index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
30,730
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/permutation/permutation_utils.py
47,48
1,74
_pattern_to_cycles
49,63
48,63
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
nq = len(pattern) explored = [False] * nq cycles = [] for i in pattern: cycle = [] while not explored[i]: cycle.append(i) explored[i] = True i = pattern[i] if len(cycle) >= 2: cycles.append(cycle) return cycles
"""Given a permutation pattern, creates its disjoint cycle decomposition.""" nq = len(pattern) explored = [False] * nq cycles = [] for i in pattern: cycle = [] while not explored[i]: cycle.append(i) explored[i] = True i = pattern[i] if len(...
35
694
106
800
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,731
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/qft/qft_decompose_lnn.py
21,24
1,71
synth_qft_line
46,71
24,71
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
qc = QuantumCircuit(num_qubits) for i in range(num_qubits): qc.h(num_qubits - 1) for j in range(i, num_qubits - 1): if j - i + 2 < num_qubits - approximation_degree + 1: qc.p(np.pi / 2 ** (j - i + 2), num_qubits - j + i - 1) qc.cx(num_qubits - j + i...
"""Synthesis of a QFT circuit for a linear nearest neighbor connectivity. Based on Fig 2.b in Fowler et al. [1]. Note that this method *reverts* the order of qubits in the circuit, compared to the original :class:`.QFT` code. Hence, the default value of the ``do_swaps`` parameter is ``True`` si...
189
583
502
1,085
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,732
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/stabilizer/stabilizer_circuit.py
27,33
1,150
synth_circuit_from_stabilizers
33,150
33,150
# This code is part of Qiskit. # # (C) Copyright IBM 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# pylint: disable=line-too-long """Synthesis of a circuit that generates a state stabilized by the stabilizers using Gaussian elimination with Clifford gates. If the stabilizers are underconstrained, and ``allow_underconstrained`` is ``True``, the circuit will output one of the states stabilized by ...
# pylint: disable=line-too-long """Synthesis of a circuit that generates a state stabilized by the stabilizers using Gaussian elimination with Clifford gates. If the stabilizers are underconstrained, and ``allow_underconstrained`` is ``True``, the circuit will output one of the states stabilized by ...
409
310
1,493
1,803
# This code is part of Qiskit. # # (C) Copyright IBM 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,734
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/two_qubit/local_invariance.py
31,32
1,94
two_qubit_local_invariants
47,71
32,71
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
U = np.asarray(U) if U.shape != (4, 4): raise ValueError("Unitary must correspond to a two-qubit gate.") # Transform to bell basis Um = MAGIC.conj().T.dot(U.dot(MAGIC)) # Get determinate since +- one is allowed. det_um = np.linalg.det(Um) M = Um.T.dot(Um) # trace(M)**2 m_tr2...
"""Computes the local invariants for a two-qubit unitary. Args: U (ndarray): Input two-qubit unitary. Returns: ndarray: NumPy array of local invariants [g0, g1, g2]. Raises: ValueError: Input not a 2q unitary. Notes: Y. Makhlin, Quant. Info. Proc. 1, 243-252 (2002...
123
811
348
1,159
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,735
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/two_qubit/weyl.py
49,50
1,98
weyl_coordinates
58,98
50,98
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
import scipy.linalg as la pi2 = np.pi / 2 pi4 = np.pi / 4 U = U / la.det(U) ** (0.25) Up = transform_to_magic_basis(U, reverse=True) # We only need the eigenvalues of `M2 = Up.T @ Up` here, not the full diagonalization. D = la.eigvals(Up.T @ Up) d = -np.angle(D) / 2 d[3] = -d[0] - ...
"""Computes the Weyl coordinates for a given two-qubit unitary matrix. Args: U (np.ndarray): Input two-qubit unitary. Returns: np.ndarray: Array of the 3 Weyl coordinates. """ import scipy.linalg as la pi2 = np.pi / 2 pi4 = np.pi / 4 U = U / la.det(U) ** (0.25) Up...
178
725
538
1,263
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,739
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/two_qubit/xx_decompose/utilities.py
27,28
1,41
safe_arccos
31,41
28,41
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
threshold = 0.005 if abs(numerator) > abs(denominator) and abs(numerator - denominator) < threshold: return 0.0 elif abs(numerator) > abs(denominator) and abs(numerator + denominator) < threshold: return np.pi else: with warnings.catch_warnings(): warnings.filterwarn...
""" Computes arccos(n/d) with different (better?) numerical stability. """ threshold = 0.005 if abs(numerator) > abs(denominator) and abs(numerator - denominator) < threshold: return 0.0 elif abs(numerator) > abs(denominator) and abs(numerator + denominator) < threshold: return ...
36
261
131
392
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
30,740
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/two_qubit/xx_decompose/weyl.py
82,83
1,134
apply_shift
87,98
83,98
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
shift_scalars, shift_phase_shift, source_shift_gates = shift_options[shift_name] shifted_coord = [np.pi / 2 * x + y for x, y in zip(shift_scalars, coordinate)] source_shift = QuantumCircuit(2) for gate in source_shift_gates: source_shift.append(gate(np.pi), [0]) source_shift.append(gate...
""" Given a shift type and a canonical coordinate, applies the shift and describes a circuit which enacts the shift + a global phase shift. """ shift_scalars, shift_phase_shift, source_shift_gates = shift_options[shift_name] shifted_coord = [np.pi / 2 * x + y for x, y in zip(shift_scalars, coord...
35
1,529
151
1,680
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
30,741
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/approximate.py
32,35
21,55
thetas
ApproximateCircuit
41,43
35,43
class ApproximateCircuit(QuantumCircuit, ABC): """A base class that represents an approximate circuit.""" def __init__(self, num_qubits: int, name: Optional[str] = None) -> None: """ Args: num_qubits: number of qubit this circuit will span. name: a name of the circuit. ...
class ApproximateCircuit(QuantumCircuit, ABC): """A base class that represents an approximate circuit.""" def __init__(self, num_qubits: int, name: Optional[str] = None) -> None: """ Args: num_qubits: number of qubit this circuit will span. name: a name of the circuit. ...
raise NotImplementedError
""" The property is not implemented and raises a ``NotImplementedException`` exception. Returns: a vector of parameters of this circuit. """ raise NotImplementedError
2
280
11
291
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,742
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/approximate.py
66,68
55,117
objective
ApproximatingObjective
77,79
68,79
class ApproximatingObjective(ABC): """ A base class for an optimization problem definition. An implementing class must provide at least an implementation of the ``objective`` method. In such case only gradient free optimizers can be used. Both method, ``objective`` and ``gradient``, preferable to have i...
class ApproximatingObjective(ABC): """ A base class for an optimization problem definition. An implementing class must provide at least an implementation of the ``objective`` method. In such case only gradient free optimizers can be used. Both method, ``objective`` and ``gradient``, preferable to have i...
raise NotImplementedError
""" Computes a value of the objective function given a vector of parameter values. Args: param_values: a vector of parameter values for the optimization problem. Returns: a float value of the objective function. """ raise NotImplementedError
2
483
11
494
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,743
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/aqc.py
127,134
77,176
compile_unitary
AQC
146,176
134,176
class AQC: """ A generic implementation of the Approximate Quantum Compiler. This implementation is agnostic of the underlying implementation of the approximate circuit, objective, and optimizer. Users may pass corresponding implementations of the abstract classes: * The *optimizer* is an implement...
class AQC: """ A generic implementation of the Approximate Quantum Compiler. This implementation is agnostic of the underlying implementation of the approximate circuit, objective, and optimizer. Users may pass corresponding implementations of the abstract classes: * The *optimizer* is an implement...
matrix_dim = target_matrix.shape[0] # check if it is actually a special unitary matrix target_det = np.linalg.det(target_matrix) if not np.isclose(target_det, 1): su_matrix = target_matrix / np.power(target_det, (1 / matrix_dim), dtype=complex) global_phase_requir...
""" Approximately compiles a circuit represented as a unitary matrix by solving an optimization problem defined by ``approximating_objective`` and using ``approximate_circuit`` as a template for the approximate circuit. Args: target_matrix: a unitary matrix to approx...
83
853
367
1,220
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,745
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/cnot_unit_circuit.py
58,60
24,104
thetas
CNOTUnitCircuit
66,68
60,68
class CNOTUnitCircuit(ApproximateCircuit): """A class that represents an approximate circuit based on CNOT unit blocks.""" def __init__( self, num_qubits: int, cnots: np.ndarray, tol: Optional[float] = 0.0, name: Optional[str] = None, ) -> None: """ A...
class CNOTUnitCircuit(ApproximateCircuit): """A class that represents an approximate circuit based on CNOT unit blocks.""" def __init__( self, num_qubits: int, cnots: np.ndarray, tol: Optional[float] = 0.0, name: Optional[str] = None, ) -> None: """ A...
return self._thetas
""" Returns a vector of rotation angles used by CNOT units in this circuit. Returns: Parameters of the rotation gates in this circuit. """ return self._thetas
2
950
11
961
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,746
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/cnot_unit_objective.py
52,54
27,61
num_thetas
CNOTUnitObjective
58,61
54,61
class CNOTUnitObjective(ApproximatingObjective, ABC): """ A base class for a problem definition based on CNOT unit. This class may have different subclasses for objective and gradient computations. """ def __init__(self, num_qubits: int, cnots: np.ndarray) -> None: """ Args: ...
class CNOTUnitObjective(ApproximatingObjective, ABC): """ A base class for a problem definition based on CNOT unit. This class may have different subclasses for objective and gradient computations. """ def __init__(self, num_qubits: int, cnots: np.ndarray) -> None: """ Args: ...
return 3 * self._num_qubits + 4 * self._num_cnots
""" Returns: Number of parameters (angles) of rotation gates in this circuit. """ return 3 * self._num_qubits + 4 * self._num_cnots
8
277
27
304
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,748
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/elementary_operations.py
37,38
1,109
place_cnot
49,72
38,72
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
if j < k: unitary = np.kron( np.kron(np.eye(2**j), [[1, 0], [0, 0]]), np.eye(2 ** (n - 1 - j)) ) + np.kron( np.kron( np.kron(np.kron(np.eye(2**j), [[0, 0], [0, 1]]), np.eye(2 ** (k - j - 1))), [[0, 1], [1, 0]], ), np.eye...
""" Places a CNOT from j to k. Args: n: number of qubits. j: control qubit. k: target qubit. Returns: a unitary of n qubits with CNOT placed at ``j`` and ``k``. """ if j < k: unitary = np.kron( np.kron(np.eye(2**j), [[1, 0], [0, 0]]), np.eye(...
95
733
354
1,087
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,752
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/fast_gradient/layer.py
90,91
59,99
set_from_matrix
Layer1Q
92,94
91,94
class Layer1Q(LayerBase): """ Layer represents a simple circuit where 1-qubit gate matrix (of size 2x2) interleaves with the identity ones. """ def __init__(self, num_qubits: int, k: int, g2x2: Optional[np.ndarray] = None): """ Args: num_qubits: number of qubits. ...
class Layer1Q(LayerBase): """ Layer represents a simple circuit where 1-qubit gate matrix (of size 2x2) interleaves with the identity ones. """ def __init__(self, num_qubits: int, k: int, g2x2: Optional[np.ndarray] = None): """ Args: num_qubits: number of qubits. ...
np.copyto(self._gmat, mat)
"""See base class description.""" np.copyto(self._gmat, mat)
2
515
17
532
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,753
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/fast_gradient/layer.py
135,136
99,140
get_attr
Layer2Q
137,140
136,140
class Layer2Q(LayerBase): """ Layer represents a simple circuit where 2-qubit gate matrix (of size 4x4) interleaves with the identity ones. """ def __init__(self, num_qubits: int, j: int, k: int, g4x4: Optional[np.ndarray] = None): """ Args: num_qubits: number of qubits....
class Layer2Q(LayerBase): """ Layer represents a simple circuit where 2-qubit gate matrix (of size 4x4) interleaves with the identity ones. """ def __init__(self, num_qubits: int, j: int, k: int, g4x4: Optional[np.ndarray] = None): """ Args: num_qubits: number of qubits....
return self._gmat, self._perm, self._inv_perm
"""See base class description.""" return self._gmat, self._perm, self._inv_perm
4
530
24
554
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,754
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/unitary/aqc/fast_gradient/layer.py
38,40
30,59
set_from_matrix
LayerBase
46,48
40,48
class LayerBase(ABC): """ Base class for any layer implementation. Each layer here is represented by a 2x2 or 4x4 gate matrix ``G`` (applied to 1 or 2 qubits respectively) interleaved with the identity ones: ``Layer = I kron I kron ... kron G kron ... kron I kron I`` """ @abstractmethod ...
class LayerBase(ABC): """ Base class for any layer implementation. Each layer here is represented by a 2x2 or 4x4 gate matrix ``G`` (applied to 1 or 2 qubits respectively) interleaved with the identity ones: ``Layer = I kron I kron ... kron G kron ... kron I kron I`` """ @abstractmethod ...
raise NotImplementedError()
""" Updates this layer from an external gate matrix. Args: mat: external gate matrix that initializes this layer's one. """ raise NotImplementedError()
2
260
12
272
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,757
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/basepasses.py
110,112
71,182
is_analysis_pass
BasePass
118,120
112,120
class BasePass(GenericPass, metaclass=MetaPass): """Base class for transpiler passes.""" def __init__(self): super().__init__() self.preserves: Iterable[GenericPass] = [] self._hash = hash(None) def __hash__(self): return self._hash def __eq__(self, other): # N...
class BasePass(GenericPass, metaclass=MetaPass): """Base class for transpiler passes.""" def __init__(self): super().__init__() self.preserves: Iterable[GenericPass] = [] self._hash = hash(None) def __hash__(self): return self._hash def __eq__(self, other): # N...
return isinstance(self, AnalysisPass)
"""Check if the pass is an analysis pass. If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass. """ return isinstance(self, A...
3
1,187
14
1,201
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,758
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/basepasses.py
55,57
31,71
_freeze_init_parameters
MetaPass
57,71
57,71
class MetaPass(abc.ABCMeta): """Metaclass for transpiler passes. Enforces the creation of some fields in the pass while allowing passes to override ``__init__``. """ # Drop this functionality in the future. # This metaclass provides a pass equivalence evaluation based on the constructor argume...
class MetaPass(abc.ABCMeta): """Metaclass for transpiler passes. Enforces the creation of some fields in the pass while allowing passes to override ``__init__``. """ # Drop this functionality in the future. # This metaclass provides a pass equivalence evaluation based on the constructor argume...
self_guard = object() init_signature = signature(class_.__init__) bound_signature = init_signature.bind(self_guard, *args, **kwargs) arguments = [("class_.__name__", class_.__name__)] for name, value in bound_signature.arguments.items(): if value == self_guard: ...
self_guard = object() init_signature = signature(class_.__init__) bound_signature = init_signature.bind(self_guard, *args, **kwargs) arguments = [("class_.__name__", class_.__name__)] for name, value in bound_signature.arguments.items(): if value == self_guard: ...
37
353
159
512
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,759
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/basepasses.py
189,195
186,222
execute
TransformationPass
195,213
195,213
class TransformationPass(BasePass): # pylint: disable=abstract-method """A transformation pass: change DAG, not property set.""" def execute( self, passmanager_ir: PassManagerIR, state: PassManagerState, callback: Callable = None, ) -> tuple[PassManagerIR, PassManagerState]...
class TransformationPass(BasePass): # pylint: disable=abstract-method """A transformation pass: change DAG, not property set.""" def execute( self, passmanager_ir: PassManagerIR, state: PassManagerState, callback: Callable = None, ) -> tuple[PassManagerIR, PassManagerState]...
new_dag, state = super().execute( passmanager_ir=passmanager_ir, state=state, callback=callback, ) if state.workflow_status.previous_run == RunState.SUCCESS: if isinstance(new_dag, DAGCircuit): # Copy calibration data from the orig...
new_dag, state = super().execute( passmanager_ir=passmanager_ir, state=state, callback=callback, ) if state.workflow_status.previous_run == RunState.SUCCESS: if isinstance(new_dag, DAGCircuit): # Copy calibration data from the orig...
47
197
188
385
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,763
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/count_ops.py
28,29
18,31
run
CountOps
30,31
29,31
class CountOps(AnalysisPass): """Count the operations in a DAG circuit. The result is saved in ``property_set['count_ops']`` as an integer. """ def __init__(self, *, recurse=True): super().__init__() self.recurse = recurse def run(self, dag): FILL_FUNC_BODY
class CountOps(AnalysisPass): """Count the operations in a DAG circuit. The result is saved in ``property_set['count_ops']`` as an integer. """ def __init__(self, *, recurse=True): super().__init__() self.recurse = recurse def run(self, dag): """Run the CountOps pass on `d...
self.property_set["count_ops"] = dag.count_ops(recurse=self.recurse)
"""Run the CountOps pass on `dag`.""" self.property_set["count_ops"] = dag.count_ops(recurse=self.recurse)
3
115
31
146
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,764
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/count_ops_longest_path.py
24,25
18,27
run
CountOpsLongestPath
26,27
25,27
class CountOpsLongestPath(AnalysisPass): """Count the operations on the longest path in a :class:`.DAGCircuit`. The result is saved in ``property_set['count_ops_longest_path']`` as an integer. """ def run(self, dag): FILL_FUNC_BODY
class CountOpsLongestPath(AnalysisPass): """Count the operations on the longest path in a :class:`.DAGCircuit`. The result is saved in ``property_set['count_ops_longest_path']`` as an integer. """ def run(self, dag): """Run the CountOpsLongestPath pass on `dag`.""" FILL_FUNC_BODY
self.property_set["count_ops_longest_path"] = dag.count_ops_longest_path()
"""Run the CountOpsLongestPath pass on `dag`.""" self.property_set["count_ops_longest_path"] = dag.count_ops_longest_path()
3
103
31
134
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,765
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/dag_longest_path.py
22,23
18,25
run
DAGLongestPath
24,25
23,25
class DAGLongestPath(AnalysisPass): """Return the longest path in a :class:`.DAGCircuit` as a list of :class:`.DAGOpNode`\\ s, :class:`.DAGInNode`\\ s, and :class:`.DAGOutNode`\\ s.""" def run(self, dag): FILL_FUNC_BODY
class DAGLongestPath(AnalysisPass): """Return the longest path in a :class:`.DAGCircuit` as a list of :class:`.DAGOpNode`\\ s, :class:`.DAGInNode`\\ s, and :class:`.DAGOutNode`\\ s.""" def run(self, dag): """Run the DAGLongestPath pass on `dag`.""" FILL_FUNC_BODY
self.property_set["dag_longest_path"] = dag.longest_path()
"""Run the DAGLongestPath pass on `dag`.""" self.property_set["dag_longest_path"] = dag.longest_path()
3
113
25
138
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,766
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/depth.py
31,32
18,34
run
Depth
33,34
32,34
class Depth(AnalysisPass): """Calculate the depth of a DAG circuit.""" def __init__(self, *, recurse=False): """ Args: recurse: whether to allow recursion into control flow. If this is ``False`` (default), the pass will throw an error when control flow is present, t...
class Depth(AnalysisPass): """Calculate the depth of a DAG circuit.""" def __init__(self, *, recurse=False): """ Args: recurse: whether to allow recursion into control flow. If this is ``False`` (default), the pass will throw an error when control flow is present, t...
self.property_set["depth"] = dag.depth(recurse=self.recurse)
"""Run the Depth pass on `dag`.""" self.property_set["depth"] = dag.depth(recurse=self.recurse)
3
149
27
176
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,767
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/num_qubits.py
24,25
18,27
run
NumQubits
26,27
25,27
class NumQubits(AnalysisPass): """Calculate the number of qubits of a DAG circuit. The result is saved in ``property_set['num_qubits']`` as an integer. """ def run(self, dag): FILL_FUNC_BODY
class NumQubits(AnalysisPass): """Calculate the number of qubits of a DAG circuit. The result is saved in ``property_set['num_qubits']`` as an integer. """ def run(self, dag): """Run the NumQubits pass on `dag`.""" FILL_FUNC_BODY
self.property_set["num_qubits"] = dag.num_qubits()
"""Run the NumQubits pass on `dag`.""" self.property_set["num_qubits"] = dag.num_qubits()
3
88
23
111
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,768
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/num_tensor_factors.py
24,25
18,27
run
NumTensorFactors
26,27
25,27
class NumTensorFactors(AnalysisPass): """Calculate the number of tensor factors of a DAG circuit. The result is saved in ``property_set['num_tensor_factors']`` as an integer. """ def run(self, dag): FILL_FUNC_BODY
class NumTensorFactors(AnalysisPass): """Calculate the number of tensor factors of a DAG circuit. The result is saved in ``property_set['num_tensor_factors']`` as an integer. """ def run(self, dag): """Run the NumTensorFactors pass on `dag`.""" FILL_FUNC_BODY
self.property_set["num_tensor_factors"] = dag.num_tensor_factors()
"""Run the NumTensorFactors pass on `dag`.""" self.property_set["num_tensor_factors"] = dag.num_tensor_factors()
3
92
27
119
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,769
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/size.py
34,35
18,37
run
Size
36,37
35,37
class Size(AnalysisPass): """Calculate the size of a DAG circuit. The result is saved in ``property_set['size']`` as an integer. """ def __init__(self, *, recurse=False): """ Args: recurse: whether to allow recursion into control flow. If this is ``False`` (default), ...
class Size(AnalysisPass): """Calculate the size of a DAG circuit. The result is saved in ``property_set['size']`` as an integer. """ def __init__(self, *, recurse=False): """ Args: recurse: whether to allow recursion into control flow. If this is ``False`` (default), ...
self.property_set["size"] = dag.size(recurse=self.recurse)
"""Run the Size pass on `dag`.""" self.property_set["size"] = dag.size(recurse=self.recurse)
3
170
27
197
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,770
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/analysis/width.py
25,26
18,28
run
Width
27,28
26,28
class Width(AnalysisPass): """Calculate the width of a DAG circuit. The result is saved in ``property_set['width']`` as an integer that contains the number of qubits + the number of clbits. """ def run(self, dag): FILL_FUNC_BODY
class Width(AnalysisPass): """Calculate the width of a DAG circuit. The result is saved in ``property_set['width']`` as an integer that contains the number of qubits + the number of clbits. """ def run(self, dag): """Run the Width pass on `dag`.""" FILL_FUNC_BODY
self.property_set["width"] = dag.width()
"""Run the Width pass on `dag`.""" self.property_set["width"] = dag.width()
3
93
17
110
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,772
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/basis/basis_translator.py
458,459
439,526
discover_vertex
BasisSearchVisitor
459,480
459,480
class BasisSearchVisitor(rustworkx.visit.DijkstraVisitor): """Handles events emitted during `rustworkx.dijkstra_search`.""" def __init__(self, graph, source_basis, target_basis): self.graph = graph self.target_basis = set(target_basis) self._source_gates_remain = set(source_basis) ...
class BasisSearchVisitor(rustworkx.visit.DijkstraVisitor): """Handles events emitted during `rustworkx.dijkstra_search`.""" def __init__(self, graph, source_basis, target_basis): self.graph = graph self.target_basis = set(target_basis) self._source_gates_remain = set(source_basis) ...
gate = self.graph[v].key self._source_gates_remain.discard(gate) self._opt_cost_map[gate] = score rule = self._predecessors.get(gate, None) if rule is not None: logger.debug( "Gate %s generated using rule \n%s\n with total cost of %s.", ...
gate = self.graph[v].key self._source_gates_remain.discard(gate) self._opt_cost_map[gate] = score rule = self._predecessors.get(gate, None) if rule is not None: logger.debug( "Gate %s generated using rule \n%s\n with total cost of %s.", ...
105
734
299
1,033
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,774
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/basis/decompose.py
69,70
23,99
_should_decompose
Decompose
72,99
70,99
class Decompose(TransformationPass): """Expand a gate in a circuit using its decomposition rules.""" def __init__( self, gates_to_decompose: Optional[Union[Type[Gate], List[Type[Gate]], List[str], str]] = None, ) -> None: """Decompose initializer. Args: gates_to...
class Decompose(TransformationPass): """Expand a gate in a circuit using its decomposition rules.""" def __init__( self, gates_to_decompose: Optional[Union[Type[Gate], List[Type[Gate]], List[str], str]] = None, ) -> None: """Decompose initializer. Args: gates_to...
if self.gates_to_decompose is None: # check if no gates given return True if not isinstance(self.gates_to_decompose, list): gates = [self.gates_to_decompose] else: gates = self.gates_to_decompose strings_list = [s for s in gates if isinstance(s, str...
"""Call a decomposition pass on this circuit, to decompose one level (shallow decompose).""" if self.gates_to_decompose is None: # check if no gates given return True if not isinstance(self.gates_to_decompose, list): gates = [self.gates_to_decompose] els...
122
536
330
866
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,776
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/basis/translate_parameterized.py
119,120
29,154
run
TranslateParameterizedGates
131,154
120,154
class TranslateParameterizedGates(TransformationPass): """Translate parameterized gates to a supported basis set. Once a parameterized instruction is found that is not in the ``supported_gates`` list, the instruction is decomposed one level and the parameterized sub-blocks are recursively decomposed. T...
class TranslateParameterizedGates(TransformationPass): """Translate parameterized gates to a supported basis set. Once a parameterized instruction is found that is not in the ``supported_gates`` list, the instruction is decomposed one level and the parameterized sub-blocks are recursively decomposed. T...
for node in dag.op_nodes(): # check whether it is parameterized and we need to decompose it if _is_parameterized(node.op) and not _is_supported( node, self._supported_gates, self._target ): definition = node.op.definition if de...
"""Run the transpiler pass. Args: dag: The DAG circuit in which the parameterized gates should be unrolled. Returns: A DAG where the parameterized gates have been unrolled. Raises: QiskitError: If the circuit cannot be unrolled. """ ...
85
1,247
250
1,497
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,777
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/basis/unroll_3q_or_more.py
46,47
22,87
run
Unroll3qOrMore
56,87
47,87
class Unroll3qOrMore(TransformationPass): """Recursively expands 3q+ gates until the circuit only contains 2q or 1q gates.""" def __init__(self, target=None, basis_gates=None): """Initialize the Unroll3qOrMore pass Args: target (Target): The target object representing the compilati...
class Unroll3qOrMore(TransformationPass): """Recursively expands 3q+ gates until the circuit only contains 2q or 1q gates.""" def __init__(self, target=None, basis_gates=None): """Initialize the Unroll3qOrMore pass Args: target (Target): The target object representing the compilati...
for node in dag.multi_qubit_ops(): if dag.has_calibration_for(node): continue if isinstance(node.op, ControlFlowOp): node.op = control_flow.map_blocks(self.run, node.op) continue if self.target is not None: # T...
"""Run the Unroll3qOrMore pass on `dag`. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag with maximum node degrees of 2 Raises: QiskitError: if a 3q+ gate is not decomposable """ for node in dag.multi_qubit_ops(): ...
118
385
359
744
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,778
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/base_builder.py
54,55
27,80
run
CalibrationBuilder
63,80
55,80
class CalibrationBuilder(TransformationPass): """Abstract base class to inject calibrations into circuits.""" @abstractmethod def supported(self, node_op: CircuitInst, qubits: List) -> bool: """Determine if a given node supports the calibration. Args: node_op: Target instructio...
class CalibrationBuilder(TransformationPass): """Abstract base class to inject calibrations into circuits.""" @abstractmethod def supported(self, node_op: CircuitInst, qubits: List) -> bool: """Determine if a given node supports the calibration. Args: node_op: Target instructio...
for node in dag.gate_nodes(): qubits = [dag.find_bit(q).index for q in node.qargs] if self.supported(node.op, qubits) and not dag.has_calibration_for(node): # calibration can be provided and no user-defined calibration is already provided try: ...
"""Run the calibration adder pass on `dag`. Args: dag: DAG to schedule. Returns: A DAG with calibrations added to it. """ for node in dag.gate_nodes(): qubits = [dag.find_bit(q).index for q in node.qargs] if self.supported(node.o...
66
305
234
539
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,779
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/pulse_gate.py
73,74
26,99
supported
PulseGates
83,85
74,85
class PulseGates(CalibrationBuilder): """Pulse gate adding pass. This pass adds gate calibrations from the supplied ``InstructionScheduleMap`` to a quantum circuit. This pass checks each DAG circuit node and acquires a corresponding schedule from the instruction schedule map object that may be pro...
class PulseGates(CalibrationBuilder): """Pulse gate adding pass. This pass adds gate calibrations from the supplied ``InstructionScheduleMap`` to a quantum circuit. This pass checks each DAG circuit node and acquires a corresponding schedule from the instruction schedule map object that may be pro...
return self.target.has_calibration(node_op.name, tuple(qubits))
"""Determine if a given node supports the calibration. Args: node_op: Target instruction object. qubits: Integer qubit indices to check. Returns: Return ``True`` is calibration can be provided. """ return self.target.has_calibration(node_op.n...
3
702
27
729
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,780
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/rx_builder.py
141,150
1,161
_create_rx_sched
153,161
150,161
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
new_amp = rx_angle / (np.pi / 2) * amp with builder.build() as new_rx_sched: builder.play( Drag(duration=duration, amp=new_amp, sigma=sigma, beta=beta, angle=0), channel=channel, ) return new_rx_sched
"""Generates (and caches) pulse calibrations for RX gates. Assumes that the rotation angle is in [0, pi]. """ new_amp = rx_angle / (np.pi / 2) * amp with builder.build() as new_rx_sched: builder.play( Drag(duration=duration, amp=new_amp, sigma=sigma, beta=beta, angle=0), ...
23
1,792
95
1,887
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,781
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/rx_builder.py
112,113
29,141
get_calibration
RXCalibrationBuilder
116,141
113,141
class RXCalibrationBuilder(CalibrationBuilder): """Add single-pulse RX calibrations that are bootstrapped from the SX calibration. .. note:: Requirement: NormalizeRXAngles pass (one of the optimization passes). It is recommended to place this pass in the post-optimization stage of a passmanager. ...
class RXCalibrationBuilder(CalibrationBuilder): """Add single-pulse RX calibrations that are bootstrapped from the SX calibration. .. note:: Requirement: NormalizeRXAngles pass (one of the optimization passes). It is recommended to place this pass in the post-optimization stage of a passmanager. ...
# already within [0, pi] by NormalizeRXAngles pass angle = node_op.params[0] try: angle = float(angle) except TypeError as ex: raise QiskitError("Target rotation angle is not assigned.") from ex params = ( self.target.get_calibration("sx", tu...
""" Generate RX calibration for the rotation angle specified in node_op. """ # already within [0, pi] by NormalizeRXAngles pass angle = node_op.params[0] try: angle = float(angle) except TypeError as ex: raise QiskitError("Target rotation ...
49
1,166
240
1,406
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,784
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/rzx_builder.py
259,260
245,310
get_calibration
RZXCalibrationBuilderNoEcho
276,310
260,310
class RZXCalibrationBuilderNoEcho(RZXCalibrationBuilder): """ Creates calibrations for RZXGate(theta) by stretching and compressing Gaussian square pulses in the CX gate. The ``RZXCalibrationBuilderNoEcho`` is a variation of the :class:`~qiskit.transpiler.passes.RZXCalibrationBuilder` pass that...
class RZXCalibrationBuilderNoEcho(RZXCalibrationBuilder): """ Creates calibrations for RZXGate(theta) by stretching and compressing Gaussian square pulses in the CX gate. The ``RZXCalibrationBuilderNoEcho`` is a variation of the :class:`~qiskit.transpiler.passes.RZXCalibrationBuilder` pass that...
theta = node_op.params[0] try: theta = float(theta) except TypeError as ex: raise QiskitError("Target rotation angle is not assigned.") from ex if np.isclose(theta, 0.0): return ScheduleBlock(name="rzx(0.000)") cal_type, cr_tones, comp_tones...
"""Builds the calibration schedule for the RZXGate(theta) without echos. Args: node_op: Instruction of the RZXGate(theta). I.e. params[0] is theta. qubits: List of qubits for which to get the schedules. The first qubit is the control and the second is the target....
120
429
492
921
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,785
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/calibration/rzx_templates.py
34,35
1,52
rzx_templates
43,52
35,52
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
if template_list is None: template_list = ["zz1", "zz2", "zz3", "yz", "xz", "cy"] templates = [RZXTemplateMap[gate.upper()].value for gate in template_list] cost_dict = {"rzx": 0, "cx": 6, "rz": 0, "sx": 1, "p": 0, "h": 1, "rx": 1, "ry": 1} rzx_dict = {"template_list": templates, "user_cost_di...
"""Convenience function to get the cost_dict and templates for template matching. Args: template_list: List of instruction names. Returns: Decomposition templates and cost values. """ if template_list is None: template_list = ["zz1", "zz2", "zz3", "yz", "xz", "cy"] tem...
45
400
167
567
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,786
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/_csp_custom_solver.py
50,51
25,66
getSolution
CustomSolver
52,58
51,58
class CustomSolver(RecursiveBacktrackingSolver): """A wrap to RecursiveBacktrackingSolver to support ``call_limit``""" # pylint: disable=invalid-name def __init__(self, call_limit=None, time_limit=None): self.call_limit = call_limit self.time_limit = time_limit ...
class CustomSolver(RecursiveBacktrackingSolver): """A wrap to RecursiveBacktrackingSolver to support ``call_limit``""" # pylint: disable=invalid-name def __init__(self, call_limit=None, time_limit=None): self.call_limit = call_limit self.time_limit = time_limit ...
if self.call_limit is not None: self.call_current = 0 if self.time_limit is not None: self.time_start = time() return super().getSolution(domains, constraints, vconstraints)
"""Wrap RecursiveBacktrackingSolver.getSolution to add the limits.""" if self.call_limit is not None: self.call_current = 0 if self.time_limit is not None: self.time_start = time() return super().getSolution(domains, constraints, vconstrain...
20
397
68
465
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,787
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/csp_layout.py
74,75
27,133
run
CSPLayout
76,133
75,133
@_optionals.HAS_CONSTRAINT.require_in_instance class CSPLayout(AnalysisPass): """If possible, chooses a Layout as a CSP, using backtracking.""" def __init__( self, coupling_map, strict_direction=False, seed=None, call_limit=1000, time_limit=10, ): """...
@_optionals.HAS_CONSTRAINT.require_in_instance class CSPLayout(AnalysisPass): """If possible, chooses a Layout as a CSP, using backtracking.""" def __init__( self, coupling_map, strict_direction=False, seed=None, call_limit=1000, time_limit=10, ): """...
if not self.coupling_map.is_connected(): raise TranspilerError( "Coupling Map is disjoint, this pass can't be used with a disconnected coupling " "map." ) qubits = dag.qubits cxs = set() from constraint import Problem, AllDifferent...
"""run the layout method""" if not self.coupling_map.is_connected(): raise TranspilerError( "Coupling Map is disjoint, this pass can't be used with a disconnected coupling " "map." ) qubits = dag.qubits cxs = set() from con...
179
549
717
1,266
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,789
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/enlarge_with_ancilla.py
27,28
19,50
run
EnlargeWithAncilla
39,50
28,50
class EnlargeWithAncilla(TransformationPass): """Extend the dag with virtual qubits that are in layout but not in the circuit yet. Extend the DAG circuit with new virtual qubits (ancilla) that are specified in the layout, but not present in the circuit. Which qubits to add are previously allocated in t...
class EnlargeWithAncilla(TransformationPass): """Extend the dag with virtual qubits that are in layout but not in the circuit yet. Extend the DAG circuit with new virtual qubits (ancilla) that are specified in the layout, but not present in the circuit. Which qubits to add are previously allocated in t...
layout = self.property_set["layout"] if layout is None: raise TranspilerError('EnlargeWithAncilla requires property_set["layout"]') new_qregs = {reg for reg in layout.get_registers() if reg not in dag.qregs.values()} for qreg in new_qregs: dag.add_qreg(qreg) ...
"""Run the EnlargeWithAncilla pass on `dag`. Args: dag (DAGCircuit): DAG to extend. Returns: DAGCircuit: An extended DAG. Raises: TranspilerError: If there is no layout in the property set or not set at init time. """ layout = self.p...
30
203
120
323
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,790
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/full_ancilla_allocation.py
50,51
21,118
run
FullAncillaAllocation
69,107
51,107
class FullAncillaAllocation(AnalysisPass): """Allocate all idle nodes from the coupling map or target as ancilla on the layout. A pass for allocating all idle physical qubits (those that exist in coupling map or target but not the dag circuit) as ancilla. It will also choose new virtual qubits to corre...
class FullAncillaAllocation(AnalysisPass): """Allocate all idle nodes from the coupling map or target as ancilla on the layout. A pass for allocating all idle physical qubits (those that exist in coupling map or target but not the dag circuit) as ancilla. It will also choose new virtual qubits to corre...
layout = self.property_set.get("layout") if layout is None: raise TranspilerError('FullAncillaAllocation pass requires property_set["layout"].') virtual_bits = layout.get_virtual_bits() physical_bits = layout.get_physical_bits() if layout: FullAncillaAll...
"""Run the FullAncillaAllocation pass on `dag`. Extend the layout with new (physical qubit, virtual qubit) pairs. The dag signals which virtual qubits are already in the circuit. This pass will allocate new virtual qubits such that no collision occurs (i.e. Layout bijectivity is...
117
603
494
1,097
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,791
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/layout_2q_distance.py
50,51
25,78
run
Layout2qDistance
56,78
51,78
class Layout2qDistance(AnalysisPass): """Evaluate how good the layout selection was. Saves in ``property_set['layout_score']`` (or the property name in property_name) the sum of distances for each circuit CX. The lower the number, the better the selection. Therefore, 0 is a perfect layout selection. ...
class Layout2qDistance(AnalysisPass): """Evaluate how good the layout selection was. Saves in ``property_set['layout_score']`` (or the property name in property_name) the sum of distances for each circuit CX. The lower the number, the better the selection. Therefore, 0 is a perfect layout selection. ...
layout = self.property_set["layout"] if layout is None: return if self.coupling_map is None or len(self.coupling_map.graph) == 0: self.property_set[self.property_name] = 0 return self.coupling_map.compute_distance_matrix() sum_distance = 0 ...
""" Run the Layout2qDistance pass on `dag`. Args: dag (DAGCircuit): DAG to evaluate. """ layout = self.property_set["layout"] if layout is None: return if self.coupling_map is None or len(self.coupling_map.graph) == 0: self.pr...
49
330
246
576
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,792
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/set_layout.py
40,41
19,70
run
SetLayout
49,70
41,70
class SetLayout(AnalysisPass): """Set the ``layout`` property to the given layout. This pass associates a physical qubit (int) to each virtual qubit of the circuit (Qubit) in increasing order. """ def __init__(self, layout): """SetLayout initializer. Args: layout (Layo...
class SetLayout(AnalysisPass): """Set the ``layout`` property to the given layout. This pass associates a physical qubit (int) to each virtual qubit of the circuit (Qubit) in increasing order. """ def __init__(self, layout): """SetLayout initializer. Args: layout (Layo...
if isinstance(self.layout, list): if len(self.layout) != len(dag.qubits): raise InvalidLayoutError( "The length of the layout is different than the size of the " f"circuit: {len(self.layout)} <> {len(dag.qubits)}" ) ...
"""Run the SetLayout pass on ``dag``. Args: dag (DAGCircuit): DAG to map. Returns: DAGCircuit: the original DAG. """ if isinstance(self.layout, list): if len(self.layout) != len(dag.qubits): raise InvalidLayoutError( ...
80
246
266
512
# This code is part of Qiskit. # # (C) Copyright IBM 2019 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2019 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
30,793
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/layout/trivial_layout.py
50,51
21,67
run
TrivialLayout
59,67
51,67
class TrivialLayout(AnalysisPass): """Choose a Layout by assigning ``n`` circuit qubits to device qubits ``0, .., n-1``. A pass for choosing a Layout of a circuit onto a Coupling graph, using a simple round-robin order. This pass associates a physical qubit (int) to each virtual qubit of the circu...
class TrivialLayout(AnalysisPass): """Choose a Layout by assigning ``n`` circuit qubits to device qubits ``0, .., n-1``. A pass for choosing a Layout of a circuit onto a Coupling graph, using a simple round-robin order. This pass associates a physical qubit (int) to each virtual qubit of the circu...
if self.target is not None: if dag.num_qubits() > self.target.num_qubits: raise TranspilerError("Number of qubits greater than device.") elif dag.num_qubits() > self.coupling_map.size(): raise TranspilerError("Number of qubits greater than device.") self.p...
"""Run the TrivialLayout pass on `dag`. Args: dag (DAGCircuit): DAG to find layout for. Raises: TranspilerError: if dag wider than the target backend """ if self.target is not None: if dag.num_qubits() > self.target.num_qubits: ...
34
341
134
475
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,797
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_1q_runs.py
21,22
18,32
run
Collect1qRuns
30,32
22,32
class Collect1qRuns(AnalysisPass): """Collect one-qubit subcircuits.""" def run(self, dag): FILL_FUNC_BODY
class Collect1qRuns(AnalysisPass): """Collect one-qubit subcircuits.""" def run(self, dag): """Run the Collect1qBlocks pass on `dag`. The blocks contain "op" nodes in topological order such that all gates in a block act on the same qubits and are adjacent in the circuit. After...
self.property_set["run_list"] = dag.collect_1q_runs() return dag
"""Run the Collect1qBlocks pass on `dag`. The blocks contain "op" nodes in topological order such that all gates in a block act on the same qubits and are adjacent in the circuit. After the execution, ``property_set['run_list']`` is set to a list of tuples of "op" node. ...
5
132
31
163
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,798
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_2q_blocks.py
23,24
20,36
run
Collect2qBlocks
32,36
24,36
class Collect2qBlocks(AnalysisPass): """Collect two-qubit subcircuits.""" def run(self, dag): FILL_FUNC_BODY
class Collect2qBlocks(AnalysisPass): """Collect two-qubit subcircuits.""" def run(self, dag): """Run the Collect2qBlocks pass on `dag`. The blocks contain "op" nodes in topological order such that all gates in a block act on the same qubits and are adjacent in the circuit. Aft...
self.property_set["commutation_set"] = defaultdict(list) self.property_set["block_list"] = dag.collect_2q_runs() return dag
"""Run the Collect2qBlocks pass on `dag`. The blocks contain "op" nodes in topological order such that all gates in a block act on the same qubits and are adjacent in the circuit. After the execution, ``property_set['block_list']`` is set to a list of tuples of "op" node. ...
8
132
54
186
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,799
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_and_collapse.py
91,99
1,116
collect_using_filter_function
102,111
99,111
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
return BlockCollector(dag).collect_all_matching_blocks( filter_fn=filter_function, split_blocks=split_blocks, min_block_size=min_block_size, split_layers=split_layers, collect_from_back=collect_from_back, )
"""Corresponds to an important block collection strategy that greedily collects maximal blocks of nodes matching a given ``filter_function``. """ return BlockCollector(dag).collect_all_matching_blocks( filter_fn=filter_function, split_blocks=split_blocks, min_block_size=min_block...
8
1,139
90
1,229
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,800
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_and_collapse.py
65,67
23,91
run
CollectAndCollapse
73,91
67,91
class CollectAndCollapse(TransformationPass): """A general transpiler pass to collect and to consolidate blocks of nodes in a circuit. This transpiler pass depends on two functions: the collection function and the collapsing function. The collection function ``collect_function`` takes a DAG and ret...
class CollectAndCollapse(TransformationPass): """A general transpiler pass to collect and to consolidate blocks of nodes in a circuit. This transpiler pass depends on two functions: the collection function and the collapsing function. The collection function ``collect_function`` takes a DAG and ret...
# If the option commutative_analysis is set, construct DAGDependency from the given DAGCircuit. if self.do_commutative_analysis: dag = dag_to_dagdependency(dag) # call collect_function to collect blocks from DAG blocks = self.collect_function(dag) # call collapse_f...
"""Run the CollectLinearFunctions pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ # If the option commutative_analysis is set, construct DAGDependency from the given DAGCircuit. if self.d...
60
559
187
746
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,801
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_cliffords.py
89,90
1,98
_is_clifford_gate
91,94
90,94
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
return node.op.name in clifford_gate_names and getattr(node.op, "condition", None) is None
"""Specifies whether a node holds a clifford gate.""" return node.op.name in clifford_gate_names and getattr(node.op, "condition", None) is None
10
846
36
882
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,802
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/collect_linear_functions.py
72,73
1,81
_is_linear_gate
74,77
73,77
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
return node.op.name in ("cx", "swap") and getattr(node.op, "condition", None) is None
"""Specifies whether a node holds a linear gate.""" return node.op.name in ("cx", "swap") and getattr(node.op, "condition", None) is None
11
769
36
805
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,804
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/commutation_analysis.py
34,35
22,94
run
CommutationAnalysis
40,94
35,94
class CommutationAnalysis(AnalysisPass): """Analysis pass to find commutation relations between DAG nodes. ``property_set['commutation_set']`` is a dictionary that describes the commutation relations on a given wire, all the gates on a wire are grouped into a set of gates that commute. """ def...
class CommutationAnalysis(AnalysisPass): """Analysis pass to find commutation relations between DAG nodes. ``property_set['commutation_set']`` is a dictionary that describes the commutation relations on a given wire, all the gates on a wire are grouped into a set of gates that commute. """ def...
# Initiate the commutation set self.property_set["commutation_set"] = defaultdict(list) # Build a dictionary to keep track of the gates on each qubit # The key with format (wire) will store the lists of commutation sets # The key with format (node, wire) will store the index of ...
"""Run the CommutationAnalysis pass on `dag`. Run the pass on the DAG, and write the discovered commutation relations into the ``property_set``. """ # Initiate the commutation set self.property_set["commutation_set"] = defaultdict(list) # Build a dictionary to k...
182
174
642
816
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,805
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py
39,40
21,144
_skip_node
CommutativeInverseCancellation
41,56
40,56
class CommutativeInverseCancellation(TransformationPass): """Cancel pairs of inverse gates exploiting commutation relations.""" def __init__(self, matrix_based: bool = False, max_qubits: int = 4): """ Args: matrix_based: If ``True``, uses matrix representations to check whether two ...
class CommutativeInverseCancellation(TransformationPass): """Cancel pairs of inverse gates exploiting commutation relations.""" def __init__(self, matrix_based: bool = False, max_qubits: int = 4): """ Args: matrix_based: If ``True``, uses matrix representations to check whether two ...
if not isinstance(node, DAGOpNode): return True # We are currently taking an over-conservative approach with respect to which nodes # can be inverses of which other nodes, and do not allow reductions for barriers, measures, # conditional gates or parameterized gates. Possibl...
"""Returns True if we should skip this node for the analysis.""" if not isinstance(node, DAGOpNode): return True # We are currently taking an over-conservative approach with respect to which nodes # can be inverses of which other nodes, and do not allow reductions for barrie...
79
1,186
183
1,369
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,807
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/cx_cancellation.py
32,34
20,66
run
CXCancellation
42,66
34,66
class CXCancellation(TransformationPass): """Cancel back-to-back ``cx`` gates in dag.""" @deprecate_func( additional_msg=( "Instead, use :class:`~.InverseCancellation`, which is a more generic pass." ), since="1.1.0", ) def __init__(self, *args, **kwargs): su...
class CXCancellation(TransformationPass): """Cancel back-to-back ``cx`` gates in dag.""" @deprecate_func( additional_msg=( "Instead, use :class:`~.InverseCancellation`, which is a more generic pass." ), since="1.1.0", ) def __init__(self, *args, **kwargs): su...
cx_runs = dag.collect_runs(["cx"]) for cx_run in cx_runs: # Although one `cx_run` will always have the same set of qubits, # the order of these qubits matters (CXi_j != CXj_i). # Therefore, we have to partition each run into chunks where the qargs # are in...
"""Run the CXCancellation pass on `dag`. Args: dag (DAGCircuit): the directed acyclic graph to run on. Returns: DAGCircuit: Transformed DAG. """ cx_runs = dag.collect_runs(["cx"]) for cx_run in cx_runs: # Although one `cx_run` will al...
110
212
325
537
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,808
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py
107,108
29,161
run
EchoRZXWeylDecomposition
123,161
108,161
class EchoRZXWeylDecomposition(TransformationPass): """Rewrite two-qubit gates using the Weyl decomposition. This transpiler pass rewrites two-qubit gates in terms of echoed cross-resonance gates according to the Weyl decomposition. A two-qubit gate will be replaced with at most six non-echoed RZXGates. ...
class EchoRZXWeylDecomposition(TransformationPass): """Rewrite two-qubit gates using the Weyl decomposition. This transpiler pass rewrites two-qubit gates in terms of echoed cross-resonance gates according to the Weyl decomposition. A two-qubit gate will be replaced with at most six non-echoed RZXGates. ...
# pylint: disable=cyclic-import from qiskit.quantum_info import Operator from qiskit.synthesis.two_qubit.two_qubit_decompose import TwoQubitControlledUDecomposer if len(dag.qregs) > 1: raise TranspilerError( "EchoRZXWeylDecomposition expects a single qreg in...
"""Run the EchoRZXWeylDecomposition pass on `dag`. Rewrites two-qubit gates in an arbitrary circuit in terms of echoed cross-resonance gates by computing the Weyl decomposition of the corresponding unitary. Modifies the input dag. Args: dag (DAGCircuit): DAG to rewr...
85
1,501
484
1,985
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,810
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/inverse_cancellation.py
90,91
24,177
_run_on_self_inverse
InverseCancellation
101,134
91,134
class InverseCancellation(TransformationPass): """Cancel specific Gates which are inverses of each other when they occur back-to- back.""" def __init__(self, gates_to_cancel: List[Union[Gate, Tuple[Gate, Gate]]]): """Initialize InverseCancellation pass. Args: gates_to_cancel: L...
class InverseCancellation(TransformationPass): """Cancel specific Gates which are inverses of each other when they occur back-to- back.""" def __init__(self, gates_to_cancel: List[Union[Gate, Tuple[Gate, Gate]]]): """Initialize InverseCancellation pass. Args: gates_to_cancel: L...
op_counts = dag.count_ops() if not self.self_inverse_gate_names.intersection(op_counts): return dag # Sets of gate runs by name, for instance: [{(H 0, H 0), (H 1, H 1)}, {(X 0, X 0}] for gate in self.self_inverse_gates: gate_name = gate.name gate_count...
""" Run self-inverse gates on `dag`. Args: dag: the directed acyclic graph to run on. self_inverse_gates: list of gates who cancel themeselves in pairs Returns: DAGCircuit: Transformed DAG. """ op_counts = dag.count_ops() if n...
122
1,343
430
1,773
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,813
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/optimize_cliffords.py
26,28
20,90
run
OptimizeCliffords
36,90
28,90
class OptimizeCliffords(TransformationPass): """Combine consecutive Cliffords over the same qubits. This serves as an example of extra capabilities enabled by storing Cliffords natively on the circuit. """ @control_flow.trivial_recurse def run(self, dag): FILL_FUNC_BODY
class OptimizeCliffords(TransformationPass): """Combine consecutive Cliffords over the same qubits. This serves as an example of extra capabilities enabled by storing Cliffords natively on the circuit. """ @control_flow.trivial_recurse def run(self, dag): """Run the OptimizeCliffords pa...
blocks = [] prev_node = None cur_block = [] # Iterate over all nodes and collect consecutive Cliffords over the # same qubits. In this very first proof-of-concept implementation # we require the same ordering of qubits, but this restriction will # be shortly rem...
"""Run the OptimizeCliffords pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ blocks = [] prev_node = None cur_block = [] # Iterate over all nodes and collect consecutiv...
209
146
595
741
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,814
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/optimize_swap_before_measure.py
30,32
23,72
run
OptimizeSwapBeforeMeasure
40,72
32,72
class OptimizeSwapBeforeMeasure(TransformationPass): """Remove the swaps followed by measurement (and adapt the measurement). Transpiler pass to remove swaps in front of measurements by re-targeting the classical bit of the measure instruction. """ @control_flow.trivial_recurse def run(self, d...
class OptimizeSwapBeforeMeasure(TransformationPass): """Remove the swaps followed by measurement (and adapt the measurement). Transpiler pass to remove swaps in front of measurements by re-targeting the classical bit of the measure instruction. """ @control_flow.trivial_recurse def run(self, d...
swaps = dag.op_nodes(SwapGate) for swap in swaps[::-1]: if getattr(swap.op, "condition", None) is not None: continue final_successor = [] for successor in dag.descendants(swap): final_successor.append( isinstance(su...
"""Run the OptimizeSwapBeforeMeasure pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ swaps = dag.op_nodes(SwapGate) for swap in swaps[::-1]: if getattr(swap.op, "condition",...
114
155
472
627
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,815
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/remove_diagonal_gates_before_measure.py
41,43
34,70
run
RemoveDiagonalGatesBeforeMeasure
51,70
43,70
class RemoveDiagonalGatesBeforeMeasure(TransformationPass): """Remove diagonal gates (including diagonal 2Q gates) before a measurement. Transpiler pass to remove diagonal gates (like RZ, T, Z, etc) before a measurement. Including diagonal 2Q gates. """ @control_flow.trivial_recurse def run(se...
class RemoveDiagonalGatesBeforeMeasure(TransformationPass): """Remove diagonal gates (including diagonal 2Q gates) before a measurement. Transpiler pass to remove diagonal gates (like RZ, T, Z, etc) before a measurement. Including diagonal 2Q gates. """ @control_flow.trivial_recurse def run(se...
diagonal_1q_gates = (RZGate, ZGate, TGate, SGate, TdgGate, SdgGate, U1Gate) diagonal_2q_gates = (CZGate, CRZGate, CU1Gate, RZZGate) nodes_to_remove = set() for measure in dag.op_nodes(Measure): predecessor = next(dag.quantum_predecessors(measure)) if isinstance(...
"""Run the RemoveDiagonalGatesBeforeMeasure pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ diagonal_1q_gates = (RZGate, ZGate, TGate, SGate, TdgGate, SdgGate, U1Gate) diagonal_2q_gates ...
59
165
323
488
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,816
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/remove_final_reset.py
23,24
20,38
run
RemoveFinalReset
32,38
24,38
class RemoveFinalReset(TransformationPass): """Remove reset when it is the final instruction on a qubit wire.""" def run(self, dag): FILL_FUNC_BODY
class RemoveFinalReset(TransformationPass): """Remove reset when it is the final instruction on a qubit wire.""" def run(self, dag): """Run the RemoveFinalReset pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized D...
for output_node in dag.output_map.values(): if isinstance(output_node.wire, Qubit): pred = next(dag.predecessors(output_node)) if isinstance(pred, DAGOpNode) and isinstance(pred.op, Reset): dag.remove_op_node(pred) return dag
"""Run the RemoveFinalReset pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ for output_node in dag.output_map.values(): if isinstance(output_node.wire, Qubit): pred =...
19
105
96
201
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,817
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py
23,24
20,38
run
RemoveResetInZeroState
32,38
24,38
class RemoveResetInZeroState(TransformationPass): """Remove reset gate when the qubit is in zero state.""" def run(self, dag): FILL_FUNC_BODY
class RemoveResetInZeroState(TransformationPass): """Remove reset gate when the qubit is in zero state.""" def run(self, dag): """Run the RemoveResetInZeroState pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized D...
resets = dag.op_nodes(Reset) for reset in resets: predecessor = next(dag.predecessors(reset)) if isinstance(predecessor, DAGInNode): dag.remove_op_node(reset) return dag
"""Run the RemoveResetInZeroState pass on `dag`. Args: dag (DAGCircuit): the DAG to be optimized. Returns: DAGCircuit: the optimized DAG. """ resets = dag.op_nodes(Reset) for reset in resets: predecessor = next(dag.predecessors(reset)...
16
107
76
183
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,818
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py
33,35
24,48
run
ResetAfterMeasureSimplification
36,48
35,48
class ResetAfterMeasureSimplification(TransformationPass): """This pass replaces reset after measure with a conditional X gate. This optimization is suitable for use on IBM Quantum systems where the reset operation is performed by a measurement followed by a conditional x-gate. It might not be desirabl...
class ResetAfterMeasureSimplification(TransformationPass): """This pass replaces reset after measure with a conditional X gate. This optimization is suitable for use on IBM Quantum systems where the reset operation is performed by a measurement followed by a conditional x-gate. It might not be desirabl...
for node in dag.op_nodes(Measure): succ = next(dag.quantum_successors(node)) if isinstance(succ, DAGOpNode) and isinstance(succ.op, Reset): new_x = XGate().c_if(node.cargs[0], 1) new_dag = DAGCircuit() new_dag.add_qubits(node.qargs) ...
"""Run the pass on a dag.""" for node in dag.op_nodes(Measure): succ = next(dag.quantum_successors(node)) if isinstance(succ, DAGOpNode) and isinstance(succ.op, Reset): new_x = XGate().c_if(node.cargs[0], 1) new_dag = DAGCircuit() n...
32
129
221
350
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,820
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/template_matching/backward_match.py
100,101
80,112
pop_scenario
MatchingScenariosList
106,112
101,112
class MatchingScenariosList: """ Object to define a list of MatchingScenarios, with method to append and pop elements. """ def __init__(self): """ Create an empty MatchingScenariosList. """ self.matching_scenarios_list = [] def append_scenario(self, matching): ...
class MatchingScenariosList: """ Object to define a list of MatchingScenarios, with method to append and pop elements. """ def __init__(self): """ Create an empty MatchingScenariosList. """ self.matching_scenarios_list = [] def append_scenario(self, matching): ...
# Pop the first MatchingScenario and returns it first = self.matching_scenarios_list[0] self.matching_scenarios_list.pop(0) return first
""" Pop the first scenario of the list. Returns: MatchingScenarios: a scenario of match. """ # Pop the first MatchingScenario and returns it first = self.matching_scenarios_list[0] self.matching_scenarios_list.pop(0) return first
14
203
60
263
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,822
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/template_matching/maximal_matches.py
55,56
39,78
run_maximal_matches
MaximalMatches
59,78
56,78
class MaximalMatches: """ Class MaximalMatches allows to sort and store the maximal matches from the list of matches obtained with the template matching algorithm. """ def __init__(self, template_matches): """ Initialize MaximalMatches with the necessary arguments. Args: ...
class MaximalMatches: """ Class MaximalMatches allows to sort and store the maximal matches from the list of matches obtained with the template matching algorithm. """ def __init__(self, template_matches): """ Initialize MaximalMatches with the necessary arguments. Args: ...
self.max_match_list = [ Match( sorted(self.template_matches[0].match), self.template_matches[0].qubit, self.template_matches[0].clbit, ) ] for matches in self.template_matches[1::]: present = False ...
""" Method that extracts and stores maximal matches in decreasing length order. """ self.max_match_list = [ Match( sorted(self.template_matches[0].match), self.template_matches[0].qubit, self.template_matches[0].clbit, ...
43
168
204
372
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,824
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/template_matching/template_substitution.py
51,52
28,61
has_parameters
SubstitutionConfig
53,61
52,61
class SubstitutionConfig: """ Class to store the configuration of a given match substitution, which circuit gates, template gates, qubits, and clbits and predecessors of the match in the circuit. """ def __init__( self, circuit_config, template_config, pred_block...
class SubstitutionConfig: """ Class to store the configuration of a given match substitution, which circuit gates, template gates, qubits, and clbits and predecessors of the match in the circuit. """ def __init__( self, circuit_config, template_config, pred_block...
for node in self.template_dag_dep.get_nodes(): for param in node.op.params: if isinstance(param, ParameterExpression): return True return False
"""Ensure that the template does not have parameters.""" for node in self.template_dag_dep.get_nodes(): for param in node.op.params: if isinstance(param, ParameterExpression): return True return False
15
229
59
288
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,826
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/optimization/template_optimization.py
89,90
42,159
run
TemplateOptimization
99,159
90,159
class TemplateOptimization(TransformationPass): """ Class for the template optimization pass. """ def __init__( self, template_list=None, heuristics_qubits_param=None, heuristics_backward_param=None, user_cost_dict=None, ): """ Args: ...
class TemplateOptimization(TransformationPass): """ Class for the template optimization pass. """ def __init__( self, template_list=None, heuristics_qubits_param=None, heuristics_backward_param=None, user_cost_dict=None, ): """ Args: ...
circuit_dag = dag circuit_dag_dep = dag_to_dagdependency(circuit_dag) for template in self.template_list: if not isinstance(template, (QuantumCircuit, DAGDependency)): raise TranspilerError("A template is a Quantumciruit or a DAGDependency.") if len(temp...
""" Args: dag(DAGCircuit): DAG circuit. Returns: DAGCircuit: optimized DAG circuit. Raises: TranspilerError: If the template has not the right form or if the output circuit acts differently as the input circuit. """ circuit...
118
737
588
1,325
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,827
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/algorithms/token_swapper.py
82,85
43,106
map
ApproximateTokenSwapper
102,106
85,106
class ApproximateTokenSwapper: """A class for computing approximate solutions to the Token Swapping problem. Internally caches the graph and associated datastructures for re-use. """ def __init__(self, graph: rx.PyGraph, seed: int | np.random.Generator | None = None) -> None: """Construct an A...
class ApproximateTokenSwapper: """A class for computing approximate solutions to the Token Swapping problem. Internally caches the graph and associated datastructures for re-use. """ def __init__(self, graph: rx.PyGraph, seed: int | np.random.Generator | None = None) -> None: """Construct an A...
# Since integer seed is used in rustworkx, take random integer from np.random.randint # and use that for the seed. seed = self.seed.integers(1, 10000) return rx.graph_token_swapper(self.graph, mapping, trials, seed, parallel_threshold)
"""Perform an approximately optimal Token Swapping algorithm to implement the permutation. Supports partial mappings (i.e. not-permutations) for graphs with missing tokens. Based on the paper: Approximation and Hardness for Token Swapping by Miltzow et al. (2016) ArXiV: https://arxiv.o...
30
671
85
756
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,828
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/algorithms/util.py
44,49
1,104
swap_permutation
56,74
49,74
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
for swap_step in swaps: for sw1, sw2 in swap_step: # Take into account non-existent keys. val1: _V | None = None val2: _V | None = None if allow_missing_keys: val1 = mapping.pop(sw1, None) val2 = mapping.pop(sw2, None) ...
"""Given a circuit of swaps, apply them to the permutation (in-place). Args: swaps: param mapping: A mapping of Keys to Values, where the Keys are being swapped. mapping: The permutation to have swaps applied to. allow_missing_keys: Whether to allow swaps of missing keys in mapping. """ ...
65
973
189
1,162
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,829
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/basic_swap.py
49,50
24,167
run
BasicSwap
62,126
50,126
class BasicSwap(TransformationPass): """Map (with minimum effort) a DAGCircuit onto a ``coupling_map`` adding swap gates. The basic mapper is a minimum effort to insert swap gates to map the DAG onto a coupling map. When a cx is not in the coupling map possibilities, it inserts one or more swaps in fro...
class BasicSwap(TransformationPass): """Map (with minimum effort) a DAGCircuit onto a ``coupling_map`` adding swap gates. The basic mapper is a minimum effort to insert swap gates to map the DAG onto a coupling map. When a cx is not in the coupling map possibilities, it inserts one or more swaps in fro...
if self.fake_run: return self._fake_run(dag) new_dag = dag.copy_empty_like() if self.coupling_map is None: raise TranspilerError("BasicSwap cannot run with coupling_map=None") if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise Transpi...
"""Run the BasicSwap pass on `dag`. Args: dag (DAGCircuit): DAG to map. Returns: DAGCircuit: A mapped DAG. Raises: TranspilerError: if the coupling map or the layout are not compatible with the DAG, or if the ``coupling_map=None``. ...
182
888
825
1,713
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,831
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py
115,116
29,142
_decompose_to_2q
FindCommutingPauliEvolutions
125,142
116,142
class FindCommutingPauliEvolutions(TransformationPass): """Finds :class:`.PauliEvolutionGate`s where the operators, that are evolved, all commute.""" def run(self, dag: DAGCircuit) -> DAGCircuit: """Check for :class:`.PauliEvolutionGate`s where the summands all commute. Args: The D...
class FindCommutingPauliEvolutions(TransformationPass): """Finds :class:`.PauliEvolutionGate`s where the operators, that are evolved, all commute.""" def run(self, dag: DAGCircuit) -> DAGCircuit: """Check for :class:`.PauliEvolutionGate`s where the summands all commute. Args: The D...
sub_dag = dag.copy_empty_like() required_paulis = { self._pauli_to_edge(pauli): (pauli, coeff) for pauli, coeff in zip(op.operator.paulis, op.operator.coeffs) } for edge, (pauli, coeff) in required_paulis.items(): qubits = [dag.qubits[edge[0]], dag....
"""Decompose the SparsePauliOp into two-qubit. Args: dag: The dag needed to get access to qubits. op: The operator with all the Pauli terms we need to apply. Returns: A dag made of two-qubit :class:`.PauliEvolutionGate`. """ sub_dag = dag.cop...
40
1,052
227
1,279
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,833
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/layout_transformation.py
75,76
25,119
run
LayoutTransformation
88,119
76,119
class LayoutTransformation(TransformationPass): """Adds a Swap circuit for a given (partial) permutation to the circuit. This circuit is found by a 4-approximation algorithm for Token Swapping. More details are available in the routing code. """ def __init__( self, coupling_map: Co...
class LayoutTransformation(TransformationPass): """Adds a Swap circuit for a given (partial) permutation to the circuit. This circuit is found by a 4-approximation algorithm for Token Swapping. More details are available in the routing code. """ def __init__( self, coupling_map: Co...
if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("LayoutTransform runs on physical circuits only") if len(dag.qubits) > len(self.coupling_map.physical_qubits): raise TranspilerError("The layout does not match the amount of qubits in the DAG") ...
"""Apply the specified partial permutation to the circuit. Args: dag (DAGCircuit): DAG to transform the layout of. Returns: DAGCircuit: The DAG with transformed layout. Raises: TranspilerError: if the coupling map or the layout are not compatible wi...
119
633
456
1,089
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,835
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/lookahead_swap.py
108,109
50,190
run
LookaheadSwap
120,190
109,190
class LookaheadSwap(TransformationPass): """Map input circuit onto a backend topology via insertion of SWAPs. Implementation of Sven Jandura's swap mapper submission for the 2018 Qiskit Developer Challenge, adapted to integrate into the transpiler architecture. The role of the swapper pass is to modif...
class LookaheadSwap(TransformationPass): """Map input circuit onto a backend topology via insertion of SWAPs. Implementation of Sven Jandura's swap mapper submission for the 2018 Qiskit Developer Challenge, adapted to integrate into the transpiler architecture. The role of the swapper pass is to modif...
if self.coupling_map is None: raise TranspilerError("LookaheadSwap cannot run with coupling_map=None") if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("Lookahead swap runs on physical circuits only") number_of_available_qubits = len(se...
"""Run the LookaheadSwap pass on `dag`. Args: dag (DAGCircuit): the directed acyclic graph to be mapped Returns: DAGCircuit: A dag mapped to be compatible with the coupling_map in the property_set. Raises: TranspilerError: if the coupl...
183
900
797
1,697
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,836
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/routing/utils.py
19,20
1,36
get_swap_map_dag
22,36
20,36
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("layout transformation runs on physical circuits only") if len(dag.qubits) > len(coupling_map.physical_qubits): raise TranspilerError("The layout does not match the amount of qubits in the DAG") token_swapper =...
"""Get the circuit of swaps to go from from_layout to to_layout, and the physical qubits (integers) that the swap circuit should be applied on.""" if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("layout transformation runs on physical circuits only") if len(dag....
117
263
339
602
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,837
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/alap.py
40,41
23,155
run
ALAPSchedule
53,155
41,155
class ALAPSchedule(BaseSchedulerTransform): """ALAP Scheduling pass, which schedules the **stop** time of instructions as late as possible. See :class:`~qiskit.transpiler.passes.scheduling.base_scheduler.BaseSchedulerTransform` for the detailed behavior of the control flow operation, i.e. ``c_if``. """...
class ALAPSchedule(BaseSchedulerTransform): """ALAP Scheduling pass, which schedules the **stop** time of instructions as late as possible. See :class:`~qiskit.transpiler.passes.scheduling.base_scheduler.BaseSchedulerTransform` for the detailed behavior of the control flow operation, i.e. ``c_if``. """...
if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("ALAP schedule runs on physical circuits only") time_unit = self.property_set["time_unit"] new_dag = DAGCircuit() for qreg in dag.qregs.values(): new_dag.add_qreg(qreg) for ...
"""Run the ALAPSchedule pass on `dag`. Args: dag (DAGCircuit): DAG to schedule. Returns: DAGCircuit: A scheduled DAG. Raises: TranspilerError: if the circuit is not mapped on physical qubits. TranspilerError: if conditional bit is added ...
420
314
1,561
1,875
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,840
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/alignments/check_durations.py
53,54
20,79
run
InstructionDurationCheck
59,79
54,79
class InstructionDurationCheck(AnalysisPass): """Duration validation pass for reschedule. This pass investigates the input quantum circuit and checks if the circuit requires rescheduling for execution. Note that this pass can be triggered without scheduling. This pass only checks the duration of delay ...
class InstructionDurationCheck(AnalysisPass): """Duration validation pass for reschedule. This pass investigates the input quantum circuit and checks if the circuit requires rescheduling for execution. Note that this pass can be triggered without scheduling. This pass only checks the duration of delay ...
self.property_set["reschedule_required"] = False # Rescheduling is not necessary if self.acquire_align == 1 and self.pulse_align == 1: return # Check delay durations for delay_node in dag.op_nodes(Delay): dur = delay_node.op.duration if not (...
"""Run duration validation passes. Args: dag: DAG circuit to check instruction durations. """ self.property_set["reschedule_required"] = False # Rescheduling is not necessary if self.acquire_align == 1 and self.pulse_align == 1: return #...
78
429
248
677
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,841
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py
69,70
22,106
run
ValidatePulseGates
81,106
70,106
class ValidatePulseGates(AnalysisPass): """Check custom gate length. This is a control electronics aware analysis pass. Quantum gates (instructions) are often implemented with shaped analog stimulus signals. These signals may be digitally stored in the waveform memory of the control electronics an...
class ValidatePulseGates(AnalysisPass): """Check custom gate length. This is a control electronics aware analysis pass. Quantum gates (instructions) are often implemented with shaped analog stimulus signals. These signals may be digitally stored in the waveform memory of the control electronics an...
if self.granularity == 1 and self.min_length == 1: # we can define arbitrary length pulse with dt resolution return for gate, insts in dag.calibrations.items(): for qubit_param_pair, schedule in insts.items(): for _, inst in schedule.instructions: ...
"""Run the pulse gate validation attached to ``dag``. Args: dag: DAG to be validated. Returns: DAGCircuit: DAG with consistent timing and op nodes annotated with duration. Raises: TranspilerError: When pulse gate violate pulse controller constraints...
136
599
347
946
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,848
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/padding/pad_delay.py
66,75
23,80
_pad
PadDelay
75,80
75,80
class PadDelay(BasePadding): """Padding idle time with Delay instructions. Consecutive delays will be merged in the output of this pass. .. code-block:: python durations = InstructionDurations([("x", None, 160), ("cx", None, 800)]) qc = QuantumCircuit(2) qc.delay(100, 0) ...
class PadDelay(BasePadding): """Padding idle time with Delay instructions. Consecutive delays will be merged in the output of this pass. .. code-block:: python durations = InstructionDurations([("x", None, 160), ("cx", None, 800)]) qc = QuantumCircuit(2) qc.delay(100, 0) ...
if not self.fill_very_end and isinstance(next_node, DAGOutNode): return time_interval = t_end - t_start self._apply_scheduled_op(dag, t_start, Delay(time_interval, dag.unit), qubit)
if not self.fill_very_end and isinstance(next_node, DAGOutNode): return time_interval = t_end - t_start self._apply_scheduled_op(dag, t_start, Delay(time_interval, dag.unit), qubit)
17
581
78
659
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,849
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/scheduling/alap.py
28,29
20,128
run
ALAPScheduleAnalysis
41,128
29,128
class ALAPScheduleAnalysis(BaseScheduler): """ALAP Scheduling pass, which schedules the **stop** time of instructions as late as possible. See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler` module documentation for the detailed behavior of the control flow operation, i.e. ``c_if``....
class ALAPScheduleAnalysis(BaseScheduler): """ALAP Scheduling pass, which schedules the **stop** time of instructions as late as possible. See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler` module documentation for the detailed behavior of the control flow operation, i.e. ``c_if``....
if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("ALAP schedule runs on physical circuits only") conditional_latency = self.property_set.get("conditional_latency", 0) clbit_write_latency = self.property_set.get("clbit_write_latency", 0) node...
"""Run the ALAPSchedule pass on `dag`. Args: dag (DAGCircuit): DAG to schedule. Returns: DAGCircuit: A scheduled DAG. Raises: TranspilerError: if the circuit is not mapped on physical qubits. TranspilerError: if conditional bit is added ...
388
214
1,355
1,569
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,850
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/scheduling/asap.py
28,29
20,132
run
ASAPScheduleAnalysis
41,132
29,132
class ASAPScheduleAnalysis(BaseScheduler): """ASAP Scheduling pass, which schedules the start time of instructions as early as possible. See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler` module documentation for the detailed behavior of the control flow operation, i.e. ``c_if``. ...
class ASAPScheduleAnalysis(BaseScheduler): """ASAP Scheduling pass, which schedules the start time of instructions as early as possible. See the :ref:`scheduling_stage` section in the :mod:`qiskit.transpiler` module documentation for the detailed behavior of the control flow operation, i.e. ``c_if``. ...
if len(dag.qregs) != 1 or dag.qregs.get("q", None) is None: raise TranspilerError("ASAP schedule runs on physical circuits only") conditional_latency = self.property_set.get("conditional_latency", 0) clbit_write_latency = self.property_set.get("clbit_write_latency", 0) node...
"""Run the ASAPSchedule pass on `dag`. Args: dag (DAGCircuit): DAG to schedule. Returns: DAGCircuit: A scheduled DAG. Raises: TranspilerError: if the circuit is not mapped on physical qubits. TranspilerError: if conditional bit is added ...
366
212
1,380
1,592
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,851
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py
59,64
27,90
_get_node_duration
BaseScheduler
65,88
64,88
class BaseScheduler(AnalysisPass): """Base scheduler pass.""" CONDITIONAL_SUPPORTED = (Gate, Delay) def __init__(self, durations: InstructionDurations = None, target: Target = None): """Scheduler initializer. Args: durations: Durations of instructions to be used in scheduling ...
class BaseScheduler(AnalysisPass): """Base scheduler pass.""" CONDITIONAL_SUPPORTED = (Gate, Delay) def __init__(self, durations: InstructionDurations = None, target: Target = None): """Scheduler initializer. Args: durations: Durations of instructions to be used in scheduling ...
indices = [dag.find_bit(qarg).index for qarg in node.qargs] if dag.has_calibration_for(node): # If node has calibration, this value should be the highest priority cal_key = tuple(indices), tuple(float(p) for p in node.op.params) duration = dag.calibrations[node.op.na...
"""A helper method to get duration from node or calibration.""" indices = [dag.find_bit(qarg).index for qarg in node.qargs] if dag.has_calibration_for(node): # If node has calibration, this value should be the highest priority cal_key = tuple(indices), tuple(float(p) for...
88
398
283
681
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,852
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py
57,58
18,65
run
SetIOLatency
63,65
58,65
class SetIOLatency(AnalysisPass): """Set IOLatency information to the input circuit. The ``clbit_write_latency`` and ``conditional_latency`` are added to the property set of pass manager. This information can be shared among the passes that perform scheduling on instructions acting on classical registe...
class SetIOLatency(AnalysisPass): """Set IOLatency information to the input circuit. The ``clbit_write_latency`` and ``conditional_latency`` are added to the property set of pass manager. This information can be shared among the passes that perform scheduling on instructions acting on classical registe...
self.property_set["conditional_latency"] = self._conditional_latency self.property_set["clbit_write_latency"] = self._clbit_write_latency
"""Add IO latency information. Args: dag: Input DAG circuit. """ self.property_set["conditional_latency"] = self._conditional_latency self.property_set["clbit_write_latency"] = self._clbit_write_latency
6
492
50
542
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,853
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/scheduling/time_unit_conversion.py
56,57
24,160
run
TimeUnitConversion
68,115
57,115
class TimeUnitConversion(TransformationPass): """Choose a time unit to be used in the following time-aware passes, and make all circuit time units consistent with that. This pass will add a :attr:`.Instruction.duration` metadata to each op whose duration is known which will be used by subsequent schedu...
class TimeUnitConversion(TransformationPass): """Choose a time unit to be used in the following time-aware passes, and make all circuit time units consistent with that. This pass will add a :attr:`.Instruction.duration` metadata to each op whose duration is known which will be used by subsequent schedu...
inst_durations = self._update_inst_durations(dag) # Choose unit if inst_durations.dt is not None: time_unit = "dt" else: # Check what units are used in delays and other instructions: dt or SI or mixed units_delay = self._units_used_in_delays(dag) ...
"""Run the TimeUnitAnalysis pass on `dag`. Args: dag (DAGCircuit): DAG to be checked. Returns: DAGCircuit: DAG with consistent timing and op nodes annotated with duration. Raises: TranspilerError: if the units are not unifiable """ ...
175
976
524
1,500
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,854
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/aqc_plugin.py
111,112
29,154
run
AQCSynthesisPlugin
112,154
112,154
class AQCSynthesisPlugin(UnitarySynthesisPlugin): """ An AQC-based Qiskit unitary synthesis plugin. This plugin is invoked by :func:`~.compiler.transpile` when the ``unitary_synthesis_method`` parameter is set to ``"aqc"``. This plugin supports customization and additional parameters can be passed...
class AQCSynthesisPlugin(UnitarySynthesisPlugin): """ An AQC-based Qiskit unitary synthesis plugin. This plugin is invoked by :func:`~.compiler.transpile` when the ``unitary_synthesis_method`` parameter is set to ``"aqc"``. This plugin supports customization and additional parameters can be passed...
# Runtime imports to avoid the overhead of these imports for # plugin discovery and only use them if the plugin is run/used from scipy.optimize import minimize from qiskit.synthesis.unitary.aqc import AQC from qiskit.synthesis.unitary.aqc.cnot_structures import make_cnot_network...
# Runtime imports to avoid the overhead of these imports for # plugin discovery and only use them if the plugin is run/used from scipy.optimize import minimize from qiskit.synthesis.unitary.aqc import AQC from qiskit.synthesis.unitary.aqc.cnot_structures import make_cnot_network...
111
757
590
1,347
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,855
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
884,885
877,890
run
ACGSynthesisPermutation
886,890
885,890
class ACGSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the Alon, Chung, Graham method. This plugin name is :``permutation.acg`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ d...
class ACGSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the Alon, Chung, Graham method. This plugin name is :``permutation.acg`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ d...
decomposition = synth_permutation_acg(high_level_object.pattern) return decomposition
"""Run synthesis for the given Permutation.""" decomposition = synth_permutation_acg(high_level_object.pattern) return decomposition
5
150
32
182
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,856
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
673,674
666,679
run
AGSynthesisClifford
675,679
674,679
class AGSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Aaronson-Gottesman method. This plugin name is :``clifford.ag`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, hig...
class AGSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Aaronson-Gottesman method. This plugin name is :``clifford.ag`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, hig...
decomposition = synth_clifford_ag(high_level_object) return decomposition
"""Run synthesis for the given Clifford.""" decomposition = synth_clifford_ag(high_level_object) return decomposition
5
151
29
180
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,857
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
689,690
679,698
run
BMSynthesisClifford
691,698
690,698
class BMSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method. The method only works on Cliffords with at most 3 qubits, for which it constructs the optimal CX cost decomposition. This plugin name is :``clifford.bm`` which can be used as the key on...
class BMSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method. The method only works on Cliffords with at most 3 qubits, for which it constructs the optimal CX cost decomposition. This plugin name is :``clifford.bm`` which can be used as the key on...
if high_level_object.num_qubits <= 3: decomposition = synth_clifford_bm(high_level_object) else: decomposition = None return decomposition
"""Run synthesis for the given Clifford.""" if high_level_object.num_qubits <= 3: decomposition = synth_clifford_bm(high_level_object) else: decomposition = None return decomposition
13
183
57
240
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,858
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
871,872
864,877
run
BasicSynthesisPermutation
873,877
872,877
class BasicSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on sorting. This plugin name is :``permutation.basic`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, high_l...
class BasicSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on sorting. This plugin name is :``permutation.basic`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, high_l...
decomposition = synth_permutation_basic(high_level_object.pattern) return decomposition
"""Run synthesis for the given Permutation.""" decomposition = synth_permutation_basic(high_level_object.pattern) return decomposition
5
142
31
173
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,859
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
660,661
649,666
run
DefaultSynthesisClifford
662,666
661,666
class DefaultSynthesisClifford(HighLevelSynthesisPlugin): """The default clifford synthesis plugin. For N <= 3 qubits this is the optimal CX cost decomposition by Bravyi, Maslov. For N > 3 qubits this is done using the general non-optimal greedy compilation routine from reference by Bravyi, Hu, Maslov,...
class DefaultSynthesisClifford(HighLevelSynthesisPlugin): """The default clifford synthesis plugin. For N <= 3 qubits this is the optimal CX cost decomposition by Bravyi, Maslov. For N > 3 qubits this is done using the general non-optimal greedy compilation routine from reference by Bravyi, Hu, Maslov,...
decomposition = synth_clifford_full(high_level_object) return decomposition
"""Run synthesis for the given Clifford.""" decomposition = synth_clifford_full(high_level_object) return decomposition
5
208
29
237
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,860
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
748,749
741,754
run
DefaultSynthesisLinearFunction
750,754
749,754
class DefaultSynthesisLinearFunction(HighLevelSynthesisPlugin): """The default linear function synthesis plugin. This plugin name is :``linear_function.default`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, ...
class DefaultSynthesisLinearFunction(HighLevelSynthesisPlugin): """The default linear function synthesis plugin. This plugin name is :``linear_function.default`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ def run(self, ...
decomposition = synth_cnot_count_full_pmh(high_level_object.linear) return decomposition
"""Run synthesis for the given LinearFunction.""" decomposition = synth_cnot_count_full_pmh(high_level_object.linear) return decomposition
5
138
35
173
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,861
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
706,707
698,712
run
GreedySynthesisClifford
708,712
707,712
class GreedySynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the greedy synthesis Bravyi-Hu-Maslov-Shaydulin method. This plugin name is :``clifford.greedy`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynth...
class GreedySynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the greedy synthesis Bravyi-Hu-Maslov-Shaydulin method. This plugin name is :``clifford.greedy`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynth...
decomposition = synth_clifford_greedy(high_level_object) return decomposition
"""Run synthesis for the given Clifford.""" decomposition = synth_clifford_greedy(high_level_object) return decomposition
5
165
30
195
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,862
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
263,264
183,269
set_methods
HLSConfig
266,269
264,269
class HLSConfig: """The high-level-synthesis config allows to specify a list of "methods" used by :class:`~.HighLevelSynthesis` transformation pass to synthesize different types of higher-level objects. A higher-level object is an object of type :class:`~.Operation` (e.g., :class:`.Clifford` or :cl...
class HLSConfig: """The high-level-synthesis config allows to specify a list of "methods" used by :class:`~.HighLevelSynthesis` transformation pass to synthesize different types of higher-level objects. A higher-level object is an object of type :class:`~.Operation` (e.g., :class:`.Clifford` or :cl...
self.methods[hls_name] = hls_methods
"""Sets the list of synthesis methods for a given higher-level-object. This overwrites the lists of methods if also set previously.""" self.methods[hls_name] = hls_methods
3
1,173
21
1,194
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,864
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
771,772
754,799
run
KMSSynthesisLinearFunction
773,799
772,799
class KMSSynthesisLinearFunction(HighLevelSynthesisPlugin): """Linear function synthesis plugin based on the Kutin-Moulton-Smithline method. This plugin name is :``linear_function.kms`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. ...
class KMSSynthesisLinearFunction(HighLevelSynthesisPlugin): """Linear function synthesis plugin based on the Kutin-Moulton-Smithline method. This plugin name is :``linear_function.kms`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. ...
if not isinstance(high_level_object, LinearFunction): raise TranspilerError( "PMHSynthesisLinearFunction only accepts objects of type LinearFunction" ) use_inverted = options.get("use_inverted", False) use_transposed = options.get("use_transposed", False...
"""Run synthesis for the given LinearFunction.""" if not isinstance(high_level_object, LinearFunction): raise TranspilerError( "PMHSynthesisLinearFunction only accepts objects of type LinearFunction" ) use_inverted = options.get("use_inverted", False) ...
50
268
238
506
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,865
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
858,859
851,864
run
KMSSynthesisPermutation
860,864
859,864
class KMSSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the Kutin, Moulton, Smithline method. This plugin name is :``permutation.kms`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ ...
class KMSSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the Kutin, Moulton, Smithline method. This plugin name is :``permutation.kms`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. """ ...
decomposition = synth_permutation_depth_lnn_kms(high_level_object.pattern) return decomposition
"""Run synthesis for the given Permutation.""" decomposition = synth_permutation_depth_lnn_kms(high_level_object.pattern) return decomposition
5
154
37
191
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,866
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
735,736
726,741
run
LayerLnnSynthesisClifford
737,741
736,741
class LayerLnnSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method to synthesize Cliffords into layers, with each layer synthesized adhering to LNN connectivity. This plugin name is :``clifford.lnn`` which can be used as the key on an :class:`~...
class LayerLnnSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method to synthesize Cliffords into layers, with each layer synthesized adhering to LNN connectivity. This plugin name is :``clifford.lnn`` which can be used as the key on an :class:`~...
decomposition = synth_clifford_depth_lnn(high_level_object) return decomposition
"""Run synthesis for the given Clifford.""" decomposition = synth_clifford_depth_lnn(high_level_object) return decomposition
5
181
32
213
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,867
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
720,721
712,726
run
LayerSynthesisClifford
722,726
721,726
class LayerSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method to synthesize Cliffords into layers. This plugin name is :``clifford.layers`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevel...
class LayerSynthesisClifford(HighLevelSynthesisPlugin): """Clifford synthesis plugin based on the Bravyi-Maslov method to synthesize Cliffords into layers. This plugin name is :``clifford.layers`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevel...
decomposition = synth_clifford_layers(high_level_object) return decomposition
"""Run synthesis for the given Clifford.""" decomposition = synth_clifford_layers(high_level_object) return decomposition
5
162
29
191
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,868
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
822,823
799,851
run
PMHSynthesisLinearFunction
824,851
823,851
class PMHSynthesisLinearFunction(HighLevelSynthesisPlugin): """Linear function synthesis plugin based on the Patel-Markov-Hayes method. This plugin name is :``linear_function.pmh`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. The...
class PMHSynthesisLinearFunction(HighLevelSynthesisPlugin): """Linear function synthesis plugin based on the Patel-Markov-Hayes method. This plugin name is :``linear_function.pmh`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`. The...
if not isinstance(high_level_object, LinearFunction): raise TranspilerError( "PMHSynthesisLinearFunction only accepts objects of type LinearFunction" ) section_size = options.get("section_size", 2) use_inverted = options.get("use_inverted", False) ...
"""Run synthesis for the given LinearFunction.""" if not isinstance(high_level_object, LinearFunction): raise TranspilerError( "PMHSynthesisLinearFunction only accepts objects of type LinearFunction" ) section_size = options.get("section_size", 2) ...
55
408
264
672
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,869
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/high_level_synthesis.py
923,924
890,965
run
TokenSwapperSynthesisPermutation
925,965
924,965
class TokenSwapperSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the token swapper algorithm. This plugin name is :``permutation.token_swapper`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`...
class TokenSwapperSynthesisPermutation(HighLevelSynthesisPlugin): """The permutation synthesis plugin based on the token swapper algorithm. This plugin name is :``permutation.token_swapper`` which can be used as the key on an :class:`~.HLSConfig` object to use this method with :class:`~.HighLevelSynthesis`...
trials = options.get("trials", 5) seed = options.get("seed", 0) parallel_threshold = options.get("parallel_threshold", 50) pattern = high_level_object.pattern pattern_as_dict = {j: i for i, j in enumerate(pattern)} # When the plugin is called from the HighLevelSynthesi...
"""Run synthesis for the given Permutation.""" trials = options.get("trials", 5) seed = options.get("seed", 0) parallel_threshold = options.get("parallel_threshold", 50) pattern = high_level_object.pattern pattern_as_dict = {j: i for i, j in enumerate(pattern)} ...
180
526
491
1,017
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,870
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py
25,26
22,42
run
LinearFunctionsToPermutations
32,42
26,42
class LinearFunctionsToPermutations(TransformationPass): """Promotes linear functions to permutations when possible.""" def run(self, dag: DAGCircuit) -> DAGCircuit: FILL_FUNC_BODY
class LinearFunctionsToPermutations(TransformationPass): """Promotes linear functions to permutations when possible.""" def run(self, dag: DAGCircuit) -> DAGCircuit: """Run the LinearFunctionsToPermutations pass on `dag`. Args: dag: input dag. Returns: Output dag...
for node in dag.named_nodes("linear_function"): try: pattern = node.op.permutation_pattern() except CircuitError: continue permutation = PermutationGate(pattern) dag.substitute_node(node, permutation) return dag
"""Run the LinearFunctionsToPermutations pass on `dag`. Args: dag: input dag. Returns: Output dag with LinearFunctions synthesized. """ for node in dag.named_nodes("linear_function"): try: pattern = node.op.permutation_pattern(...
18
115
89
204
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,872
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/plugin.py
705,706
687,718
method_names
HighLevelSynthesisPluginManager
707,712
706,712
class HighLevelSynthesisPluginManager: """Class tracking the installed high-level-synthesis plugins.""" def __init__(self): self.plugins = stevedore.ExtensionManager( "qiskit.synthesis", invoke_on_load=True, propagate_map_exceptions=True ) # The registered plugin names shou...
class HighLevelSynthesisPluginManager: """Class tracking the installed high-level-synthesis plugins.""" def __init__(self): self.plugins = stevedore.ExtensionManager( "qiskit.synthesis", invoke_on_load=True, propagate_map_exceptions=True ) # The registered plugin names shou...
if op_name in self.plugins_by_op.keys(): return self.plugins_by_op[op_name] else: return []
"""Returns plugin methods for op_name.""" if op_name in self.plugins_by_op.keys(): return self.plugins_by_op[op_name] else: return []
9
325
46
371
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,874
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py
154,155
41,192
run
SolovayKitaev
166,192
155,192
class SolovayKitaev(TransformationPass): r"""Approximately decompose 1q gates to a discrete basis using the Solovay-Kitaev algorithm. The Solovay-Kitaev theorem [1] states that any single qubit gate can be approximated to arbitrary precision by a set of fixed single-qubit gates, if the set generates a dens...
class SolovayKitaev(TransformationPass): r"""Approximately decompose 1q gates to a discrete basis using the Solovay-Kitaev algorithm. The Solovay-Kitaev theorem [1] states that any single qubit gate can be approximated to arbitrary precision by a set of fixed single-qubit gates, if the set generates a dens...
for node in dag.op_nodes(): if not node.op.num_qubits == 1: continue # ignore all non-single qubit gates # we do not check the input matrix as we know it comes from a Qiskit gate, as this # we know it will generate a valid SU(2) matrix check_inpu...
"""Run the ``SolovayKitaev`` pass on `dag`. Args: dag: The input dag. Returns: Output dag with 1q gates synthesized in the discrete target basis. Raises: TranspilerError: if a gates does not have to_matrix """ for node in dag.op_node...
97
1,443
282
1,725
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,875
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py
273,274
192,298
run
SolovayKitaevSynthesis
274,298
274,298
class SolovayKitaevSynthesis(UnitarySynthesisPlugin): """A Solovay-Kitaev Qiskit unitary synthesis plugin. This plugin is invoked by :func:`~.compiler.transpile` when the ``unitary_synthesis_method`` parameter is set to ``"sk"``. This plugin supports customization and additional parameters can be pass...
class SolovayKitaevSynthesis(UnitarySynthesisPlugin): """A Solovay-Kitaev Qiskit unitary synthesis plugin. This plugin is invoked by :func:`~.compiler.transpile` when the ``unitary_synthesis_method`` parameter is set to ``"sk"``. This plugin supports customization and additional parameters can be pass...
# Runtime imports to avoid the overhead of these imports for # plugin discovery and only use them if the plugin is run/used config = options.get("config") or {} recursion_degree = config.get("recursion_degree", 3) # if we didn't yet construct the Solovay-Kitaev instance, which...
# Runtime imports to avoid the overhead of these imports for # plugin discovery and only use them if the plugin is run/used config = options.get("config") or {} recursion_degree = config.get("recursion_degree", 3) # if we didn't yet construct the Solovay-Kitaev instance, which...
110
778
355
1,133
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...