Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b775d2c
Removed unused variables and minor corrections
mudit06mah Jan 19, 2026
c312fbb
Merge pull request #311 from mudit06mah/zzcrosstalk
BoxiLi Jan 20, 2026
a8f1e61
Depreciate N in QubitCircuit and use num_qubits instead
niranjannagumalli Jan 11, 2026
a28fd3c
Replace qc.N with qc.num_qubits in the codebase
niranjannagumalli Jan 28, 2026
a0f4e0e
Depreciated N in gatecompiler
niranjannagumalli Jan 28, 2026
fccb49b
Replaced N with num_qubits in texrenderer
niranjannagumalli Jan 28, 2026
7b5a012
Replace N with num_qubits in convertor.py and fix linting
niranjannagumalli Jan 28, 2026
14dd774
Replaced get_compact_qobj with get_qobj
Mayank447 Feb 9, 2026
8ac2358
Added num_params property and validate_params abstract method for Par…
Mayank447 Feb 9, 2026
a678aeb
Made num_qubits, num_ctrl_qubits, num_param a class attribute instead…
Mayank447 Feb 9, 2026
d23204a
Added GateReadOnlyMeta class for certain gate attributes
Mayank447 Feb 9, 2026
fdc56ed
Made arg_value an iterable in Parametric Gate
Mayank447 Feb 9, 2026
95de51d
Skip __init__subclass checks for abstract classes
Mayank447 Feb 9, 2026
be0b0cb
Replace num_qubits argument with positional argument in QubitCircuit …
niranjannagumalli Feb 9, 2026
7cf6a2e
Update qip-qiskit.rst to use num_qubits argument in CircularSpinChain…
niranjannagumalli Feb 9, 2026
c3bbef7
Removed usage of gates.py in codebase and deprecated them
Mayank447 Feb 9, 2026
4fe70fe
Added more checks to _init_subclass__ in Gate
Mayank447 Feb 9, 2026
4c5ac19
Shifted num_ctrl_qubits from Gate class to ControlledGate class
Mayank447 Feb 9, 2026
8a88790
Made num_qubits, num_params property with abstract method
Mayank447 Feb 9, 2026
90d650b
Renamed ParametrizedGat to ParametricGate
Mayank447 Feb 9, 2026
663752e
Added an abstract method target_class to ControlledGate
Mayank447 Feb 9, 2026
4b391d7
Removed target_class from ControlledParam Gate
Mayank447 Feb 9, 2026
435abc1
Added typing.py
Mayank447 Feb 9, 2026
a78f982
Added additional checks for ControlledGate
Mayank447 Feb 9, 2026
5df2b4a
Made validate_params method abstract for ParametricGate
Mayank447 Feb 9, 2026
cbcee00
Replaced string gate input to add_gate to gate class in codebase
Mayank447 Feb 9, 2026
a837d89
Removed __all__ from individual files in algorithms
Mayank447 Feb 9, 2026
de63be8
Added is_controlled_gate and is_parametric_gate methods to the gate c…
Mayank447 Feb 9, 2026
46c02cd
Made the qubit conversion logic for qiskit circuit same as qutip (no …
Mayank447 Feb 9, 2026
aa9a70e
Split std_gates into single_qubit gates
Mayank447 Feb 10, 2026
74f6cee
Split two qubit gates from std_gates.py
Mayank447 Feb 10, 2026
7670b08
Remove unused code from the split
Mayank447 Feb 10, 2026
151b98c
Finalize gate split to std
Mayank447 Feb 10, 2026
0d473e5
Remove unused imports
Mayank447 Feb 10, 2026
2eb5949
Added self-inverse property to Gate class
Mayank447 Feb 10, 2026
fcf1d8b
Added is_clifford propoerty to the Gate class
Mayank447 Feb 10, 2026
191db06
Added deprecation warning for gate input as string in add_gate method
Mayank447 Feb 10, 2026
f03e48b
Added deprecation warning for arg_value, arg_label and control_value …
Mayank447 Feb 10, 2026
7d8fd89
Replaced * imports with std.
Mayank447 Feb 10, 2026
73a679b
Added docstring for Gate class, ControlledGate class
Mayank447 Feb 10, 2026
875c41d
Added docstring for ParametricGate class
Mayank447 Feb 10, 2026
e0c904a
Renamed ControlledParamGate to ControlledParametricGate and added the…
Mayank447 Feb 10, 2026
8c76e79
Deprecated SNOT, CSIGN
Mayank447 Feb 11, 2026
9e49b0f
Deprecated CNOT gate and replaced with CX
Mayank447 Feb 11, 2026
ad6a19f
Removed ControlledParametricGate class, moved that functionality in C…
Mayank447 Feb 11, 2026
2c6630f
Merge pull request #317 Replace n with num qubits
BoxiLi Feb 12, 2026
1feae75
Replaced SQRTNOT with SQRTX
Mayank447 Feb 13, 2026
8f6bd83
Merge branch 'master' into refactor-gate-class
Mayank447 Feb 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions doc/source/apidoc/qutip_qip.operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,6 @@ qutip\_qip.operations

.. autosummary::

berkeley
cnot
controlled_gate
cphase
cs_gate
csign
ct_gate
cy_gate
cz_gate
expand_operator
fredkin
gate_sequence_product
globalphase
hadamard_transform
iswap
molmer_sorensen
phasegate
qasmu_gate
qrot
qubit_clifford_group
rotation
rx
ry
rz
s_gate
snot
sqrtiswap
sqrtnot
sqrtswap
swap
swapalpha
t_gate
toffoli
x_gate
y_gate
z_gate
12 changes: 6 additions & 6 deletions src/qutip_qip/algorithms/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import numpy as np
from qutip_qip.operations import CNOT, RZ, snot, cphase, swap, expand_operator
from qutip_qip.operations import CNOT, RZ, H, CPHASE, SWAP, expand_operator
from qutip_qip.circuit import QubitCircuit
from qutip import Qobj
from qutip_qip.decompose import decompose_one_qubit_gate
Expand Down Expand Up @@ -62,25 +62,25 @@ def qft_steps(N=1, swapping=True):

U_step_list = []
if N == 1:
U_step_list.append(snot())
U_step_list.append(H.get_qobj())
else:
for i in range(N):
for j in range(i):
U_step_list.append(
expand_operator(
cphase(np.pi / (2 ** (i - j))),
CPHASE(np.pi / (2 ** (i - j))).get_qobj(),
dims=[2] * N,
targets=[i, j],
)
)
U_step_list.append(
expand_operator(snot(), dims=[2] * N, targets=i)
expand_operator(H.get_qobj(), dims=[2] * N, targets=i)
)
if swapping:
for i in range(N // 2):
U_step_list.append(
expand_operator(
swap(), dims=[2] * N, targets=[N - i - 1, i]
SWAP.get_qobj(), dims=[2] * N, targets=[N - i - 1, i]
)
)
return U_step_list
Expand Down Expand Up @@ -141,5 +141,5 @@ def _cphase_to_cnot(targets, controls, arg_value, qc: QubitCircuit):
qc.add_gate(CNOT, targets=targets, controls=controls)
qc.add_gate(RZ, targets=controls, arg_value=arg_value / 2)
gate = decomposed_gates[7]
gate.arg_value += arg_value / 4
gate.arg_value[0] += arg_value / 4
qc.add_gate(gate, targets=targets)
2 changes: 1 addition & 1 deletion src/qutip_qip/algorithms/qpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def qpe(U, num_counting_qubits, target_qubits=None, to_cnot=False):
# Add controlled-U^power gate
controlled_u = controlled_gate_factory(
target_gate=custom_gate_factory(
name="U^power gate",
gate_name="U^power gate",
U=U_power,
)(),
)
Expand Down
12 changes: 6 additions & 6 deletions src/qutip_qip/circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def add_global_phase(self, phase: float):
def gates(self):
warnings.warn(
"QubitCircuit.gates has been replaced with QubitCircuit.instructions",
UserWarning,
DeprecationWarning,
stacklevel=2,
)
return self._instructions
Expand All @@ -113,7 +113,7 @@ def gates(self):
def gates(self):
warnings.warn(
"QubitCircuit.gates has been replaced with QubitCircuit.instructions",
UserWarning,
DeprecationWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -258,7 +258,7 @@ def add_gate(
raise ValueError("argument index is no longer supported")

if isinstance(gate, GLOBALPHASE):
self.add_global_phase(gate.arg_value)
self.add_global_phase(gate.arg_value[0])
return

# Handling case for int input
Expand Down Expand Up @@ -778,15 +778,15 @@ def propagators(self, expand=True, ignore_measurement=False):

# For Gate Instructions
for gate, qubits in gates:
qobj = gate.get_compact_qobj()
qobj = gate.get_qobj()
if expand:
qobj = expand_operator(qobj, dims=self.dims, targets=qubits)
U_list.append(qobj)

# For Circuit's Global Phase
qobj = Qobj(self.global_phase)
qobj = Qobj([self.global_phase])
if expand:
qobj = GLOBALPHASE(self.global_phase).get_qobj(self.N)
qobj = GLOBALPHASE(self.global_phase).get_qobj(num_qubits=self.N)

U_list.append(qobj)
return U_list
Expand Down
8 changes: 6 additions & 2 deletions src/qutip_qip/circuit/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ def __post_init__(self) -> None:

@property
def controls(self) -> tuple[int]:
return self.qubits[: self.operation.num_ctrl_qubits]
if hasattr(self.operation, 'num_ctrl_qubits'):
return self.qubits[: self.operation.num_ctrl_qubits]
return ()

@property
def targets(self) -> tuple[int]:
return self.qubits[self.operation.num_ctrl_qubits :]
if hasattr(self.operation, 'num_ctrl_qubits'):
return self.qubits[self.operation.num_ctrl_qubits :]
return self.qubits

def is_gate_instruction(self) -> bool:
return True
Expand Down
4 changes: 2 additions & 2 deletions src/qutip_qip/circuit/simulator/matrix_mul_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _evolve_state(self, operation, targets_indices, state):
U: Qobj
unitary to be applied.
"""
U = operation.get_compact_qobj()
U = operation.get_qobj()
U = expand_operator(
U,
dims=self.dims,
Expand All @@ -301,7 +301,7 @@ def _evolve_state_einsum(self, gate, targets_indices, state):
state = state.reshape(self._tensor_dims)

# Prepare the gate tensor.
gate = gate.get_compact_qobj()
gate = gate.get_qobj()
gate_array = gate.full().reshape(gate.dims[0] + gate.dims[1])

# Compute the tensor indices and call einsum.
Expand Down
12 changes: 6 additions & 6 deletions src/qutip_qip/circuit/simulator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def _mult_sublists(tensor_list, overall_inds, U, inds):
First, we get some imports out of the way,

>>> from qutip_qip.operations.gates import _mult_sublists
>>> from qutip_qip.operations.gates import x_gate, y_gate, toffoli, z_gate
>>> from qutip_qip.operations.gates import X, Y, Z

Suppose we have a unitary list of already processed gates,
X, Y, Z applied on qubit indices 0, 1, 2 respectively and
encounter a new TOFFOLI gate on qubit indices (0, 1, 3).

>>> tensor_list = [x_gate(), y_gate(), z_gate()]
>>> tensor_list = [X.get_qobj(), Y.get_qobj(), Z.get_qobj()]
>>> overall_inds = [[0], [1], [2]]
>>> U = toffoli()
>>> U_inds = [0, 1, 3]
Expand All @@ -60,8 +60,8 @@ def _mult_sublists(tensor_list, overall_inds, U, inds):
TOFFOLI gate (and any multiplied gates).

>>> U_list, overall_inds = _mult_sublists(tensor_list, overall_inds, U, U_inds)
>>> np.testing.assert_allclose(U_list[0]) == z_gate())
>>> toffoli_xy = toffoli() * tensor(x_gate(), y_gate(), identity(2))
>>> np.testing.assert_allclose(U_list[0]) == Z.get_qobj())
>>> toffoli_xy = toffoli() * tensor(X.get_qobj(), Y.get_qobj(), identity(2))
>>> np.testing.assert_allclose(U_list[1]), toffoli_xy)
>>> overall_inds = [[2], [0, 1, 3]]
"""
Expand Down Expand Up @@ -147,12 +147,12 @@ def gate_sequence_product(U_list, ind_list):
First, we get some imports out of the way,

>>> from qutip_qip.operations.gates import gate_sequence_product
>>> from qutip_qip.operations.gates import x_gate, y_gate, toffoli, z_gate
>>> from qutip_qip.operations.gates import X, Y, Z, TOFFOLI

Suppose we have a circuit with gates X, Y, Z, TOFFOLI
applied on qubit indices 0, 1, 2 and [0, 1, 3] respectively.

>>> tensor_lst = [x_gate(), y_gate(), z_gate(), toffoli()]
>>> tensor_lst = [X.get_qobj(), Y.get_qobj(), Z.get_qobj(), TOFFOLI.get_qobj()]
>>> overall_inds = [[0], [1], [2], [0, 1, 3]]

Then, we can use gate_sequence_product to produce a single unitary
Expand Down
2 changes: 1 addition & 1 deletion src/qutip_qip/compiler/cavityqedcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _rotation_compiler(
args["num_samples"],
maximum=self.params[param_label][targets[0]],
# The operator is Pauli Z/X/Y, without 1/2.
area=circuit_instruction.operation.arg_value / 2.0 / np.pi * 0.5,
area=circuit_instruction.operation.arg_value[0] / 2.0 / np.pi * 0.5,
)
pulse_info = [(op_label + str(targets[0]), coeff)]
return [PulseInstruction(circuit_instruction, tlist, pulse_info)]
Expand Down
2 changes: 1 addition & 1 deletion src/qutip_qip/compiler/circuitqedcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _rotation_compiler(
args["shape"],
args["num_samples"],
maximum=self.params[param_label][target],
area=circuit_instruction.operation.arg_value / 2.0 / np.pi,
area=circuit_instruction.operation.arg_value[0] / 2.0 / np.pi,
)
f = 2 * np.pi * self.params["wq"][target] # FIXME unused variable
if args["DRAG"]:
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/compiler/gatecompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, num_qubits=None, params=None, pulse_dict=None, N=None):
you can simply remove it.
""",
UserWarning,
stacklevel=2
)

def globalphase_compiler(self, phase):
Expand Down
2 changes: 1 addition & 1 deletion src/qutip_qip/compiler/spinchaincompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _rotation_compiler(
args["num_samples"],
maximum=self.params[param_label][targets[0]],
# The operator is Pauli Z/X/Y, without 1/2.
area=circuit_instruction.operation.arg_value / 2.0 / np.pi * 0.5,
area=circuit_instruction.operation.arg_value[0] / 2.0 / np.pi * 0.5,
)
pulse_info = [(op_label + str(targets[0]), coeff)]
return [PulseInstruction(circuit_instruction, tlist, pulse_info)]
Expand Down
5 changes: 3 additions & 2 deletions src/qutip_qip/device/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

from qutip import Qobj, QobjEvo, mesolve, mcsolve
from qutip_qip.operations import globalphase
from qutip_qip.operations import GLOBALPHASE
from qutip_qip.noise import Noise, process_noise
from qutip_qip.device import Model
from qutip_qip.device.utils import _pulse_interpolate
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def run_analytically(self, init_state=None, qc=None):
try: # correct_global_phase are defined for ModelProcessor
if self.correct_global_phase and self.global_phase != 0:
U_list.append(
globalphase(self.global_phase, N=self.num_qubits)
GLOBALPHASE(self.global_phase).get_qobj(self.num_qubits)
)
except AttributeError:
pass
Expand Down Expand Up @@ -1110,6 +1110,7 @@ def run_state(
warnings.warn(
"states will be deprecated and replaced by init_state",
DeprecationWarning,
stacklevel=2
)
if init_state is None and states is None:
raise ValueError("Qubit state not defined.")
Expand Down
2 changes: 2 additions & 0 deletions src/qutip_qip/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
RX,
RY,
RZ,
PHASE,
H,
SNOT,
SQRTNOT,
Expand Down Expand Up @@ -194,6 +195,7 @@
"RX",
"RY",
"RZ",
"PHASE",
"H",
"SNOT",
"SQRTNOT",
Expand Down
Loading