mindquantum.core.circuit.Circuit

View Source On Gitee
class mindquantum.core.circuit.Circuit(gates=None)[source]

The quantum circuit module.

A quantum circuit contains one or more quantum gates, and can be evaluated in a quantum simulator. You can build a quantum circuit very easy by add a quantum gate or another circuit.

Parameters

gates (BasicGate, list[BasicGate]) – You can initialize the quantum circuit by a single quantum gate or a list of gates. Default: None.

Examples

>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import RX, X
>>> circuit1 = Circuit()
>>> circuit1 += RX('a').on(0)
>>> circuit1 *= 2
>>> circuit1
      ┏━━━━━━━┓ ┏━━━━━━━┓
q0: ──┨ RX(a) ┠─┨ RX(a) ┠───
      ┗━━━━━━━┛ ┗━━━━━━━┛
>>> circuit2 = Circuit([X.on(0,1)])
>>> circuit3= circuit1 + circuit2
>>> assert len(circuit3) == 3
>>> circuit3.summary()
        Circuit Summary
╭──────────────────────┬───────╮
│ Info                 │ value │
├──────────────────────┼───────┤
│ Number of qubit      │ 2     │
├──────────────────────┼───────┤
│ Total number of gate │ 3     │
│ Barrier              │ 0     │
│ Noise Channel        │ 0     │
│ Measurement          │ 0     │
├──────────────────────┼───────┤
│ Parameter gate       │ 2     │
│ 1 ansatz parameter   │ a     │
╰──────────────────────┴───────╯
>>> circuit3
      ┏━━━━━━━┓ ┏━━━━━━━┓ ┏━━━┓
q0: ──┨ RX(a) ┠─┨ RX(a) ┠─┨╺╋╸┠───
      ┗━━━━━━━┛ ┗━━━━━━━┛ ┗━┳━┛

q1: ────────────────────────■─────
>>> Circuit.display_detail(False)
>>> circuit3
     ┏━━━━┓┏━━━━┓┏━━━┓
q0: ─┨ RX ┠┨ RX ┠┨╺╋╸┠───
     ┗━━━━┛┗━━━━┛┗━┳━┛

q1: ───────────────■─────
property ansatz_params_name

Get the ansatz parameter name of this circuit.

Returns

list, a list that contains the parameter name that works as ansatz.

Examples

>>> from mindquantum.core.gates import RX, RY
>>> from mindquantum.core.circuit import Circuit
>>> circuit = Circuit(RX({'a': 1, 'b': 2}).on(0)).as_encoder()
>>> circuit += Circuit(RY('c').on(0)).as_ansatz()
>>> circuit.ansatz_params_name
['c']
append(gate)[source]

Append a gate.

Parameters

gate (BasicGate) – The gate you want to append.

apply_value(pr)[source]

Convert this circuit to a non parameterized circuit with parameter you input.

Parameters

pr (Union[dict, ParameterResolver]) – parameters you want to apply into this circuit.

Returns

Circuit, a non parameterized circuit.

Examples

>>> from mindquantum.core.gates import X, RX
>>> from mindquantum.core.circuit import Circuit
>>> circuit = Circuit()
>>> circuit += X.on(0)
>>> circuit += RX({'a': 2}).on(0)
>>> circuit = circuit.apply_value({'a': 1.5})
>>> circuit
      ┏━━━┓ ┏━━━━━━━┓
q0: ──┨╺╋╸┠─┨ RX(3) ┠───
      ┗━━━┛ ┗━━━━━━━┛
as_ansatz(inplace=True)[source]

To set this circuit to ansatz or not.

Parameters

inplace (bool) – Whether to set inplace. Defaults: True.

as_encoder(inplace=True)[source]

To set this circuit to encoder.

Parameters

inplace (bool) – Whether to set inplace. Defaults: True.

barrier(show=True)[source]

Add a barrier.

Parameters

show (bool) – Whether show barrier or not. Default: True.

compress()[source]

Remove all unused qubits, and map qubits to range(n_qubits).

Examples

>>> from mindquantum.algorithm.library import qft
>>> qft([0, 2, 4])
      ┏━━━┓ ┏━━━━━━━━━┓ ┏━━━━━━━━━┓
q0: ──┨ H ┠─┨ PS(π/2) ┠─┨ PS(π/4) ┠─────────────────────────╳───
      ┗━━━┛ ┗━━━━┳━━━━┛ ┗━━━━┳━━━━┛                         ┃
                 ┃           ┃      ┏━━━┓ ┏━━━━━━━━━┓       ┃
q2: ─────────────■───────────╂──────┨ H ┠─┨ PS(π/2) ┠───────┃───
                             ┃      ┗━━━┛ ┗━━━━┳━━━━┛       ┃
                             ┃                 ┃      ┏━━━┓ ┃
q4: ─────────────────────────■─────────────────■──────┨ H ┠─╳───
                                                      ┗━━━┛
>>> qft([0, 2, 4]).compress()
      ┏━━━┓ ┏━━━━━━━━━┓ ┏━━━━━━━━━┓
q0: ──┨ H ┠─┨ PS(π/2) ┠─┨ PS(π/4) ┠─────────────────────────╳───
      ┗━━━┛ ┗━━━━┳━━━━┛ ┗━━━━┳━━━━┛                         ┃
                 ┃           ┃      ┏━━━┓ ┏━━━━━━━━━┓       ┃
q1: ─────────────■───────────╂──────┨ H ┠─┨ PS(π/2) ┠───────┃───
                             ┃      ┗━━━┛ ┗━━━━┳━━━━┛       ┃
                             ┃                 ┃      ┏━━━┓ ┃
q2: ─────────────────────────■─────────────────■──────┨ H ┠─╳───
                                                      ┗━━━┛
copy()[source]

Return a shallow copy of the circuit.

static display_detail(state: bool)[source]

Whether to display the detail of circuit.

Parameters

state (bool) – The state of whether to display the detail of circuit.

Examples

>>> from mindquantum import Circuit
>>> circ = Circuit().rx('a', 0).ry(1.2, 0)
>>> circ
      ┏━━━━━━━┓ ┏━━━━━━━━━┓
q0: ──┨ RX(a) ┠─┨ RY(6/5) ┠───
      ┗━━━━━━━┛ ┗━━━━━━━━━┛
>>> Circuit.display_detail(False)
>>> circ
     ┏━━━━┓┏━━━━┓
q0: ─┨ RX ┠┨ RY ┠───
     ┗━━━━┛┗━━━━┛
property encoder_params_name

Get the encoder parameter name of this circuit.

Returns

list, a list that contains the parameter name that works as encoder.

Examples

>>> from mindquantum.core.gates import RX, RY
>>> from mindquantum.core.circuit import Circuit
>>> circuit = Circuit(RX({'a': 1, 'b': 2}).on(0)).as_encoder()
>>> circuit += Circuit(RY('c').on(0)).as_ansatz()
>>> circuit.encoder_params_name
['a', 'b']
extend(gates)[source]

Extend a circuit.

Parameters

gates (Union[Circuit, list[BasicGate]]) – A Circuit or a list of BasicGate you want to extend.

static from_hiqasm(hiqasm_str: str)[source]

Convert a HiQASM string or a HiQASM file to MindQuantum circuit.

Parameters

hiqasm_str (str) – String format of HiQASM or a HiQASM file name.

Returns

Circuit, The MindQuantum circuit converted from HiQASM.

static from_openqasm(openqasm_str: str)[source]

Convert an OpenQASM string or an OpenQASM file to MindQuantum circuit.

Parameters

openqasm_str (str) – String format of OpenQASM or an OpenQASM file name.

Returns

Circuit, The MindQuantum circuit converted from OpenQASM.

fsim(theta, phi, obj_qubits, ctrl_qubits=None)[source]

Add a FSim gate.

Parameters
get_cpp_obj(hermitian=False)[source]

Get cpp obj of circuit.

Parameters

hermitian (bool) – Whether to get cpp object of this circuit in hermitian version. Default: False.

get_qs(backend='mqvector', pr=None, ket=False, seed=None, dtype=None)[source]

Get the final quantum state of this circuit.

Parameters
  • backend (str) – Which backend you want to use. Default: 'mqvector'.

  • pr (Union[numbers.Number, ParameterResolver, dict, numpy.ndarray]) – The parameter of this circuit, if this circuit is parameterized. Default: None.

  • ket (str) – Whether to return the quantum state in ket format. Default: False.

  • seed (int) – The random seed of simulator. Default: None

  • dtype (mindquantum.dtype) – The data type of simulator.

givens(para, obj_qubits, ctrl_qubits=None)[source]

Add a Givens rotation gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Givens gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Givens gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Givens gate. Default: None.

global_phase(para, obj_qubits, ctrl_qubits=None)[source]

Add a Global Phase gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for GlobalPhase gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of GlobalPhase gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of GlobalPhase gate. Default: None.

h(obj_qubits, ctrl_qubits=None)[source]

Add a hadamard gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of H gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of H gate. Default: None.

property has_measure_gate

To check whether this circuit has measure gate.

Returns

bool, whether this circuit has measure gate.

hermitian()[source]

Get the hermitian of this quantum circuit.

Examples

>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import RX
>>> circ = Circuit(RX({'a': 0.2}).on(0))
>>> herm_circ = circ.hermitian()
>>> print(herm_circ)
      ┏━━━━━━━━━━━━┓
q0: ──┨ RX(-1/5*a) ┠───
      ┗━━━━━━━━━━━━┛
insert(index, gates)[source]

Insert a quantum gate or quantum circuit in index.

Parameters
property is_measure_end

Check whether each qubit has a measurement as its last operation.

Check whether the circuit is end with measurement gate that there is at most one measurement gate that act on each qubit, and this measurement gate should be at end of gate serial of this qubit.

Returns

bool, whether the circuit is end with measurement.

property is_noise_circuit

To check whether this circuit has noise channel.

Returns

bool, whether this circuit has noise channel.

iswap(obj_qubits, ctrl_qubits=None)[source]

Add a ISWAP gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of ISWAP gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of ISWAP gate. Default: None.

matrix(pr=None, big_end=False, backend='mqvector', seed=None, dtype=None)[source]

Get the matrix of this circuit.

Parameters
  • pr (ParameterResolver, dict, numpy.ndarray, list, numbers.Number) – The parameter resolver for parameterized quantum circuit. Default: None.

  • big_end (bool) – The low index qubit is place in the end or not. Default: False.

  • backend (str) – The backend to do simulation. Default: ‘mqvector’.

  • seed (int) – The random to generate circuit matrix, if the circuit has noise channel.

  • dtype (mindquantum.dtype) – data type of simulator. Default: ‘None’.

Returns

numpy.ndarray, two dimensional complex matrix of this circuit.

Examples

>>> from mindquantum.core.circuit import Circuit
>>> circuit = Circuit().rx('a',0).h(0)
>>> circuit.matrix({'a': 1.0})
array([[ 0.62054458-0.33900505j,  0.62054458-0.33900505j],
       [ 0.62054458+0.33900505j, -0.62054458-0.33900505j]])
measure(key, obj_qubit=None, reset_to=None)[source]

Add a measure gate.

Parameters
  • key (Union[int, str]) – If obj_qubit is None, then key should be a int and means which qubit to measure, otherwise, key should be a str and means the name of this measure gate.

  • obj_qubit (int) – Which qubit to measure. Default: None.

  • reset_to (Union[int, None]) – Reset the qubit to 0 state or 1 state. If None, do not reset. Default: None.

measure_all(suffix=None, up_to: int = - 1)[source]

Measure all qubits.

Parameters
  • suffix (str) – The suffix string you want to add to the name of measure gate.

  • up_to (int) – The maximum qubit you want to measure. If this value is less than the qubit number of this quantum circuit, the circuit qubit number will be used. Default: -1.

property n_qubits

Get the total number of qubits used.

no_grad()[source]

Set all parameterized gate in this quantum circuit not require grad.

parameter_resolver()[source]

Get the parameter resolver of the whole circuit.

Note

This parameter resolver only tells you what are the parameters of this quantum circuit, and which part of parameters need grad, since the same parameter can be in different gate, and the coefficient can be different. The detail parameter resolver that shows the coefficient is in each gate of the circuit.

Returns

ParameterResolver, the parameter resolver of the whole circuit.

property parameterized

To check whether this circuit is a parameterized quantum circuit.

Returns

bool, whether this circuit is a parameterized quantum circuit.

property params_name

Get the parameter name of this circuit.

Returns

list, a list that contains the parameter name.

Examples

>>> from mindquantum.core.gates import RX
>>> from mindquantum.core.circuit import Circuit
>>> circuit = Circuit(RX({'a': 1, 'b': 2}).on(0))
>>> circuit.params_name
['a', 'b']
phase_shift(para, obj_qubits, ctrl_qubits=None)[source]

Add a Phase Shift gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for PhaseShift gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of PhaseShift gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of PhaseShift gate. Default: None.

remove_barrier()[source]

Remove all barrier gates.

remove_measure()[source]

Remove all measure gate.

remove_measure_on_qubits(qubits)[source]

Remove all measure gate on some certain qubits.

Parameters

qubit (Union[int, list[int]]) – The qubits you want to remove measure.

Examples

>>> from mindquantum.core.circuit import UN
>>> from mindquantum.core.gates import H, Measure
>>> circ = UN(H, 3).x(0, 1).x(1, 2).measure_all()
>>> circ += H.on(0)
>>> circ += Measure('q0_1').on(0)
>>> circ.remove_measure_on_qubits(0)
      ┏━━━┓ ┏━━━┓ ┏━━━┓
q0: ──┨ H ┠─┨╺╋╸┠─┨ H ┠────────────
      ┗━━━┛ ┗━┳━┛ ┗━━━┛
      ┏━━━┓   ┃   ┏━━━┓ ┍━━━━━━┑
q1: ──┨ H ┠───■───┨╺╋╸┠─┤ M q1 ├───
      ┗━━━┛       ┗━┳━┛ ┕━━━━━━┙
      ┏━━━┓         ┃   ┍━━━━━━┑
q2: ──┨ H ┠─────────■───┤ M q2 ├───
      ┗━━━┛             ┕━━━━━━┙
remove_noise()[source]

Remove all noise gate.

requires_grad()[source]

Set all parameterized gates in this quantum circuit require grad.

reverse_qubits()[source]

Flip the circuit to big endian.

Examples

>>> from mindquantum.core.circuit import Circuit
>>> circ = Circuit().h(0).x(2, 0).y(3).x(3, 2)
>>> circ
      ┏━━━┓
q0: ──┨ H ┠───■───────────
      ┗━━━┛   ┃
            ┏━┻━┓
q2: ────────┨╺╋╸┠───■─────
            ┗━━━┛   ┃
      ┏━━━┓       ┏━┻━┓
q3: ──┨ Y ┠───────┨╺╋╸┠───
      ┗━━━┛       ┗━━━┛
>>> circ.reverse_qubits()
      ┏━━━┓       ┏━━━┓
q0: ──┨ Y ┠───────┨╺╋╸┠───
      ┗━━━┛       ┗━┳━┛
            ┏━━━┓   ┃
q1: ────────┨╺╋╸┠───■─────
            ┗━┳━┛
      ┏━━━┓   ┃
q3: ──┨ H ┠───■───────────
      ┗━━━┛
rx(para, obj_qubits, ctrl_qubits=None)[source]

Add a RX gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for RX gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of RX gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of RX gate. Default: None.

rxx(para, obj_qubits, ctrl_qubits=None)[source]

Add a Rxx gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Rxx gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Rxx gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Rxx gate. Default: None.

rxy(para, obj_qubits, ctrl_qubits=None)[source]

Add a Rxy gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Rxy gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Rxy gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Rxy gate. Default: None.

rxz(para, obj_qubits, ctrl_qubits=None)[source]

Add a Rxz gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Rxz gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Rxz gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Rxz gate. Default: None.

ry(para, obj_qubits, ctrl_qubits=None)[source]

Add a RY gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for RY gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of RY gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of RY gate. Default: None.

ryy(para, obj_qubits, ctrl_qubits=None)[source]

Add a Ryy gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Ryy gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Ryy gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Ryy gate. Default: None.

ryz(para, obj_qubits, ctrl_qubits=None)[source]

Add a Ryz gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Ryz gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Ryz gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Ryz gate. Default: None.

rz(para, obj_qubits, ctrl_qubits=None)[source]

Add a RZ gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for RZ gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of RZ gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of RZ gate. Default: None.

rzz(para, obj_qubits, ctrl_qubits=None)[source]

Add a Rzz gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for Rzz gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of Rzz gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Rzz gate. Default: None.

s(obj_qubits, ctrl_qubits=None, hermitian=False)[source]

Add a S gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of S gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of S gate. Default: None.

  • hermitian (bool) – Whether use the hermitian conjugated version. Default: False.

summary(show=True)[source]

Print a summary of the current circuit.

Print the information about current circuit, including block number, gate number, non-parameterized gate number, parameterized gate number and the total parameters.

Parameters

show (bool) – whether to show the information. Default: True.

Examples

>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import RX, H
>>> circuit = Circuit([RX('a').on(1), H.on(1), RX('b').on(0)])
>>> circuit.summary()
        Circuit Summary
╭──────────────────────┬───────╮
│ Info                 │ value │
├──────────────────────┼───────┤
│ Number of qubit      │ 2     │
├──────────────────────┼───────┤
│ Total number of gate │ 3     │
│ Barrier              │ 0     │
│ Noise Channel        │ 0     │
│ Measurement          │ 0     │
├──────────────────────┼───────┤
│ Parameter gate       │ 2     │
│ 2 ansatz parameters  │ a, b  │
╰──────────────────────┴───────╯
svg(style=None, width=None, scale=None)[source]

Display current quantum circuit into SVG picture in jupyter notebook.

Parameters
  • style (dict, str) – the style to set svg circuit. Currently, we support 'official', 'light' and 'dark'. Default: None.

  • width (int, float) – the max width of circuit. Default: None.

  • scale (Union[float, None]) – Scale factor for scaling svg. If None, do not scale. Default: None.

swap(obj_qubits, ctrl_qubits=None)[source]

Add a SWAP gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of SWAP gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of SWAP gate. Default: None.

swap_alpha(para, obj_qubits, ctrl_qubits=None)[source]

Add a SWAPalpha gate.

Parameters
  • para (Union[dict, ParameterResolver]) – The parameter for SWAPalpha gate.

  • obj_qubits (Union[int, list[int]]) – The object qubits of SWAPalpha gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of SWAPalpha gate. Default: None.

sx(obj_qubits, ctrl_qubits=None, hermitian=False)[source]

Add a SX gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of SX gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of SX gate. Default: None.

  • hermitian (bool) – Whether use the hermitian conjugated version. Default: False.

t(obj_qubits, ctrl_qubits=None, hermitian=False)[source]

Add a T gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of T gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of T gate. Default: None.

  • hermitian (bool) – Whether use the hermitian conjugated version. Default: False.

to_hiqasm(file_name: Optional[str] = None, version: str = '0.1')[source]

Convert a MindQuantum circuit to HiQASM format string or file.

Parameters
  • file_name (str) – File name if you want to save HiQASM. If it is None, we will return the string. Otherwise, we will save to given file. Default: None.

  • version (str) – The HiQASM version you want to use. Default: '0.1'.

to_openqasm(file_name: Optional[str] = None, version: str = '2.0')[source]

Convert a MindQuantum circuit to OpenQASM format string or file.

Parameters
  • file_name (str) – File name if you want to save OpenQASM. If it is None, we will return the string. Otherwise, we will save to given file. Default: None.

  • version (str) – The OpenQASM version you want to use. Default: '2.0'.

u3(theta, phi, lamda, obj_qubits, ctrl_qubits=None)[source]

Add a U3 gate.

Parameters
un(gate, maps_obj, maps_ctrl=None)[source]

Map a quantum gate to different objective qubits and control qubits.

Please refer to UN.

Parameters
  • gate (BasicGate) – The BasicGate you want to map.

  • maps_obj (Union[int, list[int]]) – object qubits.

  • maps_ctrl (Union[int, list[int]]) – control qubits. Default: None.

with_noise(noise_gate=mq_gates.AmplitudeDampingChannel(0.001), also_ctrl=False)[source]

Apply noises on each gate.

Parameters
  • noise_gate (NoiseGate) – The NoiseGate you want to apply. Default: AmplitudeDampingChannel(0.001).

  • also_ctrl (bool) – Whether add NoiseGate on control qubits. Default: False.

x(obj_qubits, ctrl_qubits=None)[source]

Add a X gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of X gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of X gate. Default: None.

y(obj_qubits, ctrl_qubits=None)[source]

Add a Y gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of Y gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Y gate. Default: None.

z(obj_qubits, ctrl_qubits=None)[source]

Add a Z gate.

Parameters
  • obj_qubits (Union[int, list[int]]) – The object qubits of Z gate.

  • ctrl_qubits (Union[int, list[int]]) – the control qubits of Z gate. Default: None.