Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.14.2 #2145

Merged
merged 16 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- name: Build wheels
env:
AER_CMAKE_OPENMP_BUILD: 1
CIBW_SKIP: "pp* cp38-macosx_arm64 cp39-macosx_arm64"
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -133,7 +132,7 @@ jobs:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 30000
root-reserve-mb: 32000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
Expand All @@ -149,9 +148,10 @@ jobs:
python -m pip install cibuildwheel==2.16.2
- name: Build wheels
env:
CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && rpm -i cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all"
CIBW_BEFORE_BUILD : "pip cache purge && pip install nvidia-cuda-runtime-cu11 nvidia-cublas-cu11 nvidia-cusolver-cu11 nvidia-cusparse-cu11 cuquantum-cu11"
CIBW_BEFORE_ALL: "pip cache purge && yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && rpm -i cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all"
CIBW_BEFORE_BUILD : "pip install nvidia-cuda-runtime-cu11 nvidia-cublas-cu11 nvidia-cusolver-cu11 nvidia-cusparse-cu11 cuquantum-cu11"
CIBW_SKIP: "*-manylinux_i686 pp* cp36* cp37* *musllinux*"
CIBW_TEST_SKIP: "*"
CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu-cu11 QISKIT_AER_CUDA_MAJOR=11 CMAKE_VERBOSE_MAKEFILE=true AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7" AER_PYTHON_CUDA_ROOT=/opt/_internal AER_CIBUILD=true
CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair --exclude libcudart.so.11.0 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusparse.so.11 --exclude libcublas.so.11 --exclude libcublasLt.so.11 -w {dest_dir} {wheel}'
run: |
Expand All @@ -176,7 +176,7 @@ jobs:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 30000
root-reserve-mb: 32000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
Expand All @@ -192,9 +192,10 @@ jobs:
python -m pip install cibuildwheel==2.16.2
- name: Build wheels
env:
CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda-repo-rhel7-12-4-local-12.4.0_550.54.14-1.x86_64.rpm && rpm -i cuda-repo-rhel7-12-4-local-12.4.0_550.54.14-1.x86_64.rpm && yum clean all && yum -y install nvidia-driver-latest-dkms && yum -y install cuda-toolkit-12-4 && yum -y install openblas-devel && yum clean all"
CIBW_BEFORE_BUILD : "pip cache purge && pip install nvidia-cuda-runtime-cu12 nvidia-nvjitlink-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12"
CIBW_BEFORE_ALL: "pip cache purge && yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda-repo-rhel7-12-4-local-12.4.0_550.54.14-1.x86_64.rpm && rpm -i cuda-repo-rhel7-12-4-local-12.4.0_550.54.14-1.x86_64.rpm && yum clean all && yum -y install nvidia-driver-latest-dkms && yum -y install cuda-toolkit-12-4 && yum -y install openblas-devel && yum clean all"
CIBW_BEFORE_BUILD : "pip install nvidia-cuda-runtime-cu12 nvidia-nvjitlink-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12"
CIBW_SKIP: "*-manylinux_i686 pp* cp36* cp37* *musllinux*"
CIBW_TEST_SKIP: "*"
CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu QISKIT_AER_CUDA_MAJOR=12 CMAKE_VERBOSE_MAKEFILE=true AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7 9.0" AER_PYTHON_CUDA_ROOT=/opt/_internal AER_CIBUILD=true
CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair --exclude libcudart.so.12 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusolver.so.12 --exclude libcusolverMg.so.12 --exclude libcusparse.so.12 --exclude libcublas.so.12 --exclude libcublasLt.so.12 --exclude libnvJitLink.so.12 -w {dest_dir} {wheel}'
run: |
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ provider = QiskitRuntimeService(channel='ibm_quantum', token="set your own token
backend = provider.get_backend("ibm_kyoto")

# create sampler from the actual backend
sampler.from_backend(backend)
sampler = SamplerV2.from_backend(backend)

# run a sampler job on the parameterized circuits with noise model of the actual hardware
job3 = sampler.run([(pqc, theta1), (pqc2, theta2)])
bell_t = transpile(bell, AerSimulator(basis_gates=["ecr", "id", "rz", "sx"]), optimization_level=0)
job3 = sampler.run([bell_t], shots=128)
job_result = job3.result()
print(f"Parameterized for Bell circuit w/noise: {job_result[0].data.meas.get_counts()}")

print(f"counts for Bell circuit w/noise: {job_result[0].data.meas.get_counts()}")
```

## Contribution Guidelines
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
author = 'Qiskit Development Team'

# The short X.Y version
version = '0.14.1'
version = '0.14.2'
# The full version, including alpha/beta/rc tags
release = '0.14.1'
release = '0.14.2'

templates_path = ['_templates']

Expand Down
2 changes: 1 addition & 1 deletion qiskit_aer/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.1
0.14.2
37 changes: 30 additions & 7 deletions qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,43 @@ def _assemble_op(

aer_cond_expr = conditional_expr.accept(_AssembleExprImpl(circ)) if conditional_expr else None

# check if there is ctrl_state option
ctrl_state_pos = name.find("_o")
if ctrl_state_pos > 0:
gate_name = name[0:ctrl_state_pos]
else:
gate_name = name

num_of_aer_ops = 1
# fmt: off
if basis_gates is None and name in {
if (gate_name in {
"ccx", "ccz", "cp", "cswap", "csx", "cx", "cy", "cz", "delay", "ecr", "h",
"id", "mcp", "mcphase", "mcr", "mcrx", "mcry", "mcrz", "mcswap", "mcsx",
"mcu", "mcu1", "mcu2", "mcu3", "mcx", "mcx_gray", "mcy", "mcz", "p", "r",
"rx", "rxx", "ry", "ryy", "rz", "rzx", "rzz", "s", "sdg", "swap", "sx", "sxdg",
"t", "tdg", "u", "x", "y", "z", "u1", "u2", "u3", "cu", "cu1", "cu2", "cu3",
}:
aer_circ.gate(name, qubits, params, [], conditional_reg, aer_cond_expr,
label if label else name)
"crx", "cry", "crz",
}) and (basis_gates is None or gate_name in basis_gates):
if ctrl_state_pos > 0:
# Add x gates for ctrl qubits which state=0
ctrl_state = int(name[ctrl_state_pos+2:len(name)])
for i in range(len(qubits)):
if (ctrl_state >> i) & 1 == 0:
qubits_i = [qubits[len(qubits) - 1 - i]]
aer_circ.gate("x", qubits_i, params, [], conditional_reg, aer_cond_expr,
label if label else "x")
num_of_aer_ops += 1
aer_circ.gate(gate_name, qubits, params, [], conditional_reg, aer_cond_expr,
label if label else gate_name)
for i in range(len(qubits)):
if (ctrl_state >> i) & 1 == 0:
qubits_i = [qubits[len(qubits) - 1 - i]]
aer_circ.gate("x", qubits_i, params, [], conditional_reg, aer_cond_expr,
label if label else "x")
num_of_aer_ops += 1
else:
aer_circ.gate(name, qubits, params, [], conditional_reg, aer_cond_expr,
label if label else name)
elif name == "measure":
if is_conditional:
aer_circ.measure(qubits, clbits, clbits)
Expand Down Expand Up @@ -914,9 +940,6 @@ def _assemble_op(
aer_circ.mark(qubits, params)
elif name == "qerror_loc":
aer_circ.set_qerror_loc(qubits, label if label else name, conditional_reg, aer_cond_expr)
elif basis_gates is not None and name in basis_gates:
aer_circ.gate(name, qubits, params, [], conditional_reg, aer_cond_expr,
label if label else name)
elif name in ("for_loop", "while_loop", "if_else"):
raise AerError(
"control-flow instructions must be converted " f"to jump and mark instructions: {name}"
Expand Down
30 changes: 27 additions & 3 deletions qiskit_aer/backends/aer_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class AerSimulator(AerBackend):
than number of total shots.
This option is available for ``"statevector"``, ``"density_matrix"``
and ``"tensor_network"``.
WARNING: `shot_branching` option is unstable on MacOS currently

* ``shot_branching_sampling_enable`` (bool): This option enables/disables
applying sampling measure if the input circuit has all the measure
Expand Down Expand Up @@ -524,6 +525,7 @@ class AerSimulator(AerBackend):
"continue_loop",
"reset",
"switch_case",
"delay",
]
),
"density_matrix": sorted(
Expand All @@ -548,6 +550,7 @@ class AerSimulator(AerBackend):
"continue_loop",
"reset",
"switch_case",
"delay",
]
),
"matrix_product_state": sorted(
Expand All @@ -574,6 +577,7 @@ class AerSimulator(AerBackend):
"continue_loop",
"reset",
"switch_case",
"delay",
]
),
"stabilizer": sorted(
Expand All @@ -597,6 +601,7 @@ class AerSimulator(AerBackend):
"continue_loop",
"reset",
"switch_case",
"delay",
]
),
"extended_stabilizer": sorted(
Expand All @@ -606,6 +611,7 @@ class AerSimulator(AerBackend):
"roerror",
"save_statevector",
"reset",
"delay",
]
),
"unitary": sorted(
Expand All @@ -614,6 +620,7 @@ class AerSimulator(AerBackend):
"save_unitary",
"set_unitary",
"reset",
"delay",
]
),
"superop": sorted(
Expand All @@ -626,6 +633,7 @@ class AerSimulator(AerBackend):
"save_superop",
"set_superop",
"reset",
"delay",
]
),
"tensor_network": sorted(
Expand All @@ -649,6 +657,7 @@ class AerSimulator(AerBackend):
"set_density_matrix",
"reset",
"switch_case",
"delay",
]
),
}
Expand Down Expand Up @@ -744,6 +753,9 @@ def __init__(
backend_options=backend_options,
)

if "basis_gates" in backend_options.items():
self._check_basis_gates(backend_options["basis_gates"])

@classmethod
def _default_options(cls):
return Options(
Expand Down Expand Up @@ -897,11 +909,12 @@ def configuration(self):
config = copy.copy(self._configuration)
for key, val in self._options_configuration.items():
setattr(config, key, val)

method = getattr(self.options, "method", "automatic")

# Update basis gates based on custom options, config, method,
# and noise model
config.custom_instructions = self._CUSTOM_INSTR[
getattr(self.options, "method", "automatic")
]
config.custom_instructions = self._CUSTOM_INSTR[method]
config.basis_gates = self._cached_basis_gates + config.custom_instructions
return config

Expand Down Expand Up @@ -932,6 +945,9 @@ def set_option(self, key, value):
f" are: {self.available_methods()}"
)
self._set_method_config(value)
if key == "basis_gates":
self._check_basis_gates(value)

super().set_option(key, value)
if key in ["method", "noise_model", "basis_gates"]:
self._cached_basis_gates = self._basis_gates()
Expand Down Expand Up @@ -1046,3 +1062,11 @@ def _set_method_config(self, method=None):

self._set_configuration_option("description", description)
self._set_configuration_option("n_qubits", n_qubits)

def _check_basis_gates(self, basis_gates):
method = getattr(self.options, "method", "automatic")
# check if basis_gates contains non-supported gates
if method != "automatic":
for gate in basis_gates:
if gate not in self._BASIS_GATES[method]:
raise AerError(f"Invalid gate {gate} for simulation method {method}.")
9 changes: 1 addition & 8 deletions qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def target(self):

def set_max_qubits(self, max_qubits):
"""Set maximun number of qubits to be used for this backend."""
if self._target is not None:
if self._target is None:
self._configuration.n_qubits = max_qubits

def clear_options(self):
Expand Down Expand Up @@ -737,10 +737,3 @@ def __repr__(self):
name = self.__class__.__name__
display = f"'{self.name}'"
return f"{name}({display})"

def get_translation_stage_plugin(self):
"""use custom translation method to avoid gate exchange"""
if self._target is None:
return "aer_backend_plugin"
else:
return None
Loading
Loading