Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Oct 3, 2023
2 parents 6826481 + 6131e31 commit c655640
Show file tree
Hide file tree
Showing 68 changed files with 1,229 additions and 625 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ version = "0.14.0"
features = ["rayon"]

[dependencies.indexmap]
version = "2.0.0"
version = "2.0.1"
features = ["rayon"]
2 changes: 1 addition & 1 deletion qiskit/algorithms/optimizers/spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SPSA(Optimizer):
SPSA can be used in the presence of noise, and it is therefore indicated in situations
involving measurement uncertainty on a quantum computation when finding a minimum.
If you are executing a variational algorithm using a Quantum ASseMbly Language (QASM)
If you are executing a variational algorithm using an OpenQASM
simulator or a real device, SPSA would be the most recommended choice among the optimizers
provided here.
Expand Down
4 changes: 2 additions & 2 deletions qiskit/assembler/assemble_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _assemble_circuit(
if calibrations:
config.calibrations = calibrations

# Convert conditionals from QASM-style (creg ?= int) to qobj-style
# Convert conditionals from OpenQASM-2-style (creg ?= int) to qobj-style
# (register_bit ?= 1), by assuming device has unlimited register slots
# (supported only for simulators). Map all measures to a register matching
# their clbit_index, create a new register slot for every conditional gate
Expand Down Expand Up @@ -213,7 +213,7 @@ def _extract_common_calibrations(
and delete them from their local experiments.
Args:
experiments: The list of Qasm experiments that are being assembled into one qobj
experiments: The list of OpenQASM experiments that are being assembled into one qobj
Returns:
The input experiments with modified calibrations, and common calibrations, if there
Expand Down
6 changes: 3 additions & 3 deletions qiskit/circuit/add_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def control(
if operation.name == "x" or (
isinstance(operation, controlledgate.ControlledGate) and operation.base_gate.name == "x"
):
controlled_circ.mct(q_control[:] + q_target[:-1], q_target[-1], q_ancillae)
controlled_circ.mcx(q_control[:] + q_target[:-1], q_target[-1], q_ancillae)
if operation.definition is not None and operation.definition.global_phase:
global_phase += operation.definition.global_phase
else:
Expand All @@ -126,7 +126,7 @@ def control(
for instruction in definition.data:
gate, qargs = instruction.operation, instruction.qubits
if gate.name == "x":
controlled_circ.mct(q_control, q_target[bit_indices[qargs[0]]], q_ancillae)
controlled_circ.mcx(q_control, q_target[bit_indices[qargs[0]]], q_ancillae)
elif gate.name == "rx":
controlled_circ.mcrx(
gate.definition.data[0].operation.params[0],
Expand Down Expand Up @@ -159,7 +159,7 @@ def control(
q_control[:] + [q_target[bit_indices[qargs[0]]]],
)
elif gate.name == "cx":
controlled_circ.mct(
controlled_circ.mcx(
q_control[:] + [q_target[bit_indices[qargs[0]]]],
q_target[bit_indices[qargs[1]]],
q_ancillae,
Expand Down
22 changes: 17 additions & 5 deletions qiskit/circuit/classicalfunction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
========
The classical function compiler provides the necessary tools to map a classical
irreversible functions into quantum circuits. Below is a simple example of
potentially irreversible functions into quantum circuits. Below is a simple example of
how to synthesize a simple boolean function defined using Python into a
QuantumCircuit:
Expand All @@ -34,10 +34,22 @@
def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
return (not a and b and not c and d)
quantum_circuit = grover_oracle.synth()
Following Qiskit's little-endian bit ordering convention, the left-most bit (`a`) is the most
significant bit and the right-most bit (`d`) is the least significant bit. The resulting
quantum_circuit = grover_oracle.synth(registerless=False)
quantum_circuit.draw('text')
a: ──o──
b: ──■──
c: ──o──
d: ──■──
┌─┴─┐
return: ┤ X ├
└───┘
Following Qiskit's little-endian bit ordering convention, the left-most bit (``a``) is the most
significant bit and the right-most bit (``d``) is the least significant bit.
Supplementary Information
=========================
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/controlflow/for_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def params(self, parameters):
)

# Consume indexset into a tuple unless it was provided as a range.
# Preserve ranges so that they can be exported as OpenQASM3 ranges.
# Preserve ranges so that they can be exported as OpenQASM 3 ranges.
indexset = indexset if isinstance(indexset, range) else tuple(indexset)

self._params = [indexset, loop_parameter, body]
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/arithmetic/weighted_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _build(self):
# - controlled by q_state[i]
circuit.x(qr_sum[j])
circuit.x(qr_carry[j - 1])
circuit.mct(
circuit.mcx(
[q_state, qr_sum[j], qr_carry[j - 1]],
qr_carry[j],
qr_control,
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/hamiltonian_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _define(self):
)
def qasm(self):
"""Raise an error, as QASM is not defined for the HamiltonianGate."""
raise CircuitError("HamiltonianGate has no QASM definition.")
raise CircuitError("HamiltonianGate has no OpenQASM 2 definition.")

def validate_parameter(self, parameter):
"""Hamiltonian parameter has to be an ndarray, operator or float."""
Expand Down
41 changes: 25 additions & 16 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,8 @@ def qasm(
interface for other serialisers in Qiskit.
Args:
formatted (bool): Return formatted Qasm string.
filename (str): Save Qasm to file with name 'filename'.
formatted (bool): Return formatted OpenQASM 2.0 string.
filename (str): Save OpenQASM 2.0 to file with name 'filename'.
encoding (str): Optionally specify the encoding to use for the
output file if ``filename`` is specified. By default this is
set to the system's default encoding (ie whatever
Expand All @@ -1634,7 +1634,7 @@ def qasm(
print(out, file=file)

if formatted:
_optionals.HAS_PYGMENTS.require_now("formatted OpenQASM 2 output")
_optionals.HAS_PYGMENTS.require_now("formatted OpenQASM 2.0 output")

import pygments
from pygments.formatters import ( # pylint: disable=no-name-in-module
Expand Down Expand Up @@ -2390,13 +2390,14 @@ def remove_final_measurements(self, inplace: bool = True) -> Optional["QuantumCi

@staticmethod
def from_qasm_file(path: str) -> "QuantumCircuit":
"""Take in a QASM file and generate a QuantumCircuit object.
"""Read an OpenQASM 2.0 program from a file and convert to an instance of
:class:`.QuantumCircuit`.
Args:
path (str): Path to the file for a QASM program
path (str): Path to the file for an OpenQASM 2 program
Return:
QuantumCircuit: The QuantumCircuit object for the input QASM
QuantumCircuit: The QuantumCircuit object for the input OpenQASM 2.
See also:
:func:`.qasm2.load`: the complete interface to the OpenQASM 2 importer.
Expand All @@ -2414,12 +2415,12 @@ def from_qasm_file(path: str) -> "QuantumCircuit":

@staticmethod
def from_qasm_str(qasm_str: str) -> "QuantumCircuit":
"""Take in a QASM string and generate a QuantumCircuit object.
"""Convert a string containing an OpenQASM 2.0 program to a :class:`.QuantumCircuit`.
Args:
qasm_str (str): A QASM program string
qasm_str (str): A string containing an OpenQASM 2.0 program.
Return:
QuantumCircuit: The QuantumCircuit object for the input QASM
QuantumCircuit: The QuantumCircuit object for the input OpenQASM 2
See also:
:func:`.qasm2.loads`: the complete interface to the OpenQASM 2 importer.
Expand Down Expand Up @@ -2955,6 +2956,10 @@ def ch(
CHGate(label=label, ctrl_state=ctrl_state), [control_qubit, target_qubit], []
)

@deprecate_func(
since="0.45.0",
additional_msg="Use QuantumCircuit.id as direct replacement.",
)
def i(self, qubit: QubitSpecifier) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.IGate`.
Expand All @@ -2966,9 +2971,7 @@ def i(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
from .library.standard_gates.i import IGate

return self.append(IGate(), [qubit], [])
return self.id(qubit)

def id(self, qubit: QubitSpecifier) -> InstructionSet: # pylint: disable=invalid-name
"""Apply :class:`~qiskit.circuit.library.IGate`.
Expand All @@ -2980,11 +2983,10 @@ def id(self, qubit: QubitSpecifier) -> InstructionSet: # pylint: disable=invali
Returns:
A handle to the instructions created.
See Also:
QuantumCircuit.i: the same function.
"""
return self.i(qubit)
from .library.standard_gates.i import IGate

return self.append(IGate(), [qubit], [])

def ms(self, theta: ParameterValueType, qubits: Sequence[QubitSpecifier]) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.MSGate`.
Expand Down Expand Up @@ -3555,6 +3557,10 @@ def cswap(
[],
)

@deprecate_func(
since="0.45.0",
additional_msg="Use QuantumCircuit.cswap as direct replacement.",
)
def fredkin(
self,
control_qubit: QubitSpecifier,
Expand Down Expand Up @@ -3775,6 +3781,7 @@ def cx(
CXGate(label=label, ctrl_state=ctrl_state), [control_qubit, target_qubit], []
)

@deprecate_func(since="0.45.0", additional_msg="Use QuantumCircuit.cx as direct replacement.")
def cnot(
self,
control_qubit: QubitSpecifier,
Expand Down Expand Up @@ -3848,6 +3855,7 @@ def ccx(
[],
)

@deprecate_func(since="0.45.0", additional_msg="Use QuantumCircuit.ccx as direct replacement.")
def toffoli(
self,
control_qubit1: QubitSpecifier,
Expand Down Expand Up @@ -3949,6 +3957,7 @@ def mcx(

return self.append(gate, control_qubits[:] + [target_qubit] + ancilla_qubits[:], [])

@deprecate_func(since="0.45.0", additional_msg="Use QuantumCircuit.mcx as direct replacement.")
def mct(
self,
control_qubits: Sequence[QubitSpecifier],
Expand Down
4 changes: 2 additions & 2 deletions qiskit/compiler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def assemble(
``n_qubits.``
schedule_los: Experiment level (ie circuit or schedule) LO frequency configurations for
qubit drive and measurement channels. These values override the job level values from
``default_qubit_los`` and ``default_meas_los``. Frequencies are in Hz. Settable for qasm
and pulse jobs.
``default_qubit_los`` and ``default_meas_los``. Frequencies are in Hz. Settable for
OpenQASM 2 and pulse jobs.
meas_level: Set the appropriate level of the measurement output for pulse experiments.
meas_return: Level of measurement data for the backend to return.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/converters/ast_to_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _process_node(self, node):
return None

def _gate_rules_to_qiskit_circuit(self, node, params):
"""From a gate definition in qasm, to a QuantumCircuit format."""
"""From a gate definition in OpenQASM, to a QuantumCircuit format."""
rules = []
qreg = QuantumRegister(node["n_bits"])
bit_args = {node["bits"][i]: q for i, q in enumerate(qreg)}
Expand Down
2 changes: 1 addition & 1 deletion qiskit/opflow/converters/pauli_basis_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def construct_cnot_chain(self, diag_pauli_op1: PauliOp, diag_pauli_op2: PauliOp)
cnots.swap(origin_anchor_bit, dest_anchor_bit)

# Need to do this or a Terra bug sometimes flips cnots. No time to investigate.
cnots.i(0)
cnots.id(0)

# Step 6)
for i in sig_in_dest_only_indices:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/providers/basicaer/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

"""Contains a (slow) Python simulator.
It simulates a qasm quantum circuit (an experiment) that has been compiled
It simulates an OpenQASM 2 quantum circuit (an experiment) that has been compiled
to run on the simulator. It is exponential in the number of qubits.
The simulator is run using
Expand Down Expand Up @@ -53,7 +53,7 @@


class QasmSimulatorPy(BackendV1):
"""Python implementation of a qasm simulator."""
"""Python implementation of an OpenQASM 2 simulator."""

MAX_QUBITS_MEMORY = int(log2(local_hardware_info()["memory"] * (1024**3) / 16))

Expand Down
Loading

0 comments on commit c655640

Please sign in to comment.