janus.optimize#
高级电路优化模块。
基类#
TransformationPass#
AnalysisPass#
Clifford+Rz 优化#
- janus.optimize.OptimizeCliffordT#
TChinMerger的别名
- class janus.optimize.TChinMerger(*args, **kwargs)[源代码]#
An optimization pass for Clifford+T circuits.
Currently all the pass does is merging pairs of consecutive T-gates into S-gates, and pair of consecutive Tdg-gates into Sdg-gates.
- merge_t_gates(dag)[源代码]#
Run the TChinMerger pass on dag.
Enhanced version: Merges T gates more intelligently by creating a new DAG - T + T = S - T + T + T + T = Z - Tdg + Tdg = Sdg - Tdg + Tdg + Tdg + Tdg = Z
- 参数:
dag (DAGCircuit) -- The directed acyclic graph to run on.
- 返回:
Transformed DAG.
- 返回类型:
- run(dag)[源代码]#
Alias for merge_t_gates() to maintain backward compatibility.
- 参数:
dag (DAGCircuit)
门融合优化#
- janus.optimize.ConsolidateBlocks#
BlockConsolidator的别名
- janus.optimize.Optimize1qGates#
SingleQubitGateOptimizer的别名
- janus.optimize.Collect2qBlocks#
TwoQubitBlockCollector的别名
交换性优化#
- janus.optimize.CommutativeCancellation#
CommutativeGateCanceller的别名
- janus.optimize.InverseCancellation#
InverseGateCanceller的别名
模板匹配#
- janus.optimize.TemplateOptimization#
CircuitTemplateOptimizer的别名
- janus.optimize.TemplateMatching#
TemplatePatternMatcher的别名
合成算法#
KAK 分解#
- janus.optimize.TwoQubitWeylDecomposition#
KAKDecomposition的别名
- janus.optimize.TwoQubitBasisDecomposer#
KAKBasisDecomposer的别名
Clifford 合成#
- janus.optimize.synthesize_clifford_circuit(clifford, method=None)[源代码]#
Decompose a
Cliffordoperator into aQuantumCircuit.For \(N \leq 3\) qubits this is based on optimal CX-cost decomposition from reference [1]. For \(N > 3\) qubits this is done using the general non-optimal greedy compilation routine from reference [3], which typically yields better CX cost compared to the AG method in [2].
- 参数:
clifford (Clifford) -- A Clifford operator.
method (str | None) -- Optional, a synthesis method (
'AG'or'greedy'). If set this overrides optimal decomposition for \(N \leq 3\) qubits.
- 返回:
A circuit implementation of the Clifford.
- 返回类型:
引用
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
S. Aaronson, D. Gottesman, Improved Simulation of Stabilizer Circuits, Phys. Rev. A 70, 052328 (2004). arXiv:quant-ph/0406196
Sergey Bravyi, Shaohan Hu, Dmitri Maslov, Ruslan Shaydulin, Clifford Circuit Optimization with Templates and Symbolic Pauli Gates, arXiv:2105.02291 [quant-ph]
- janus.optimize.synthesize_clifford_bravyi_maslov(clifford)[源代码]#
Optimal CX-cost decomposition of a
Cliffordoperator on 2 qubits or 3 qubits into aQuantumCircuitbased on the Bravyi-Maslov method [1].- 参数:
clifford (Clifford) -- A Clifford operator.
- 返回:
A circuit implementation of the Clifford.
- 抛出:
JanusError -- if Clifford is on more than 3 qubits.
- 返回类型:
引用
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
CNOT 优化#
- janus.optimize.synthesize_cnot_count_pmh(state, section_size=None)[源代码]#
Synthesize linear reversible circuits for all-to-all architecture using Patel, Markov and Hayes method.
This function is an implementation of the Patel, Markov and Hayes algorithm from [1] for optimal synthesis of linear reversible circuits for all-to-all architecture, as specified by an \(n \times n\) matrix.
- 参数:
state (list[list[bool]] | ndarray[bool]) -- \(n \times n\) boolean invertible matrix, describing the state of the input circuit.
section_size (int | None) -- The size of each section in the Patel–Markov–Hayes algorithm [1]. If
Noneit is chosen to be \(\max(2, \alpha\log_2(n))\) with \(\alpha = 0.56\), which approximately minimizes the upper bound on the number of row operations given in [1] Eq. (3).
- 返回:
A CX-only circuit implementing the linear transformation.
- 抛出:
ValueError -- When
section_sizeis larger than the number of columns.- 返回类型:
引用
Patel, Ketan N., Igor L. Markov, and John P. Hayes, Optimal synthesis of linear reversible circuits, Quantum Information & Computation 8.3 (2008): 282-294. arXiv:quant-ph/0302002 [quant-ph]
- janus.optimize.synthesize_cnot_depth_lnn_kms(mat)[源代码]#
Synthesize linear reversible circuit for linear nearest-neighbor architectures using Kutin, Moulton, Smithline method.
Synthesis algorithm for linear reversible circuits from [1], section 7. This algorithm synthesizes any linear reversible circuit of \(n\) qubits over a linear nearest-neighbor architecture using CX gates with depth at most \(5n\).
- 参数:
mat (ndarray) -- A boolean invertible matrix.
- 返回:
The synthesized quantum circuit.
- 抛出:
JanusError -- if
matis not invertible.- 返回类型:
引用
Kutin, S., Moulton, D. P., Smithline, L., Computation at a distance, Chicago J. Theor. Comput. Sci., vol. 2007, (2007), arXiv:quant-ph/0701194
分析 Pass#
- janus.optimize.Depth#
CircuitDepthAnalyzer的别名
- janus.optimize.Width#
CircuitWidthAnalyzer的别名
- janus.optimize.Size#
CircuitSizeAnalyzer的别名
- janus.optimize.CountOps#
GateCountAnalyzer的别名
- janus.optimize.ResourceEstimation#
CircuitResourceAnalyzer的别名