wy_qcos.common.cmss package
Submodules
wy_qcos.common.cmss.barrier module
Circuit-level Barrier instruction.
- class wy_qcos.common.cmss.barrier.Barrier(num_qubits=0, name='barrier')
-
For PulseIR: Barrier instruction.
It prevents instruction reordering across the barrier.
- property duration
Barrier has zero duration.
- property params
Return instruction params.
wy_qcos.common.cmss.base_operation module
- class wy_qcos.common.cmss.base_operation.OperationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
基类:
Enum操作类型.
- SINGLE_QUBIT_OPERATION = 1
- DOUBLE_QUBIT_OPERATION = 2
- TRIPLE_QUBIT_OPERATION = 3
- FOUR_QUBIT_OPERATION = 4
- FIVE_QUBIT_OPERATION = 5
- MEASURE = 0
- SYNC = -1
- MOVE = -2
- RESET = -3
- class wy_qcos.common.cmss.base_operation.BaseOperation(name, targets=None, arg_value=None, operation_type=OperationType.SINGLE_QUBIT_OPERATION.value)
基类:
object中间表示类基类.
- to_openqasm(qubit_prefix='q')
Convert the current operation into an OpenQASM statement.
示例
H -> h q[0]; RX(pi/2) -> rx(pi/2) q[1]; CX(0, 1) -> cx q[0], q[1];
- 参数:
qubit_prefix (str) -- The prefix used for qubit identifiers in the output QASM code (e.g., "q" results in q[0], q[1], ...).
- 返回:
A formatted OpenQASM instruction string.
- 返回类型:
str
- 抛出:
ValueError -- If the operation contains no target qubits.
wy_qcos.common.cmss.circuit_instruction module
- class wy_qcos.common.cmss.circuit_instruction.CircuitInstruction(operation, qubits, clbits=None)
基类:
object电路中的单条指令,对应 QuantumCircuit.instructions 中的元素.
对应 qiskit QuantumCircuit.data 字段。
实例包含三个核心字段:
operation表示门操作对象,需具备.name、.params、.duration属性;qubits为该指令 作用的量子比特索引列表;clbits为该指令关联的经典比特索引 列表,主要用于测量门。- 参数:
qubits (list)
clbits (list | None)
- operation
- qubits
- clbits
wy_qcos.common.cmss.delay module
Circuit-level Delay instruction.
- class wy_qcos.common.cmss.delay.Delay(duration, unit='dt', name='delay')
-
Delay instruction that idles a qubit for a specified duration.
- property duration
Return the duration of the delay.
- property unit
Return the time unit of the duration.
- property params
Return instruction params.
wy_qcos.common.cmss.duration module
Duration conversion utilities for quantum circuits.
- wy_qcos.common.cmss.duration.convert_durations_to_dt(circuit, dt_in_sec=None, inplace=False)
Convert instruction durations from SI units to dt units.
Converts the duration of each instruction in the circuit from its current time unit to the backend's dt (sample time) unit.
- 参数:
circuit -- The QuantumCircuit to convert.
dt_in_sec -- The duration of one dt in seconds.
inplace -- If True, modify the circuit in place. Otherwise return a copy.
- 返回:
The circuit with durations converted to dt units.
wy_qcos.common.cmss.gate_operation module
- class wy_qcos.common.cmss.gate_operation.GateOperation(name, targets=None, arg_value=None, operation_type=OperationType.SINGLE_QUBIT_OPERATION.value, hermitian=True)
-
中间表示类.
- validate_params()
Validate gate's params.
Operation type already indicated the number of qubits that gate needed.
- decompose()
门对应的分解规则,如无指定规则,则调用默认的分解方法.
分解规则以字典的形式指定,配置在GlobalSetting的decomposition_rule中, 其每个item的形式为:
gate_name: #门名称 { "param": [str] #形式化的门参数,数量与门实际所需一致, 如无参数,该项可不填 "gates": [based_gates] #指定的分解形式,以based_gates列表表示 }其中based_gates为一个三元组(name, targets, exps), name表示门名称,targets为作用比特下标列表(从0开始), exps为参数对应的表达式,以字符串的形式表示, 表达式中的操作数可为param中定义的形式化参数以及常量,常量中π可用pi表示
示例:
decomposition_rule = { "u3": { "params": ["a", "b", "c"], "gates": [ ("rz", [0], ["c"]), ("rx", [0], ["pi/2"]), ("rz", [0], ["b+pi"]), ("rx", [0], ["pi/2"]), ("rz", [0], ["a+pi"]), ], }, "h": {"gates": [("rx", [0], ["pi/2"])]}, }
- decompose_to_1q2q()
- default_decompose()
默认的分解方法.
- static with_gate_array(base_array, dtype=None)
Return the complex matrix for the gate.
- static with_controlled_gate_array(base_array, ctrl_state, num_ctrl_qubits, cached_states=None, dtype=None)
Return the complex matrix.
- Description:
If cached_states is not given, then all possible control states are precomputed. If it is given, it should be an iterable of integers, and only these control states will be cached.
- to_matrix()
Return a Numpy.ndarray for the gate unitary matrix.
- 返回:
a matrix array of the gate.
- 返回类型:
np.ndarray
- 抛出:
ValueError -- If a Gate subclass does not implement this method
an exception will be raised when this base class method is called. --
- class wy_qcos.common.cmss.gate_operation.H(targets=None, arg_value=None)
-
Hadamard门类, 将基态变为叠加态的量子逻辑门.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.X(targets=None, arg_value=None)
-
Pauli-X门类, 将量子态绕Bloch球X轴旋转角度π进行翻转.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.Y(targets=None, arg_value=None)
-
Pauli-Y门类, 将量子态绕Bloch球Y轴旋转角度π进行翻转.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.Z(targets=None, arg_value=None)
-
Pauli-Z门类, 将量子态绕Bloch球Z轴旋转角度π进行翻转.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.S(targets=None, arg_value=None)
-
相位门类.
对量子态的`|1⟩`分量施加一个相位变换,使得`|1⟩`变为`i∣1⟩`,而`|0⟩`分量保持不变 S门在Bloch球中对应于绕Z轴旋转π/2的操作
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.SDG(targets=None, arg_value=None)
-
反相位门类.
是S门的共轭转置,对量子态的`|1⟩`分量施加一个相位变换,使得`|1⟩`变为`-i∣1⟩`,而`|0⟩`分量保持不变。 SDG门在Bloch球中对应于绕Z轴旋转-π/2的操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.T(targets=None, arg_value=None)
-
T门.
用于实现较小的相位旋转。T门的作用是对量子态的`|1⟩`分量施加一个相位变换, 使得`|1⟩`变为`e^iπ/4∣1⟩`,而`|0⟩`分量保持不变。 T门在Bloch球中对应于绕Z轴旋转π/4的操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.P(targets=None, arg_value=None)
-
P门.
P门是单量子比特的相位旋转门,用于在Bloch球上实现绕Z轴旋转λ角度的操作。 它对量子态的`|1⟩`分量施加一个相位因子`e^{iλ}`,而`|0⟩`分量保持不变。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.R(targets=None, arg_value=None)
-
R门(XY平面旋转门).
R(θ, φ) = exp[-i θ/2 (cosφ X + sinφ Y)] 表示绕 Bloch 球 XY 平面中、与 X 轴夹角为 φ 的轴旋转 θ。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.TDG(targets=None, arg_value=None)
-
TDG门.
T门的共轭转置, 作用是对量子态的`|1⟩`分量施加一个相位变换, 使得`|1⟩`变为`e^-iπ/4∣1⟩`,而`|0⟩`分量保持不变。 T门在Bloch球中对应于绕Z轴旋转-π/4的操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.RX(targets=None, arg_value=None)
-
绕X轴旋转门.
用来改变量子比特在X轴方向上的状态 RX门在Bloch球中对应于绕X轴旋转一个指定的角度θ
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.RY(targets=None, arg_value=None)
-
绕Y轴旋转门.
用来改变量子比特在Y轴方向上的状态 RY门在Bloch球中对应于绕Y轴旋转一个指定的角度θ
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.RZ(targets=None, arg_value=None)
-
绕Z轴旋转门.
用来改变量子比特在Z轴方向上的状态 RZ门在Bloch球中对应于绕Z轴旋转一个指定的角度θ
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.SX(targets=None, arg_value=None)
-
SX门(也称为 √X 门 或 square-root of NOT 门).
Pauli-X 门(即量子NOT门)的一半旋转, 它在Bloch球上对应于 绕 X 轴旋转 π/2 的操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.SXDG(targets=None, arg_value=None)
-
SXDG 门(也写作 √X† 或 SX⁻¹).
SXDG 门是 SX 门的共轭转置(逆操作),也称为 inverse square-root of X gate. 它在 Bloch 球上对应于 绕 X 轴旋转 -π/2 的操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CZ(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控Z门或Controlled-Z门.
在控制量子比特为`|1⟩`时,对目标量子比特应用一个Z门(Pauli-Z门) 将目标量子比特的相位翻转。 CZ门在Bloch球中对应于绕Z轴旋转π角度, 仅当控制量子比特为`|1⟩`时。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控非门或Controlled-X门.
当控制位处于`|1⟩`状态时,将目标位翻转 (即`|0⟩`变为`|1⟩`,|1⟩`变为`|0⟩)。如果控制位处于`|0⟩`状态,则目标位保持不变。 对应于经典比特的XOR(异或)操作
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CY(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控Y门或Controlled-Y门.
在控制量子比特为`|1⟩`时, 对目标量子比特应用一个Y门(Pauli-Y门)将目标量子比特绕Y轴旋转π角度。 CY门在Bloch球中对应于绕Y轴旋转π角度, 仅当控制量子比特为`|1⟩`时。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.SWAP(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
交换门,交换两个量子比特。.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.ISWAP(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
iSWAP门(双量子比特交换门).
iSWAP 门交换
|01>与|10>, 并在交换过程中引入一个 i 相位。
- class wy_qcos.common.cmss.gate_operation.CH(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控Hadamard门,当控制量子比特为`|1⟩`时,对目标量子比特应用Hadamard门(H门).
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CS(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CS门(Controlled-S 门).
CS 是一种双量子比特受控相位门, 当控制量子比特为 1 时, 在目标量子比特上施加 S 门。
- class wy_qcos.common.cmss.gate_operation.CSDG(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CSDG门(Controlled-S† 门).
CSDG 是一种双量子比特受控相位门, 当控制量子比特为 1 时, 在目标量子比特上施加 S† 门。
- class wy_qcos.common.cmss.gate_operation.CRX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控单量子比特旋转门,当控制量子比特为`|1⟩`时,对目标量子比特沿X轴旋转θ角度.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CRY(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控的单量子比特旋转门,当控制量子比特为`|1⟩`时,对目标量子比特沿Y轴旋转θ角度.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CRZ(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控的单量子比特旋转门,当控制量子比特为`|1⟩`时,对目标量子比特沿Z轴旋转θ角度.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CU1(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
受控U1门.
CU1 门是一个 受控相位旋转门,是单量子比特 U1(λ) 门的受控版本。 当控制量子比特为`|1⟩`时,目标量子比特执行一个绕 Z 轴旋转角度 λ 的 U1 门; 当控制量子比特为`|0⟩`时,不进行任何操作。.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CP(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CP门(Controlled-Phase 门).
CP 门(Controlled-Phase Gate)是一个 受控相位旋转门, 对目标量子比特施加受控的 Z 轴旋转操作。 当控制量子比特为`|1⟩`时,目标量子比特执行绕 Z 轴旋转角度 λ 的相位门 P(λ); 当控制量子比特为`|0⟩`时,目标量子比特保持不变。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CU3(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CU3门(受控U3门).
CU3 门是一种两量子比特门,用于在控制比特为`|1⟩`时, 对目标比特施加 U3(θ, φ, λ) 操作;当控制比特为`|0⟩`时, 目标比特保持不变。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CSX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CSX门(受控SX门).
CSX 门是一种两量子比特受控门, 当控制比特处于`|1⟩`状态时,对目标比特施加 SX 门(√X 门); 当控制比特为`|0⟩`时,目标比特保持不变。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.CU(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
CU门(受控U门).
CU 门是一种通用的两量子比特受控门, 当控制比特处于`|1⟩`状态时,对目标比特施加一个任意的单量子比特酉变换 U; 当控制比特为`|0⟩`时,目标比特保持不变。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.ECR(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
ECR门(Echoed Cross Resonance 门).
ECR 是一种双量子比特纠缠门, 在超导量子体系中作为原生门使用, 与 CNOT 门局部等价。
- class wy_qcos.common.cmss.gate_operation.DCX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
DCX门(Double-CNOT 门).
- DCX 门由两个方向相反的 CNOT 组成:
CX(a→b) 后接 CX(b→a)
- class wy_qcos.common.cmss.gate_operation.RXX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
RXX门(双量子比特 X-X 旋转门).
RXX 门是一种双量子比特旋转门, 用于在两个量子比特的 X 方向上进行相互耦合的旋转操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.RYY(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
RYY门(双量子比特 Y-Y 旋转门).
RYY 门是一种双量子比特旋转门, 用于在两个量子比特的 Y 方向上进行相互耦合的旋转操作。
- class wy_qcos.common.cmss.gate_operation.RZZ(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
RZZ门(双量子比特 Z-Z 旋转门).
RZZ 门是一种双量子比特旋转门, 用于在两个量子比特的 Z 方向上进行相互耦合的旋转操作。
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.RZX(targets=None, arg_value=None, gate_type=OperationType.DOUBLE_QUBIT_OPERATION.value)
-
RZX门(双量子比特 Z-X 旋转门).
RZX 门是一种双量子比特旋转门, 用于在第一个量子比特的 Z 方向与第二个量子比特的 X 方向之间 进行相互耦合的旋转操作。
- class wy_qcos.common.cmss.gate_operation.CCX(targets=None, arg_value=None, gate_type=OperationType.TRIPLE_QUBIT_OPERATION.value)
-
Toffoli门,如果两个控制量子比特都处于`|1⟩`状态,则对目标量子比特应用X门(Pauli-X门).
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.CSWAP(targets=None, arg_value=None, gate_type=OperationType.TRIPLE_QUBIT_OPERATION.value)
-
CSWAP 门(也称 Fredkin 门)是一种 三比特受控交换门,.
它根据第一个比特(控制比特)的状态,决定是否交换后两个比特(目标比特)的状态。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.RCCX(targets=None, arg_value=None, gate_type=OperationType.TRIPLE_QUBIT_OPERATION.value)
-
RCCX门(相对相位受控受控X门 / Relative-Phase Toffoli Gate).
RCCX 门是一种三量子比特逻辑门, 是 Toffoli 门(CCX)的一个相对相位版本, 即在实现相同控制逻辑的同时,引入了相位差, 从而在物理实现上更简洁、资源消耗更低。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.RC3X(targets=None, arg_value=None, gate_type=OperationType.FOUR_QUBIT_OPERATION.value)
-
RC3X门(Relative-phase Toffoli 门).
RC3X 门是 Toffoli(CCX)门的相对相位版本, 当两个控制量子比特均为`|1⟩`时,对目标量子比特施加 X 操作, 但在部分叠加态上引入相对相位差。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.C3X(targets=None, arg_value=None, gate_type=OperationType.FOUR_QUBIT_OPERATION.value)
-
C3X门(三控制X门 / 三重受控非门).
C3X 门是多控制量子门的一种,具有三个控制量子比特和一个目标量子比特。 当且仅当三个控制量子比特均为`|1⟩`时,C3X 门对目标量子比特施加 X(非)操作; 否则,目标量子比特保持不变。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.C3SQRTX(targets=None, arg_value=None, gate_type=OperationType.FOUR_QUBIT_OPERATION.value)
-
C3√X门(三控制√X门 / 三重受控平方根X门).
C3√X门是具有三个控制量子比特的受控平方根X门(Controlled-Square-Root-of-X) 当且仅当三个控制量子比特均处于 |1⟩ 状态时, 它对目标量子比特施加 √X 操作(即 X 门的平方根); 否则,目标量子比特保持不变。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.C4X(targets=None, arg_value=None, gate_type=OperationType.FIVE_QUBIT_OPERATION.value)
-
C4X门(四控制X门 / 四重受控非门).
C4X 门是具有四个控制量子比特的多控制X门(Multi-Controlled X Gate), 也称为四重受控非门(Four-Controlled-NOT Gate)。
当且仅当四个控制量子比特全部处于 |1⟩ 状态时, C4X 门对目标量子比特施加 X 操作(即翻转其量子态:|0⟩ ↔ |1⟩); 否则,目标量子比特保持不变。
- default_decompose()
- decompose_to_1q2q()
- class wy_qcos.common.cmss.gate_operation.U1(targets=None, arg_value=None)
-
U1门,对应于绕Z轴的相位旋转,参数为λ.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.U2(targets=None, arg_value=None)
-
U2门,对应于 π/2 角度的极坐标旋转,参数为ϕ和λ.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.U3(targets=None, arg_value=None)
-
U3门,对应于任意角度的极坐标旋转,参数为θ、ϕ和λ.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.U(targets=None, arg_value=None)
-
U门,对应于任意角度的极坐标旋转,参数为θ、ϕ和λ.
- default_decompose()
- class wy_qcos.common.cmss.gate_operation.ControlGate(base_gate, num_controls=1, ctrl_state=None, targets=None)
-
Generic control gate.
- default_decompose()
- wy_qcos.common.cmss.gate_operation.create_gate(name, targets=[], arg_value=[], allow_undefined=False)
Create gate object.
- 参数:
name (str) -- name of gate
targets (list) -- targets to bit list
arg_value (list) -- arg list
allow_undefined (bool) -- allow undefined
- 返回:
gate instance
wy_qcos.common.cmss.measure module
- class wy_qcos.common.cmss.measure.Measure(targets=None, arg_value=None, operation_type=OperationType.MEASURE.value)
-
测量操作,用于测量量子比特的状态,将其从量子态转换为经典态.
wy_qcos.common.cmss.move module
- class wy_qcos.common.cmss.move.Move(targets=None, arg_value=None, operation_type=OperationType.MOVE.value)
-
移动操作, 用于执行量子比特在存储区和操纵区之间的移动操作.
wy_qcos.common.cmss.operation module
- class wy_qcos.common.cmss.operation.Operation(name, params=None, duration=0)
基类:
object面向 pulse scheduler 的轻量门描述符.
与 cmss 内部的重型
GateOperation不同,此类仅持有 pulse scheduler(lowering.py / sequence.py)所需的最小接口:name、params、duration。其中
name表示门名称,如"rx"、"sx"、"measure";params保存门参数列表,例如旋转角[math.pi / 2],无参数时为[];duration表示门脉冲时长,单位为 dt,虚拟门如rz的时长为0。- 参数:
name (str)
params (list | None)
duration (int)
- name
- params
- duration
wy_qcos.common.cmss.qasm_converter module
- class wy_qcos.common.cmss.qasm_converter.QasmConverter(circuit)
基类:
objectConvert a list of Operations into OpenQASM 2.0 or 3.0 code.
- 参数:
circuit (QuantumCircuit)
- to_qasm2()
Generate OpenQASM 2.0 source code.
- 返回类型:
str
- to_qasm3()
Generate OpenQASM 3.0 source code.
- 返回类型:
str
- save(path, version='2.0')
Save the generated QASM code to a .qasm file.
- 参数:
path (str | Path)
version (str)
wy_qcos.common.cmss.quantum_circuit module
- class wy_qcos.common.cmss.quantum_circuit.QuantumCircuit(num_qubits=0, num_clbits=0, global_phase=0)
基类:
object- 参数:
num_qubits (int)
num_clbits (int)
global_phase (float)
- classmethod from_ir(ir, num_qubits=0)
Create a quantum circuit from a list of gate operations.
- 参数:
ir (list[BaseOperation]) -- gate operations of ir.
num_qubits (int) -- number of qubits in the circuit.
- 返回:
a quantum circuit corresponding to the ir.
- 返回类型:
- append(operation)
Append a gate operation to the quantum circuit.
- 参数:
operation (BaseOperation) -- The gate operation to append.
- append_operations(operations)
Append multiple gate operations to the quantum circuit.
- 参数:
operations (list[BaseOperation]) -- The list of gate
append. (operations to)
- get_operations()
- property num_qubits
- property num_clbits
- property global_phase
- set_global_phase(phase)
Set the global phase.
- 参数:
phase (float)
- set_num_qubits(num_qubits)
- 参数:
num_qubits (int)
- set_num_clbits(num_clbits)
- 参数:
num_clbits (int)
- depth()
Calculate the depth of the quantum circuit.
- 返回:
depth of the quantum circuit
- 返回类型:
depth (int)
- width()
Calculate the width of the quantum circuit.
- 返回:
number of bits in the quantum circuit
- 返回类型:
width (int)
- size()
Returns total number of operations in circuit.
- 返回:
Total number of gate operations.
- 返回类型:
int
- add_register(*regs)
Add registers to the quantum circuit.
- 参数:
*regs (Register|QuantumRegister|ClassicalRegister) -- registers
added (to be)
- measure(qubits)
Measure quantum bits.
- 参数:
qubits (list) -- qubit(s) to measure.
- measure_all()
Adds measurement to all qubits.
By default, adds new classical bits in a
ClassicalRegisterto store these measurements.
wy_qcos.common.cmss.register module
- class wy_qcos.common.cmss.register.Register(size=None, name=None, init_pos=0, bits=None)
基类:
objectCreate a quantum register.
- 参数:
size (int | None)
name (str | None)
init_pos (int)
bits (list[int] | None)
- instances_counter = count(0)
- prefix = 'reg'
- property name
Get the register name.
- property size
Get the register size.
- index(bit)
Find the index of the provided bit within this register.
- class wy_qcos.common.cmss.register.QuantumRegister(size=None, name=None, init_pos=0, bits=None)
基类:
RegisterCreate a quantum register.
- 参数:
size (int | None)
name (str | None)
init_pos (int)
bits (list[int] | None)
- instances_counter = count(0)
- prefix = 'q'
- class wy_qcos.common.cmss.register.ClassicalRegister(size=None, name=None, init_pos=0, bits=None)
基类:
RegisterCreate a classical register.
- 参数:
size (int | None)
name (str | None)
init_pos (int)
bits (list[int] | None)
- instances_counter = count(0)
- prefix = 'c'
wy_qcos.common.cmss.reset module
- class wy_qcos.common.cmss.reset.Reset(targets=None, arg_value=None, operation_type=OperationType.RESET.value)
-
重置操作,用于将量子比特重置到|0> 态.
wy_qcos.common.cmss.sync module
- class wy_qcos.common.cmss.sync.Sync(targets=None, arg_value=None, operation_type=OperationType.SYNC.value)
-
同步操作,用于在量子电路中同步操作,确保某些操作在特定的时间点同时发生.