mqt.qmap.ph.subcircuit_compilation¶
Photonic MZI-mesh subcircuit compiler.
Classes¶
Hyperparameters for the phase-shifter optimization. |
|
Output of a single |
Functions¶
|
Compile a target unitary onto the chip and return the phases to program. |
Module Contents¶
- class OptimizationConfig[source]¶
Hyperparameters for the phase-shifter optimization.
- lr¶
Initial Adam learning rate.
- threshold¶
Fidelity-loss value below which optimization terminates early.
- max_iterations¶
Maximum gradient steps.
- exclude_edge_phase_shifters¶
If
True, the two edge phase shifters are excluded from the parameter set.
- optimize_routing_parameters¶
If
True, routing MZI cells contribute a single trainable degree of freedom.
- class CompilationResult[source]¶
Output of a single
compile_subcircuit()call.This is the end-user result of compiling a target unitary onto a physical chip. It carries everything needed to drive the hardware: the phase-shifter values to program, and the input/output ports the photons enter and leave on.
- phases¶
Flat list of
chip_dim ** 2phase-shifter angles in column-major (layer-by-layer) order - every mode phase of layer 0, then every mode phase of layer 1, and so on. The value for spatial moderin MZI layercis at indexc * chip_dim + r. These are the values to program onto the chip.
- input_ports¶
Physical mode indices into which photons are injected (the lower mode of each dual-rail pair), length
target_dim // 2.
- output_ports¶
Physical mode indices of the computation zone where the output photons are measured, length
target_dim.
- loss¶
Fidelity loss of the returned phases.
- compute_time¶
Elapsed seconds for routing and phase optimization.
- compile_subcircuit(beam_splitter_reflectivities: list[float], input_transmissions: list[float], output_transmissions: list[float], target_unitary: torch.Tensor, config: OptimizationConfig | None = None) CompilationResult[source]¶
Compile a target unitary onto the chip and return the phases to program.
chip_dimis derived fromlen(input_transmissions)andtarget_dimfromtarget_unitary.shape[0].The compiler searches for the optimal photon routing through the chip (the path minimizing overall photon loss, independent of the target operation) and then optimizes the phase-shifter parameters for that placement.
- Parameters:
beam_splitter_reflectivities – Flat list of measured chip beam-splitter reflectivities ordered MZI-by-MZI as in/out pairs, layer by layer.
input_transmissions – Per-mode input transmission coefficients, a list of length
chip_dim. Its length determineschip_dim.output_transmissions – Per-mode output transmission coefficients, a list of length
chip_dim.target_unitary – Target unitary tensor of shape
(target_dim, target_dim). Its first dimension determinestarget_dim.config – Optimization hyperparameters. Defaults to
OptimizationConfigwith all defaults whenNone.
- Returns:
A
CompilationResultcontaining the flat phase-shifter list to program, the input/output ports, the final fidelity loss, and the compilation compute time.- Raises:
ValueError – If
target_unitaryis not a square, even-dimensioned, finite complex matrix withtarget_dim < chip_dim; if either transmission vector does not have exactlychip_dimfinite values in[0, 1]; or ifbeam_splitter_reflectivitiesdoes not have exactlychip_dim * (chip_dim - 1)finite values in[0, 1]; or if no route has nonzero transmission.
Note
No hardware simulation is performed, so this step is suitable for chips too large to simulate classically.