### prob_all(q) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Get the probabilities of all permutations of the subset. ```APIDOC ## prob_all(q) ### Description Probabilities of all subset permutations. ### Parameters - **q** (list) - List of qubit ids ### Returns - **list** - List representing the state vector ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### QrackSimulator Constructor Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Initializes a new QrackSimulator instance with specified configuration parameters. ```APIDOC ## QrackSimulator(qubit_count, clone_sid, is_schmidt_decompose_multi, is_stabilizer_hybrid, is_binary_decision_tree, is_gpu, is_host_pointer, is_sparse, is_near_clifford_tableau_writer, noise, pyzx_circuit, qiskit_circuit) ### Description Initializes the simulator interface for Qrack functionality. ### Parameters - **qubit_count** (int) - Optional - Number of qubits. - **is_gpu** (bool) - Optional - Whether to use GPU acceleration. - **noise** (float) - Optional - Noise level. ``` -------------------------------- ### QrackCircuit.run(qsim) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Executes the circuit on a simulator. ```APIDOC ## QrackCircuit.run(qsim) ### Description Runs the defined circuit on the provided simulator instance. ``` -------------------------------- ### prob(q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Get the probability that a qubit is in the |1> state. ```APIDOC ## prob(q) ### Description Get the probability that a qubit is in the |1> state. ### Parameters - **q** (int) - Required - Qubit id ### Returns - **float** - Probability of qubit being in |1> ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### prob_rdm(q) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Gets the probability that a qubit is in the |1> state via RDM. ```APIDOC ## prob_rdm(q) ### Description Get the probability that a qubit is in the |1> state, tracing out the reduced density matrix. ### Parameters - **q** (int) - Required - Qubit ID. ### Returns - (float) - Probability of qubit being in |1>. ``` -------------------------------- ### QrackCircuit.run Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Executes the defined circuit on a provided QrackSimulator instance. ```APIDOC ## run(qsim) ### Description Runs the encoded circuit on the specified simulator. ### Parameters - **qsim** (QrackSimulator) - Required - The simulator instance to execute the circuit on. ``` -------------------------------- ### run_pyzx_gates(gates) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Converts PYZX gates to a QRackSimulator and executes them immediately. ```APIDOC ## run_pyzx_gates(gates) ### Description Executes a list of PYZX gates on the QRackSimulator. ### Parameters - **gates** (list) - Required - A list of PYZX gates to execute. ### Raises - **RuntimeError** - Raised if the QrackSimulator encounters an exception. ``` -------------------------------- ### permutation_expectation(q) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Get the permutation expectation value, based upon the order of input qubits. ```APIDOC ## permutation_expectation(q) ### Description Permutation expectation value. ### Parameters - **q** (list) - Qubits, from low to high ### Returns - **float** - Expectation value ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### prob_perm(q, c) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Get the probability that the qubit IDs in 'q' have the truth values in 'c'. ```APIDOC ## prob_perm(q, c) ### Description Get the probability that the qubit IDs in 'q' have the truth values in 'c', directly corresponding by list index. ### Parameters - **q** (list) - Required - List of qubit ids - **c** (list) - Required - List of qubit truth values bools ### Returns - **float** - Probability that each qubit in 'q[i]' has corresponding truth value in 'c[i]' ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### QrackNearCliffordQecBackend Constructor Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_near_clifford_qec_backend/index.rst.txt Initializes a new instance of the QrackNearCliffordQecBackend class. ```APIDOC ## QrackNearCliffordQecBackend(qubit_count=1, code_len=5, layers_per_qec_round=0, is_eager=True, to_clone=None) ### Description Initializes the near-Clifford quantum error correction back end. ### Parameters - **qubit_count** (int) - Optional - Number of qubits. - **code_len** (int) - Optional - Length of the repetition code. - **layers_per_qec_round** (int) - Optional - Number of layers per QEC round. - **is_eager** (bool) - Optional - Whether to use eager execution. - **to_clone** (object) - Optional - Instance to clone from. ``` -------------------------------- ### run_qiskit_circuit(experiment, shots=1) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Executes a Qiskit circuit using the Qrack simulator. ```APIDOC ## run_qiskit_circuit(experiment, shots=1) ### Description Executes a provided Qiskit circuit experiment on the Qrack simulator for a specified number of shots. ### Parameters - **experiment** (object) - The Qiskit circuit experiment to run. - **shots** (int) - The number of times to execute the circuit (default: 1). ``` -------------------------------- ### Configuration Methods Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Methods for configuring the simulator environment. ```APIDOC ## set_concurrency(p) Sets the CPU parallel thread count. ## set_device(d) Sets the GPU device ID. ## seed(s) Sets the random seed for the simulator. ``` -------------------------------- ### learn_cycle(e=True) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Runs a full learning cycle. ```APIDOC ## learn_cycle(e=True) ### Description A learning cycle consists of predicting a result, saving the classical outcome, and uncomputing the prediction. ### Parameters - **e** (bool) - Optional - If False, predict the opposite ### Raises - **RuntimeError** - QrackNeuron C++ library raised an exception. ``` -------------------------------- ### QrackSimulator Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt The primary interface for Qrack quantum simulation functionality. ```APIDOC ## QrackSimulator(qubit_count, ...) ### Description Initializes a new Qrack simulator instance. ### Parameters - **qubit_count** (int) - Number of qubits. - **is_gpu** (bool) - Whether to use GPU acceleration. - **noise** (float) - Noise level for the simulation. ``` -------------------------------- ### m_all() Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Measures all qubits in the simulator. ```APIDOC ## m_all() ### Description Measure-all gate. Measures all qubits. This operator is not unitary & is probabilistic in nature. ### Returns - Measurement result of all qubits. ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### QrackSystem Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_system/index.rst.txt The QrackSystem class is the primary interface for managing the quantum simulation environment. ```APIDOC ## class QrackSystem ### Description Represents the core system for Qrack quantum simulations. ### Attributes - **fppow** (int) - Default value: 5 ``` -------------------------------- ### Simulator Configuration Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Methods for configuring simulator settings like concurrency and device selection. ```APIDOC ## set_concurrency(p) ### Description Sets the CPU parallel thread count. ## set_device(d) ### Description Sets the GPU device ID. ``` -------------------------------- ### QrackStabilizer Constructor Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_stabilizer/index.rst.txt Initializes a new QrackStabilizer instance. ```APIDOC ## QrackStabilizer(qubit_count=-1, clone_sid=-1, pyzx_circuit=None, qiskit_circuit=None) ### Description Initializes the QrackStabilizer interface for pure-stabilizer functionality. ### Parameters - **qubit_count** (int) - Optional - Number of qubits. - **clone_sid** (int) - Optional - Simulator ID to clone. - **pyzx_circuit** (object) - Optional - PyZX circuit input. - **qiskit_circuit** (object) - Optional - Qiskit circuit input. ``` -------------------------------- ### QrackCircuit.clone() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Creates an exact clone of the current circuit instance. ```APIDOC ## QrackCircuit.clone() ### Description Creates a new circuit instance that is an exact clone of the current circuit. ### Raises - **RuntimeError** - QrackCircuit C++ library raised an exception. ``` -------------------------------- ### QrackSystem Class Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_system/qrack_system/index.rst.txt The QrackSystem class provides the primary interface for interacting with the quantum system. It includes configuration attributes such as fppow. ```APIDOC ## Class: QrackSystem ### Description Represents the quantum system interface in pyqrack. This class is used to initialize and manage system-level quantum parameters. ### Attributes - **fppow** (int) - A configuration attribute for the system, default value is 5. ``` -------------------------------- ### run_qiskit_circuit Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_near_clifford_qec_backend/index.rst.txt Executes a Qiskit circuit on the backend. ```APIDOC ## run_qiskit_circuit(experiment, shots=1) ### Description Runs a provided Qiskit experiment circuit on the backend for a specified number of shots. ``` -------------------------------- ### QrackNeuron.clone() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Creates an independent clone of the current QrackNeuron instance with identical configuration. ```APIDOC ## clone() ### Description Clones this neuron. Create a new, independent neuron instance with identical angles, inputs, output, and tolerance, for the same QrackSimulator. ### Exceptions - **RuntimeError** - QrackNeuron C++ library raised an exception. ``` -------------------------------- ### file_to_qiskit_circuit(is_hardware_encoded=False) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Converts an output state file to a Qiskit circuit. ```APIDOC ## file_to_qiskit_circuit(is_hardware_encoded=False) ### Description Reads in an optimized circuit from a file and outputs a Qiskit circuit. ### Parameters - **filename** (str) - Required - Name of the file. ### Raises - **RuntimeError** - Requires Qiskit, numpy, and math to be installed. ``` -------------------------------- ### file_to_qiskit_circuit(filename) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Converts an optimized circuit file to a Qiskit circuit. ```APIDOC ## file_to_qiskit_circuit(filename) ### Description Reads in an optimized circuit from a file and outputs a Qiskit circuit. ### Parameters - **filename** (string) - Required - Name of file ### Exceptions - **RuntimeError** - Requires Qiskit, numpy, and math to be installed. ``` -------------------------------- ### run_pyzx_gates(gates) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Executes a list of PYZX gates on the simulator. ```APIDOC ## run_pyzx_gates(gates) ### Description Converts PYZX gates to QRackSimulator operations and immediately executes them. ### Parameters - **gates** (list) - Required - List of PYZX gates ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### load_data(sim, index_bits, value_bits, data) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/stats/load_quantized_data/index.rst.txt Loads discretized features from quantize_by_range into a QrackSimulator. ```APIDOC ## load_data(sim, index_bits, value_bits, data) ### Description Takes discretized features from quantize_by_range and loads them into a QrackSimulator. ### Parameters - **sim** (QrackSimulator) - Required - Simulator into which to load data. - **index_bits** (list[int]) - Required - List of index bits, least-to-most significant. - **value_bits** (list[int]) - Required - List of value bits, least-to-most significant. - **data** (list[list[bool]]) - Required - Data to load, row-major. ### Errors - **ValueError** - Raised if the length of value_bits does not match the data feature column count. ``` -------------------------------- ### QrackNeuron.set_simulator(s, controls=None, target=None) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Configures the simulator and qubit identifiers for the neuron. ```APIDOC ## set_simulator(s, controls=None, target=None) ### Description Set the simulator used by this neuron. ### Parameters - **s** (QrackSimulator) - Required - The simulator to use - **controls** (list[int]) - Optional - The control qubit IDs to use - **target** (int) - Optional - The output qubit ID to use ### Exceptions - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### Static Helper Methods Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron/index.rst.txt Utility methods for data processing including quantile calculation, discretization, and matrix manipulation. ```APIDOC ### quantile_bounds(vec, bits) - **vec**: numerical vector - **bits**: log2() of quantile count - **Returns**: Quantile (n + 1) bounds. ### discretize(vec, bounds) - **vec**: numerical vector - **bounds**: (n + 1) n-quantile bounds - **Returns**: Discretized bit-row vector. ### flatten_and_transpose(arr) - **arr**: bit-row matrix - **Returns**: Observation-row matrix with flat feature columns. ### bin_endpoints_average(bounds) - **bounds**: (n + 1) n-quantile bounds - **Returns**: List of average points between bin endpoints. ``` -------------------------------- ### in_from_file(filename) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Reads an optimized circuit from a file. ```APIDOC ## in_from_file(filename) ### Description Reads in an (optimized) circuit from a file named according to the "filename" parameter. ### Parameters - **filename** (string) - Required - Name of file ``` -------------------------------- ### file_to_quimb_circuit(filename, ...) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Converts an optimized circuit file to a Quimb circuit. ```APIDOC ## file_to_quimb_circuit(filename, circuit_type=QuimbCircuitType.Circuit, psi0=None, gate_opts=None, tags=None, psi0_dtype='complex128', psi0_tag='PSI0', bra_site_ind_id='b{}') ### Description Reads in an optimized circuit from a file and outputs a Quimb circuit. ### Parameters - **filename** (string) - Required - Name of file - **circuit_type** (QuimbCircuitType) - Optional - Type of Quimb circuit - **psi0** (any) - Optional - Initial state - **gate_opts** (dict) - Optional - Default keyword arguments for gate_TN_1D - **tags** (list) - Optional - Tags to add to initial wavefunction tensors - **psi0_dtype** (string) - Optional - Dtype for initial state - **psi0_tag** (string) - Optional - Tag for initial state - **bra_site_ind_id** (string) - Optional - Label for bra site indices ``` -------------------------------- ### m(lq), force_m(lq, result), m_all() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_ace_backend/index.rst.txt Measurement operations. ```APIDOC ## Measurement ### Description Performs measurements on qubits. `m` measures a single qubit, `force_m` forces a measurement result, and `m_all` measures all qubits. ### Parameters - **lq** (int) - Logical qubit index - **result** (int) - Forced measurement result ``` -------------------------------- ### file_to_tensorcircuit(filename, ...) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Converts an optimized circuit file to a TensorCircuit circuit. ```APIDOC ## file_to_tensorcircuit(filename, inputs=None, circuit_params=None, binding_params=None) ### Description Reads in an optimized circuit from a file and outputs a TensorCircuit circuit. ### Parameters - **filename** (string) - Required - Name of file - **inputs** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit - **circuit_params** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit - **binding_params** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit ``` -------------------------------- ### learn(eta, e=True, r=True) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron/index.rst.txt Learns to associate current inputs with output by updating synaptic parameters based on volatility 'eta'. ```APIDOC ### Method: learn(eta, e=True, r=True) - **eta** (double): Training volatility, 0 to 1. - **e** (bool): If False, predict the opposite. - **r** (bool): If True, start by resetting the output to 50/50. - **Raises**: RuntimeError if the QrackNeuron C++ library raises an exception. ``` -------------------------------- ### in_from_file(...) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Inputs a stabilizer state from a file. ```APIDOC ## in_from_file(is_binary_decision_tree=False, is_gpu=True, is_host_pointer=False, is_sparse=False, is_near_clifford_tableau_writer=False, noise=0) ### Description Reads a hybrid stabilizer state from a file. ### Parameters - **is_binary_decision_tree** (bool) - Optional - Use binary decision tree. - **is_gpu** (bool) - Optional - Use GPU. - **is_host_pointer** (bool) - Optional - Use host pointer. - **is_sparse** (bool) - Optional - Use sparse representation. - **is_near_clifford_tableau_writer** (bool) - Optional - Use near-Clifford tableau writer. - **noise** (float) - Optional - Noise level. ``` -------------------------------- ### separate(qs) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Forces manual multi-qubit separation. ```APIDOC ### Method separate(qs) ### Description Force separation as per try_separate_tolerance. ### Parameters - **qs** (list) - List of qubits to be decomposed ``` -------------------------------- ### swap(lq1, lq2), iswap(lq1, lq2), adjiswap(lq1, lq2) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_ace_backend/index.rst.txt Applies swap operations. ```APIDOC ## Swap Gates ### Description Applies swap or iSwap operations between two logical qubits. ### Parameters - **lq1** (int) - Qubit index - **lq2** (int) - Qubit index ``` -------------------------------- ### out_to_file(filename) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Outputs the optimized circuit to a specified file. ```APIDOC ## out_to_file(filename) ### Description Outputs the (optimized) circuit to a file named according to the "filename" parameter. ### Parameters - **filename** (string) - Required - Name of file ``` -------------------------------- ### dump() Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Dumps the state vector from the selected simulator. ```APIDOC ## dump() ### Description Dump state vector from the selected simulator ID into the callback. ### Returns - (list) - State vector list. ``` -------------------------------- ### mcexp(b, ph, cs, q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Multi-controlled arbitrary exponentiation. If all controlled qubits are |1>, the target qubit is exponentiated in the Pauli basis with the given coefficient. ```APIDOC ## mcexp(b, ph, cs, q) ### Description Multi-controlled arbitrary exponentiation. If all controlled qubits are |1>, the target qubit is exponentiated in the Pauli basis with the given coefficient. ### Parameters - **b** (Pauli basis) - Pauli basis - **ph** (float) - coefficient of exponentiation - **cs** (list) - list of controlled qubits - **q** (int) - the qubit number on which the gate is applied ### Errors - **RuntimeError**: QrackSimulator raised an exception. ``` -------------------------------- ### add(a, q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Adds the given integer to the given set of qubits. ```APIDOC ## add(a, q) ### Description Adds the given integer to the given set of qubits. ### Parameters - **a** (int) - number to add - **q** (list) - list of qubits to add the number to ``` -------------------------------- ### QrackCircuit Class Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_circuit/index.html The QrackCircuit class allows the user to specify a unitary circuit before running it on a QrackSimulator. ```APIDOC ## QrackCircuit ### Constructor `QrackCircuit(is_collapse=True, is_near_clifford=False, clone_cid=-1, is_inverse=False, past_light_cone=[])` ### Methods - **clone()**: Returns a new QrackCircuit that is an exact clone of this circuit. - **inverse()**: Returns a new QrackCircuit that is the exact inverse of this circuit. - **past_light_cone(q)**: Returns a new circuit containing only the past light cone for the specified qubits. - **get_qubit_count()**: Returns the number of qubits in the circuit. - **swap(q1, q2)**: Adds a 'Swap' gate to the circuit. - **mtrx(m, q)**: Applies an arbitrary operation defined by the provided 2x2 matrix `m` to qubit `q`. - **ucmtrx(c, m, q, p)**: Applies a multi-controlled single-target-qubit gate. - **run(qsim)**: Executes the circuit on the provided `QrackSimulator`. - **out_to_file(filename)**: Exports the optimized circuit to a file. - **out_to_string()**: Returns the optimized circuit as a string. - **to_qiskit_circuit()**: Converts the circuit to a Qiskit circuit object. ### Static Methods - **in_from_file(filename)**: Reads an optimized circuit from a file. - **file_gate_count(filename)**: Returns the number of gates in a circuit file. - **file_to_qiskit_circuit(filename)**: Reads a circuit file and converts it to a Qiskit circuit. ``` -------------------------------- ### out_to_file(filename) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Outputs the stabilizer state to a file. ```APIDOC ## out_to_file(filename) ### Description Writes the current hybrid stabilizer state to the specified file. ### Parameters - **filename** (str) - Required - The path to the output file. ``` -------------------------------- ### file_to_tensorcircuit Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_circuit/index.html Converts an optimized circuit file into a TensorCircuit circuit. ```APIDOC ## static file_to_tensorcircuit(filename, inputs=None, circuit_params=None, binding_params=None) ### Description Reads in an optimized circuit from a file and outputs a TensorCircuit circuit. ### Parameters - **filename** (string) - Required - Name of file - **inputs** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit - **circuit_params** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit - **binding_params** (any) - Optional - Pass-through to tensorcircuit.Circuit.from_qiskit ### Raises - **RuntimeError** - Raised if TensorCircuit, Qiskit, numpy, or math are not installed. ``` -------------------------------- ### QrackNearCliffordQecBackend Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_near_clifford_qec_backend/index.html A back end for near-Clifford quantum error correction that uses repetition code on a near-Clifford simulator to emulate a utility-scale superconducting chip quantum computer. ```APIDOC ## class QrackNearCliffordQecBackend(qubit_count=1, code_len=5, layers_per_qec_round=0, is_eager=True, to_clone=None) ### Description Initializes a back end for near-Clifford quantum error correction. ### Parameters - **qubit_count** (int) - Optional - Number of qubits. - **code_len** (int) - Optional - Length of the repetition code. - **layers_per_qec_round** (int) - Optional - Number of layers per QEC round. - **is_eager** (bool) - Optional - Whether to use eager execution. - **to_clone** (QrackNearCliffordQecBackend) - Optional - Instance to clone. ``` -------------------------------- ### out_to_file(filename) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Outputs the hybrid stabilizer state to a file. ```APIDOC ## out_to_file(filename) ### Description Outputs the hybrid stabilizer state to a file. ### Parameters - **filename** (str) - Required - Name of the file. ``` -------------------------------- ### QrackCircuit Methods Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Methods available on the QrackCircuit class for circuit manipulation and execution. ```APIDOC ## QrackCircuit.clone() ### Description Creates a new circuit that is an exact clone of the current circuit. ## QrackCircuit.inverse() ### Description Creates a new circuit that is the exact inverse of the current circuit. ## QrackCircuit.past_light_cone(q) ### Description Creates a new circuit containing only the past light cone for the specified qubits. ### Parameters - **q** (list) - Required - List of qubit indices. ## QrackCircuit.swap(q1, q2) ### Description Adds a 'Swap' gate to the circuit. ### Parameters - **q1** (int) - Required - Qubit index #1 - **q2** (int) - Required - Qubit index #2 ## QrackCircuit.mtrx(m, q) ### Description Applies an arbitrary operation defined by the given matrix to a specific qubit. ### Parameters - **m** (list) - Required - Row-major complex list representing the operator. - **q** (int) - Required - Target qubit index. ## QrackCircuit.run(qsim) ### Description Executes the encoded circuit on the provided QrackSimulator. ### Parameters - **qsim** (QrackSimulator) - Required - The simulator instance to run the circuit on. ``` -------------------------------- ### learn(eta, e=True, r=True) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Updates synaptic parameters based on current qubit state. ```APIDOC ## learn(eta, e=True, r=True) ### Description Learn to associate current inputs with output based on input qubit states and volatility 'eta'. ### Parameters - **eta** (double) - Required - Training volatility, 0 to 1 - **e** (bool) - Optional - If False, predict the opposite - **r** (bool) - Optional - If True, start by resetting the output to 50/50 ### Raises - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### in_from_file(...) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Reads in a hybrid stabilizer state from a file. ```APIDOC ## in_from_file(is_binary_decision_tree=False, is_gpu=True, is_host_pointer=..., is_sparse=False, is_near_clifford_tableau_writer=False, noise=0) ### Description Reads in a hybrid stabilizer state from a file. ### Parameters - **filename** (str) - Required - Name of the file. ``` -------------------------------- ### file_to_optimized_qiskit_circuit Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Converts an output state file to a hyper-optimized Qiskit circuit. ```APIDOC ## file_to_optimized_qiskit_circuit() ### Description Reads in a circuit from a file and outputs a 'hyper-optimized' Qiskit circuit that favors maximum reduction in gate count and depth. ### Raises - **RuntimeError** - Requires Qiskit, numpy, and math to be installed. ``` -------------------------------- ### in_from_tensorcircuit Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_circuit/index.html Converts a TensorCircuit circuit into a QrackCircuit. ```APIDOC ## static in_from_tensorcircuit(tcirc, enable_instruction=False, enable_inputs=False) ### Description Accepts a TensorCircuit circuit and outputs an equivalent QrackCircuit. ### Parameters - **tcirc** (TensorCircuit) - Required - TensorCircuit circuit - **enable_instruction** (bool) - Optional - Whether to export measurement and reset instructions - **enable_inputs** (bool) - Optional - Whether to export the inputs ### Raises - **RuntimeError** - Raised if TensorCircuit, Qiskit, numpy, or math are not installed. ``` -------------------------------- ### file_to_quimb_circuit Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_circuit/index.html Converts an optimized circuit file into a Quimb circuit representation. ```APIDOC ## static file_to_quimb_circuit(filename, circuit_type=QuimbCircuitType.Circuit, psi0=None, gate_opts=None, tags=None, psi0_dtype='complex128', psi0_tag='PSI0', bra_site_ind_id='b{}') ### Description Reads in an optimized circuit from a file and outputs a Quimb circuit. ### Parameters - **filename** (string) - Required - Name of file - **circuit_type** (QuimbCircuitType) - Optional - Enum value specifying type of Quimb circuit - **psi0** (any) - Optional - The initial state - **gate_opts** (dict) - Optional - Default keyword arguments for gate_TN_1D - **tags** (list) - Optional - Tags to add to initial wavefunction tensors - **psi0_dtype** (string) - Optional - Dtype for initial state - **psi0_tag** (string) - Optional - Tag for initial state - **bra_site_ind_id** (string) - Optional - Label for bra site indices ### Raises - **RuntimeError** - Raised if quimb, Qiskit, numpy, or math are not installed. ``` -------------------------------- ### mcx(c, q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Multi-controlled X gate. ```APIDOC ## mcx(c, q) ### Description If all controlled qubits are |1>, the target qubit is flipped. ### Parameters - **c** (list) - List of controlled qubits - **q** (int) - Target qubit ### Errors - **RuntimeError**: QrackSimulator raised an exception. ``` -------------------------------- ### dump() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Dumps the state vector from the selected simulator ID into the callback. ```APIDOC ## dump() ### Description Dump state vector from the selected simulator ID into the callback. ### Returns - **list** - State vector list ``` -------------------------------- ### QrackSimulator.x(q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Applies the Pauli X gate (logical NOT) to the specified qubit. ```APIDOC ## QrackSimulator.x(q) ### Description Applies the Pauli X operator to the qubit at position q. This is equivalent to a logical NOT gate. ### Parameters - **q** (int) - Required - The qubit index on which the gate is applied. ### Errors - **RuntimeError** - Raised if the underlying QrackSimulator encounters an exception. ``` -------------------------------- ### QrackNeuronTorchLayer Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_neuron_torch_layer/index.html A PyTorch layer wrapper for QrackNeuron, providing a maximally expressive set of neurons between inputs and outputs. ```APIDOC ## class QrackNeuronTorchLayer(input_qubits, output_qubits, hidden_qubits=None, lowest_combo_count=0, highest_combo_count=2, activation=int(NeuronActivationFn.Generalized_Logistic), parameters=None, post_init_fn=dummy_post_init_fn, **kwargs) ### Description Torch layer wrapper for QrackNeuron. This layer manages a set of QrackNeuronTorch wrappers and provides the necessary infrastructure for quantum-classical hybrid neural network training. ### Parameters - **input_qubits** (list[int]) - Required - Simulator qubit indices used as QrackNeuron inputs. - **output_qubits** (list[int]) - Required - Simulator qubit indices used as QrackNeuron outputs. - **hidden_qubits** (list[int]) - Optional - Simulator qubit indices used as QrackNeuron hidden inputs. - **lowest_combo_count** (int) - Optional - Minimum combination count for neuron expression. - **highest_combo_count** (int) - Optional - Maximum combination count for neuron expression. - **activation** (int) - Optional - Activation function identifier. - **parameters** (Tensor) - Optional - Initial parameters for the layer. - **post_init_fn** (Callable) - Optional - Function applied after forward state initialization. ### Methods - **forward(x)**: Performs the forward pass of the quantum layer. ``` -------------------------------- ### learn_cycle(e=True) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron/index.rst.txt Runs a learning cycle consisting of predicting a result, saving the classical outcome, and uncomputing the prediction. ```APIDOC ### Method: learn_cycle(e=True) - **e** (bool): If False, predict the opposite. - **Raises**: RuntimeError if the QrackNeuron C++ library raises an exception. ``` -------------------------------- ### in_ket(ket) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Sets the state vector for the selected simulator. ```APIDOC ## in_ket(ket) ### Description Set state vector for the selected simulator ID. ### Parameters - **ket** (list) - Required - The state vector to which simulator will be set. ``` -------------------------------- ### string_to_qiskit_circuit Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_circuit/index.html Converts an optimized circuit string representation into a Qiskit QuantumCircuit object. ```APIDOC ## static string_to_qiskit_circuit(circ_string) ### Description Reads in an optimized circuit from a string parameter and outputs a Qiskit circuit. ### Parameters - **circ_string** (string) - Required - String representation of circuit ### Raises - **RuntimeError** - Raised if Qiskit, numpy, or math are not installed. ``` -------------------------------- ### out_to_string() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Outputs the optimized circuit to a string. ```APIDOC ## out_to_string() ### Description Outputs the (optimized) circuit to a string. ``` -------------------------------- ### QrackNeuronTorch Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron_torch_layer/index.rst.txt A PyTorch module wrapper for a single QrackNeuron instance. ```APIDOC ## QrackNeuronTorch(neuron, x) ### Description Wraps a QrackNeuron instance to be used as a PyTorch module. ### Attributes - **neuron** (QrackNeuron) - The underlying QrackNeuron instance. - **weights** (Parameter) - The weights associated with the neuron. ``` -------------------------------- ### cx(lq1, lq2), cy(lq1, lq2), cz(lq1, lq2) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_ace_backend/index.rst.txt Applies controlled Pauli gates. ```APIDOC ## Controlled Pauli Gates ### Description Applies controlled-X, controlled-Y, or controlled-Z gates between two logical qubits. ### Parameters - **lq1** (int) - Control qubit index - **lq2** (int) - Target qubit index ``` -------------------------------- ### QrackNeuronTorchLayer Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron_torch_layer/index.rst.txt A PyTorch layer wrapper for QrackNeuron, supporting input/output qubit configuration and activation functions. ```APIDOC ## QrackNeuronTorchLayer(input_qubits, output_qubits, hidden_qubits=None, lowest_combo_count=0, highest_combo_count=2, activation=int(NeuronActivationFn.Generalized_Logistic), parameters=None, post_init_fn=dummy_post_init_fn, **kwargs) ### Description Initializes a Torch layer wrapper for QrackNeuron, facilitating the use of quantum-inspired neurons within a PyTorch model. ### Parameters - **input_qubits** (list[int]) - Qubit indices used as inputs. - **output_qubits** (list[int]) - Qubit indices used as outputs. - **hidden_qubits** (list[int], optional) - Qubit indices used as hidden inputs. - **lowest_combo_count** (int) - Minimum combination count for neurons. - **highest_combo_count** (int) - Maximum combination count for neurons. - **activation** (int) - Activation function identifier. - **parameters** (list, optional) - Initial parameters for the layer. - **post_init_fn** (Callable) - Function applied after state initialization. ### Methods - **forward(x)**: Performs the forward pass of the layer using the provided input tensor. ``` -------------------------------- ### General Unitary and Matrix Operations Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Methods for applying custom unitary gates and matrix-defined operations. ```APIDOC ## u(q, th, ph, la) ### Description Applies a general unitary gate U(theta, phi, lambda). ### Parameters - **q** (int) - Required - Qubit index. - **th** (float) - Required - Theta. - **ph** (float) - Required - Phi. - **la** (float) - Required - Lambda. ## mtrx(m, q) ### Description Applies an arbitrary operation defined by a 2x2 matrix. ### Parameters - **m** (list) - Required - Row-major complex list representing the operator. - **q** (int) - Required - Qubit index. ``` -------------------------------- ### compose(other, q) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Composes the quantum description of a given qubit with the current system. ```APIDOC ## compose(other, q) ### Description Compose quantum description of given qubit with the current system. ### Parameters - **other** (object) - Required - The other system to compose. - **q** (int) - Required - The qubit ID. ``` -------------------------------- ### learn_permutation(eta, e=True, r=True) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_neuron/index.rst.txt Learns to associate current inputs with output under the assumption that inputs and outputs are classical. ```APIDOC ### Method: learn_permutation(eta, e=True, r=True) - **eta** (double): Training volatility, 0 to 1. - **e** (bool): If False, predict the opposite. - **r** (bool): If True, start by resetting the output to 50/50. - **Raises**: RuntimeError if the QrackNeuron C++ library raises an exception. ``` -------------------------------- ### QrackSimulator.z(q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Applies the Pauli Z gate to the specified qubit. ```APIDOC ## QrackSimulator.z(q) ### Description Applies the Pauli Z operator to the qubit at position q. This flips the phase of the |1> state. ### Parameters - **q** (int) - Required - The qubit index on which the gate is applied. ``` -------------------------------- ### out_ket() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Returns the raw state vector of the simulator. ```APIDOC ## out_ket() ### Description Returns the raw state vector of the simulator. Warning: State vector is not always the internal representation leading to sub-optimal performance of the method. ### Returns - **list** - List representing the state vector. ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### static quantile_bounds(vec, bits) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_neuron/index.html Calculates the quantile bounds of 2 ** bits worth of quantiles. ```APIDOC ## static quantile_bounds(vec, bits) ### Description Calculate vector quantile bounds. This is a static helper method to calculate the quantile bounds of 2 ** bits worth of quantiles. ### Parameters - **vec** (numerical vector) - Required - Input vector. - **bits** (int) - Required - log2() of quantile count. ### Returns - Quantile (n + 1) bounds for n-quantile division, including minimum and maximum values. ``` -------------------------------- ### qft(qs) / iqft(qs) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/index.html Applies Quantum Fourier Transform or its inverse. ```APIDOC ## qft(qs) / iqft(qs) ### Description Applies Quantum Fourier Transform or Inverse-quantum Fourier Transform on the provided list of qubits. ### Parameters - **qs** (list) - List of qubits ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### QrackCircuit.inverse() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Creates an inverse of the current circuit. ```APIDOC ## QrackCircuit.inverse() ### Description Creates a new circuit instance that is the exact inverse of this circuit. ### Raises - **RuntimeError** - QrackCircuit C++ library raised an exception. ``` -------------------------------- ### qft(qs) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Applies the Quantum Fourier Transform to a list of qubits. ```APIDOC ## qft(qs) ### Description Applies Quantum Fourier Transform on the list of qubits provided. ### Parameters - **qs**: list of qubits ### Errors - **RuntimeError**: QrackSimulator raised an exception. ``` -------------------------------- ### iqft(qs) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Applies the Inverse-quantum Fourier Transform on the provided list of qubits. ```APIDOC ## iqft(qs) ### Description Applies Inverse-quantum Fourier Transform on the list of qubits provided. ### Parameters - **qs** (list) - Required - List of qubits ### Errors - **RuntimeError** - Raised if QrackSimulator encounters an exception. ``` -------------------------------- ### try_separate_2qb(qi1, qi2) Source: https://pyqrack.readthedocs.io/en/latest/autoapi/pyqrack/qrack_simulator/index.html Attempts to decompose two qubits for performance improvement. ```APIDOC ## try_separate_2qb(qi1, qi2) ### Description Two-qubits counterpart of try_separate_1qb. ### Parameters - **qi1** (int) - Required - First qubit to be decomposed. - **qi2** (int) - Required - Second qubit to be decomposed. ### Returns - **State** (object) - State of both the qubits. ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### string_to_qiskit_circuit(circ_string) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Converts an optimized circuit string to a Qiskit circuit. ```APIDOC ## string_to_qiskit_circuit(circ_string) ### Description Reads in an optimized circuit from a string and outputs a Qiskit circuit. ### Parameters - **circ_string** (string) - Required - String representation of circuit ### Exceptions - **RuntimeError** - Requires Qiskit, numpy, and math to be installed. ``` -------------------------------- ### adds(a, s, q) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Performs signed addition of an integer to a set of qubits, handling overflow. ```APIDOC ## adds(a, s, q) ### Description Signed addition of the given integer to the given set of qubits. If there is an overflow, the result becomes negative. ### Parameters - **a** (int) - The number to add. - **s** (int) - The qubit to store overflow. - **q** (list) - The list of qubits to add the number to. ### Errors - **RuntimeError**: Raised if the QrackSimulator encounters an exception. ``` -------------------------------- ### num_qubits() Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Returns the total number of qubits in the simulator. ```APIDOC ## num_qubits() ### Description Returns the qubit count of the simulator. ### Returns - Qubit count of the simulator ### Errors - **RuntimeError**: QrackSimulator raised an exception. ``` -------------------------------- ### in_from_tensorcircuit(tcirc, ...) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt Converts a TensorCircuit circuit to a QrackCircuit. ```APIDOC ## in_from_tensorcircuit(tcirc, enable_instruction=False, enable_inputs=False) ### Description Accepts a TensorCircuit circuit and outputs an equivalent QrackCircuit. ### Parameters - **tcirc** (any) - Required - TensorCircuit circuit - **enable_instruction** (boolean) - Optional - Export measurement and reset instructions - **enable_inputs** (boolean) - Optional - Export inputs ``` -------------------------------- ### QrackCircuit.swap(q1, q2) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Adds a Swap gate to the circuit. ```APIDOC ## QrackCircuit.swap(q1, q2) ### Description Adds a 'Swap' gate to the circuit between two specified qubits. ### Parameters - **q1** (int) - Qubit index #1 - **q2** (int) - Qubit index #2 ### Raises - **RuntimeError** - QrackCircuit C++ library raised an exception. ``` -------------------------------- ### mcu(c, q, th, ph, la, gm=0.0) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Multi-controlled arbitrary unitary gate. ```APIDOC ## mcu(c, q, th, ph, la, gm=0.0) ### Description If all controlled qubits are |1>, the unitary gate described by parameters is applied to the target qubit. ### Parameters - **c** (list) - List of controlled qubits - **q** (int) - Target qubit - **th** (float) - Theta - **ph** (float) - Phi - **la** (float) - Lambda - **gm** (float) - Gamma (default 0.0) ### Errors - **RuntimeError**: QrackSimulator raised an exception. ``` -------------------------------- ### in_ket(ket) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Sets the state vector for the selected simulator ID. ```APIDOC ## in_ket(ket) ### Description Set state vector for the selected simulator ID. Warning: State vector is not always the internal representation leading to sub-optimal performance of the method. ### Parameters - **ket** (list) - Required - The state vector to which simulator will be set ### Errors - **RuntimeError** - QrackSimulator raised an exception. ``` -------------------------------- ### Logical Gate Operations (qand, qor, qxor, qnand, qnor, qxnor) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/index.rst.txt Performs standard logical operations on two qubits and stores the result in a target qubit. ```APIDOC ## Logical Gate Operations ### Description Performs logical operations (AND, OR, XOR, NAND, NOR, XNOR) on two input qubits and stores the result in a target qubit. ### Parameters - **qi1** (qubit) - First input qubit - **qi2** (qubit) - Second input qubit - **qo** (qubit) - Target qubit ### Errors - **RuntimeError** - Raised if QrackSimulator fails. ``` -------------------------------- ### QrackCircuit Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_circuit/index.rst.txt The primary class for defining and managing a unitary quantum circuit. ```APIDOC ## QrackCircuit(is_collapse=True, is_near_clifford=False, clone_cid=-1, is_inverse=False, past_light_cone=[]) ### Description Initializes a new QrackCircuit instance to define a unitary circuit. ### Parameters - **is_collapse** (bool) - Optional - Whether to enable collapse. - **is_near_clifford** (bool) - Optional - Whether to enable near-clifford optimization. - **clone_cid** (int) - Optional - ID of a circuit to clone. - **is_inverse** (bool) - Optional - Whether the circuit is an inverse. - **past_light_cone** (list) - Optional - List of qubit indices for the past light cone. ``` -------------------------------- ### get_qiskit_basis_gates Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_near_clifford_qec_backend/index.rst.txt Retrieves the basis gates supported by the backend for Qiskit integration. ```APIDOC ## get_qiskit_basis_gates() ### Description Static method that returns the list of basis gates supported by this backend. ``` -------------------------------- ### qand(qi1, qi2, qo) Source: https://pyqrack.readthedocs.io/en/latest/_sources/autoapi/pyqrack/qrack_simulator/index.rst.txt Performs a logical AND operation on two qubits. ```APIDOC ### qand(qi1, qi2, qo) Logical AND of 2 qubits whose result is stored in the target qubit. - **qi1** (int) - Qubit 1 - **qi2** (int) - Qubit 2 - **qo** (int) - Target qubit **Raises:** RuntimeError if QrackSimulator raises an exception. ```