You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running the latest versions of pyQuil and the Forest SDK
I checked to make sure that this bug has not already been reported
Issue Description
Is program_unitary supposed to work with Custom gates? I couldn't find any docs and it feels like it should work with any circuit.
How to Reproduce
If useful, provide a numbered list of the steps that result in the error.
Otherwise, just fill out the "Code Snippet" and "Error Output" sections below.
Code Snippet
importnumpyasnpfrompyquilimportProgramfrompyquil.quilimportDefGatefrompyquil.simulation.toolsimportprogram_unitary# First we define the new gate from a matrixsqrt_x=np.array([[ 0.5+0.5j, 0.5-0.5j],
[ 0.5-0.5j, 0.5+0.5j]])
# Get the Quil definition for the new gatesqrt_x_definition=DefGate("SQRT-X", sqrt_x)
# Get the gate constructorSQRT_X=sqrt_x_definition.get_constructor()
# Then we can use the new gatep=Program()
p+=sqrt_x_definitionp+=SQRT_X(0)
program_unitary(p, 1)
Error Output
KeyError Traceback (most recent call last)
Cell In[3], line 1
----> 1 program_unitary(p, 2)
File ~/Desktop/bloqs/env/lib/python3.10/site-packages/pyquil/simulation/tools.py:335, in program_unitary(program, n_qubits)
333 for instruction in program:
334 if isinstance(instruction, Gate):
--> 335 unitary = lifted_gate(gate=instruction, n_qubits=n_qubits)
336 umat = unitary.dot(umat)
337 elif isinstance(instruction, Halt):
File ~/Desktop/bloqs/env/lib/python3.10/site-packages/pyquil/simulation/tools.py:320, in lifted_gate(gate, n_qubits)
317 else:
318 raise TypeError("Unsupported gate modifier {}".format(mod))
--> 320 matrix = _gate_matrix(gate)
322 return lifted_gate_matrix(matrix=matrix, qubit_inds=[q.index for q in gate.qubits], n_qubits=n_qubits)
File ~/Desktop/bloqs/env/lib/python3.10/site-packages/pyquil/simulation/tools.py:296, in lifted_gate.<locals>._gate_matrix(gate)
294 return QUANTUM_GATES[gate.name](*gate.params) # type: ignore
295 else:
--> 296 return QUANTUM_GATES[gate.name] # type: ignore
297 else:
298 mod = gate.modifiers[0]
KeyError: 'SQRT-X'
Environment Context
Operating System: Mac OS Ventura 13.1 (Apple M1 Pro)
Python Version (e): Python 3.10.6
Quilc Version (quilc --version): 1.23.0 [e6c0939]
QVM Version (qvm --version): 1.17.1 [cf3f91f]
Python Environment Details (pip freeze or conda list):
Pre-Report Checklist
Issue Description
Is
program_unitary
supposed to work with Custom gates? I couldn't find any docs and it feels like it should work with any circuit.How to Reproduce
If useful, provide a numbered list of the steps that result in the error.
Otherwise, just fill out the "Code Snippet" and "Error Output" sections below.
Code Snippet
Error Output
Environment Context
Operating System: Mac OS Ventura 13.1 (Apple M1 Pro)
Python Version (
e
): Python 3.10.6Quilc Version (
quilc --version
): 1.23.0 [e6c0939]QVM Version (
qvm --version
): 1.17.1 [cf3f91f]Python Environment Details (
pip freeze
orconda list
):The text was updated successfully, but these errors were encountered: