pyqrack.qrack_circuit
¶
Module Contents¶
Classes¶
Class that exposes the QCircuit class of Qrack |
Attributes¶
- pyqrack.qrack_circuit._IS_QISKIT_AVAILABLE = True¶
- pyqrack.qrack_circuit._IS_QISKIT_AVAILABLE = False¶
- pyqrack.qrack_circuit._IS_QUIMB_AVAILABLE = True¶
- pyqrack.qrack_circuit._IS_QUIMB_AVAILABLE = False¶
- pyqrack.qrack_circuit._IS_TENSORCIRCUIT_AVAILABLE = True¶
- pyqrack.qrack_circuit._IS_TENSORCIRCUIT_AVAILABLE = False¶
- class pyqrack.qrack_circuit.QrackCircuit(is_collapse=True, clone_cid=-1, is_inverse=False, past_light_cone=[])¶
Class that exposes the QCircuit class of Qrack
QrackCircuit allows the user to specify a unitary circuit, before running it. Upon running the state, the result is a QrackSimulator state. Currently, measurement is not supported, but measurement can be run on the resultant QrackSimulator.
- cid¶
Qrack ID of this circuit
- Type:
int
- __del__()¶
- _ulonglong_byref(a)¶
- _double_byref(a)¶
- _complex_byref(a)¶
- clone()¶
Make a new circuit that is an exact clone of this circuit
- Raises:
RuntimeError – QrackCircuit C++ library raised an exception.
- inverse()¶
Make a new circuit that is the exact inverse of this circuit
- Raises:
RuntimeError – QrackCircuit C++ library raised an exception.
- past_light_cone(q)¶
Make a new circuit with just this circuits’ past light cone for certain qubits.
- Parameters:
q – list of qubit indices to include at beginning of past light cone
- Raises:
RuntimeError – QrackCircuit C++ library raised an exception.
- get_qubit_count()¶
Get count of qubits in circuit
- Raises:
RuntimeError – QrackCircuit C++ library raised an exception.
- swap(q1, q2)¶
Add a ‘Swap’ gate to the circuit
- Parameters:
q1 – qubit index #1
q2 – qubit index #2
- Raises:
RuntimeError – QrackCircuit C++ library raised an exception.
- mtrx(m, q)¶
Operation from matrix.
Applies arbitrary operation defined by the given matrix.
- Parameters:
m – row-major complex list representing the operator.
q – the qubit number on which the gate is applied to.
- Raises:
ValueError – 2x2 matrix ‘m’ in QrackCircuit.mtrx() must contain at least 4 elements.
RuntimeError – QrackSimulator raised an exception.
- ucmtrx(c, m, q, p)¶
Multi-controlled single-target-qubit gate
Specify a controlled gate by its control qubits, its single-qubit matrix “payload,” the target qubit, and the permutation of qubits that activates the gate.
- Parameters:
c – list of controlled qubits
m – row-major complex list representing the operator.
q – target qubit
p – permutation of target qubits
- Raises:
ValueError – 2x2 matrix ‘m’ in QrackCircuit.ucmtrx() must contain at least 4 elements.
RuntimeError – QrackSimulator raised an exception.
- run(qsim)¶
Run circuit on simulator
Run the encoded circuit on a specific simulator. The result will remain in this simulator.
- Parameters:
qsim – QrackSimulator on which to run circuit
- Raises:
RuntimeError – QrackCircuit raised an exception.
- out_to_file(filename)¶
Output optimized circuit to file
Outputs the (optimized) circuit to a file named according to the “filename” parameter.
- Parameters:
filename – Name of file
- in_from_file()¶
Read in optimized circuit from file
Reads in an (optimized) circuit from a file named according to the “filename” parameter.
- Parameters:
filename – Name of file
- file_to_qiskit_circuit()¶
Convert an output file to a Qiskit circuit
Reads in an (optimized) circuit from a file named according to the “filename” parameter and outputs a Qiskit circuit.
- Parameters:
filename – Name of file
- Raises:
RuntimeErorr – Before trying to file_to_qiskit_circuit() with QrackCircuit, you must install Qiskit, numpy, and math!
- in_from_qiskit_circuit()¶
Read a Qiskit circuit into a QrackCircuit
Reads in a circuit from a Qiskit QuantumCircuit
- Parameters:
circ – Qiskit circuit
- Raises:
RuntimeErorr – Before trying to file_to_qiskit_circuit() with QrackCircuit, you must install Qiskit, numpy, and math!
- file_to_quimb_circuit(circuit_type=QuimbCircuitType.Circuit, psi0=None, gate_opts=None, tags=None, psi0_dtype='complex128', psi0_tag='PSI0', bra_site_ind_id='b{}')¶
Convert an output file to a Quimb circuit
Reads in an (optimized) circuit from a file named according to the “filename” parameter and outputs a Quimb circuit.
- Parameters:
filename – Name of file
circuit_type – “QuimbCircuitType” enum value specifying type of Quimb circuit
psi0 – The initial state, assumed to be |00000….0> if not given. The state is always copied and the tag PSI0 added
gate_opts – Default keyword arguments to supply to each gate_TN_1D() call during the circuit
tags – Tag(s) to add to the initial wavefunction tensors (whether these are propagated to the rest of the circuit’s tensors
psi0_dtype – Ensure the initial state has this dtype.
psi0_tag – Ensure the initial state has this tag.
bra_site_ind_id – Use this to label ‘bra’ site indices when creating certain (mostly internal) intermediate tensor networks.
- Raises:
RuntimeErorr – Before trying to file_to_quimb_circuit() with QrackCircuit, you must install quimb, Qiskit, numpy, and math!
- file_to_tensorcircuit(inputs=None, circuit_params=None, binding_params=None)¶
Convert an output file to a TensorCircuit circuit
Reads in an (optimized) circuit from a file named according to the “filename” parameter and outputs a TensorCircuit circuit.
- Parameters:
filename – Name of file
inputs – pass-through to tensorcircuit.Circuit.from_qiskit
circuit_params – pass-through to tensorcircuit.Circuit.from_qiskit
binding_params – pass-through to tensorcircuit.Circuit.from_qiskit
- Raises:
RuntimeErorr – Before trying to file_to_quimb_circuit() with QrackCircuit, you must install TensorCircuit, Qiskit, numpy, and math!
- in_from_tensorcircuit(enable_instruction=False, enable_inputs=False)¶
Convert a TensorCircuit circuit to a QrackCircuit
Accepts a TensorCircuit circuit and outputs an equivalent QrackCircuit
- Parameters:
tcirc – TensorCircuit circuit
enable_instruction – whether to also export measurement and reset instructions
enable_inputs – whether to also export the inputs
- Raises:
RuntimeErorr – Before trying to in_from_tensorcircuit() with QrackCircuit, you must install TensorCircuit, Qiskit, numpy, and math!