API Reference¶
This reference documents the public API: the Executor factory, the
shared executor interface, the backend-agnostic building blocks, and each
backend plugin.
The Executor factory¶
Executor is the entry point for creating backend
executors. It is a factory and cannot be instantiated directly — use
create().
- class qc_executor.factory.Executor[source]¶
Bases:
objectFactory class for creating executor instances based on backend name.
This class provides a plugin-based architecture for executor backends. Backends can be registered using the @Executor.register() decorator or discovered automatically via entry points.
Example
>>> executor = Executor.create("qiskit", shots=1024) >>> backends = Executor.available_backends() >>> print(backends) # ['qiskit', 'pennylane', 'qulacs']
- classmethod register(name)[source]¶
Decorator to register a backend implementation.
- Parameters:
name (
str) – The name of the backend (e.g., “qiskit”, “pennylane”, “qulacs”)- Return type:
Callable[[Type[ExecutorBase]],Type[ExecutorBase]]- Returns:
Decorator function that registers the backend class
- Raises:
TypeError – If the decorated class does not inherit from ExecutorBase
Example
>>> @Executor.register("qiskit") ... class QiskitExecutor(ExecutorBase): ... pass
- classmethod create(target, **kwargs)[source]¶
Create an executor instance for the specified backend.
- Parameters:
target (
str|Any) – Name of the backend (e.g., “qiskit”, “pennylane”, “qulacs”). May also be a QiskitBackend/BackendV2instance, in which case the"qiskit"executor is used automatically and the object is forwarded asbackend=<instance>.**kwargs – Configuration parameters passed to the backend constructor
- Return type:
- Returns:
An instance of the requested backend executor
- Raises:
ValueError – If the backend is not found or not installed
Example
>>> executor = Executor.create("qiskit", shots=1024, seed=42) >>> executor = Executor.create("pennylane", shots=1000)
- classmethod available_backends()[source]¶
Get a list of available (installed) backends.
- Return type:
list[str]- Returns:
List of backend names that can be used with create()
Example
>>> backends = Executor.available_backends() >>> print(backends) # ['qiskit', 'pennylane', 'qulacs']
- classmethod switch_backend(executor, backend, **overrides)[source]¶
Switch an executor to a different backend while preserving its configuration.
Creates a new executor instance with the specified backend, copying the current configuration and applying any overrides.
- Parameters:
executor (ExecutorBase) – The existing executor whose configuration should be copied.
backend (
str|Any) – Name of the backend to switch to (e.g.,"qiskit","pennylane","qulacs"). May also be a QiskitBackend/BackendV2instance, in which case the"qiskit"executor is used automatically.**overrides – Configuration parameters to override (e.g., shots=2048)
- Returns:
New executor instance with the specified backend
- Return type:
Example
>>> executor = Executor.create("qiskit", shots=1024, seed=42) >>> pennylane_executor = Executor.switch_backend(executor, "pennylane") >>> # pennylane_executor has shots=1024, seed=42 >>> >>> # Override specific parameters >>> qulacs_executor = Executor.switch_backend(executor, "qulacs", shots=2048) >>> # qulacs_executor has shots=2048, seed=42 >>> >>> # Switch to a real IBM Quantum backend >>> from qiskit_ibm_runtime import QiskitRuntimeService >>> service = QiskitRuntimeService() >>> ibm_backend = service.least_busy(operational=True, simulator=False) >>> ibm_executor = Executor.switch_backend(executor, ibm_backend)
Core building blocks¶
Backend-agnostic circuit, observable, and parameter types from the package root.
- class qc_executor.quantum_circuit.QuantumCircuit(num_qubits, _native_circuit=None)[source]¶
Bases:
QuantumCircuitBaseBase class for quantum circuits for different quantum frameworks.
- Parameters:
num_qubits (int) – Number of qubits in the circuit
_native_circuit (QiskitQuantumCircuit | None)
- classmethod from_quantum_circuit(circuit)[source]¶
Identity conversion for generic circuits.
- Return type:
QuantumCircuitBase- Parameters:
circuit (QuantumCircuitBase)
- property qiskit_circuit: QuantumCircuit¶
The underlying Qiskit circuit.
- property num_qubits: int¶
Return the number of qubits in the circuit.
- property parameters: List[ParameterVectorElement]¶
Return the free trainable parameters in the circuit.
- property num_parameters: int¶
Return the number of free trainable parameters in the circuit.
- property is_parameterized: bool¶
Check if the wavefunction is parameterized.
- cp(control_qubit, target_qubit, angle)[source]¶
Add CP gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- cx(control_qubit, target_qubit)[source]¶
Add CNOT gates
- Parameters:
control_qubit (int)
target_qubit (int)
- cy(control_qubit, target_qubit)[source]¶
Add CY gates
- Parameters:
control_qubit (int)
target_qubit (int)
- cz(control_qubit, target_qubit)[source]¶
Add CZ gates
- Parameters:
control_qubit (int)
target_qubit (int)
- cnot(control_qubit, target_qubit)[source]¶
Add CNOT gates
- Parameters:
control_qubit (int)
target_qubit (int)
- ccx(control_qubit1, control_qubit2, target_qubit)[source]¶
Add Toffoli (CCX) gates
- Parameters:
control_qubit1 (int)
control_qubit2 (int)
target_qubit (int)
- toffoli(control_qubit1, control_qubit2, target_qubit)[source]¶
Add Toffoli (CCX) gates
- Parameters:
control_qubit1 (int)
control_qubit2 (int)
target_qubit (int)
- ecr(control_qubit, target_qubit)[source]¶
Add ECR gates
- Parameters:
control_qubit (int)
target_qubit (int)
- crx(control_qubit, target_qubit, angle)[source]¶
Add CRX gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- cry(control_qubit, target_qubit, angle)[source]¶
Add CRY gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- crz(control_qubit, target_qubit, angle)[source]¶
Add CRZ gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- rxx(control_qubit, target_qubit, angle)[source]¶
Add RXX gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- ryy(control_qubit, target_qubit, angle)[source]¶
Add RYY gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- rzz(control_qubit, target_qubit, angle)[source]¶
Add RZZ gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- rzx(control_qubit, target_qubit, angle)[source]¶
Add RZX gates
- Parameters:
control_qubit (int)
target_qubit (int)
angle (float)
- compose(qc, qubits)[source]¶
Compose two quantum circuits.
- Return type:
- Parameters:
qc (QuantumCircuitBase)
qubits (List[int])
- assign_parameters(parameters)[source]¶
Change parameters in the circuit.
- Parameters:
parameters (np.array) – parameters to assign to the circuit
- class qc_executor.quantum_operator.QuantumOperator(paulis=None, coeffs=None, num_qubits=None, _native_operator=None)[source]¶
Bases:
QuantumOperatorBaseQuantum operator backed by a Qiskit SparsePauliOp.
- Parameters:
paulis (Optional[List[str]])
coeffs (Optional[List[float]])
num_qubits (Optional[int])
_native_operator (Optional[SparsePauliOp])
- classmethod from_quantum_operator(operator)[source]¶
Identity conversion for generic operators.
- Return type:
QuantumOperatorBase- Parameters:
operator (QuantumOperatorBase)
- property qiskit_operator: SparsePauliOp¶
The underlying Qiskit SparsePauliOp.
- property num_qubits: int¶
Return the number of qubits in the circuit.
- property num_paulis: int¶
Return the number of Paulis in the operator.
- property paulis: List[str]¶
Return the list of Paulis.
- property coeffs: List¶
Return the list of coefficients.
- property is_parametrized: bool¶
Return True if the operator is parametrized.
- property parameters: list¶
Return the parameters of the operator.
- Returns:
List of parameters.
- property num_parameters: int¶
Return the number of parameters in the operator.
- Returns:
Number of parameters.
- copy()[source]¶
Return a copy of the operator.
- Return type:
QuantumOperatorBase- Returns:
Copy of the operator.
- adjoint()[source]¶
Return the adjoint of the operator.
- Return type:
QuantumOperatorBase- Returns:
Adjoint of the operator.
- apply_layout(layout)[source]¶
Apply a layout to the operator.
- Parameters:
layout (List[int]) – Layout to apply.
- Return type:
QuantumOperatorBase- Returns:
Operator with applied layout.
- compose(other)[source]¶
Compose the operator with another operator.
- Parameters:
other (QuantumOperatorBase) – Operator to compose with.
- Return type:
QuantumOperatorBase- Returns:
Composed operator.
- append(pauli, coeff=None)[source]¶
Append a Pauli operator with a coefficient to the operator.
- Parameters:
pauli (str) – Pauli operator to append.
coeff (float) – Coefficient of the Pauli operator.
- Return type:
QuantumOperatorBase
- simplify()[source]¶
Simplify the operator.
- Return type:
QuantumOperatorBase- Returns:
Simplified operator.
- transpose()[source]¶
Return the transpose of the operator.
- Return type:
QuantumOperatorBase- Returns:
Transpose of the operator.
- conjugate()[source]¶
Return the conjugate of the operator.
- Return type:
QuantumOperatorBase- Returns:
Conjugate of the operator.
- group_commuting()[source]¶
Group commuting operators.
- Return type:
List[QuantumOperatorBase]- Returns:
List of commuting operators.
- property is_unitary: bool¶
Return True if the operator is unitary.
- Returns:
True if the operator is unitary.
- property is_real: bool¶
Return True if the operator is real.
- Returns:
True if the operator is real.
- property is_imaginary: bool¶
Return True if the operator is imaginary.
- Returns:
True if the operator is imaginary.
- qc_executor.parameters.Parameters¶
alias of
ParameterVector
Backend plugins¶
Each plugin provides an executor plus native circuit/operator wrappers. You
normally obtain an executor through Executor.create("<name>") rather than
instantiating these classes directly, but their public classes are documented
on the per-plugin pages below.
Qiskit backend for the executor framework. |
|
PennyLane backend for Executor. |
|
Qulacs backend for Executor. |
|
Pauli Propagation Package for Quantum Computing. |