hybridlane.devices.preprocess¶
Transforms and utilities for preprocessing quantum circuits before execution.
Functions¶
|
Circuit pass that validates a wire is only used as a qubit or a qumode |
|
Transform pass that fills in missing wire dimensions for measurements |
Module Contents¶
- hybridlane.devices.preprocess.static_analyze_tape(tape)[source]¶
Circuit pass that validates a wire is only used as a qubit or a qumode
This validates that once a wire is used in an operation as a qubit or a qumode, that its role remains the same in the rest of the circuit. This is physically motivated since a device cannot perform swap gates between qubits and qumodes (there would be truncation issues).
Example:
# This would throw an error def bad_circuit(): qp.Displacement(alpha, 0, wires=[0]) qp.X(1) qp.H(0) # error: wire 0 became a qumode earlier during Displacement
- Parameters:
tape (QuantumScript) – The quantum circuit to check
- Raises:
StaticAnalysisError – qumode across the circuit, or if its type cannot be inferred and no default is provided.
- Return type:
tuple[pennylane.tape.QuantumScriptBatch, pennylane.typing.PostprocessingFn]
- hybridlane.devices.preprocess.fill_wire_dims(tape, wire_dims=None, default_qumode_dim=None)[source]¶
Transform pass that fills in missing wire dimensions for measurements
To be compatible with JAX, certain measurements require the wire dimensions to be known at construction time so that JAX may deduce their shape statically. However, in hybridlane, truncations are set by the device and not the circuit definition, so this pass inserts the dimensions into the measurements after the circuit has been constructed.