This commit adds a new file with the SHA1 of commits to ignore when
running git blame. This is important because of the recent adoption of
black and clang-format as our code formatting tool in #1630 we caused a
large amount of code churn to change the code formatting. However, using
the ignore file is a local opt-in feature for git and not something we
can enable globally by default. To facilitate this a section is added to
the bottom of the contributing guide to document how this file can be
used.
* add black and clang-format
* apply black and clang-format
* manually format codes that were not covered in black and clang-format
* add targets of clang-format and clean up tox.ini
* apply black with new configuration
* Update CONTRIBUTING.md
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
* Update .github/workflows/tests.yml
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
* reformat qiskit_aer, test, tools, and setup.py with length 100
---------
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Remove the redundant `wheel` dependency, as it is added by the backend automatically.
Listing it explicitly in the documentation was a historical mistake and has been fixed since,
see: [pypa/setuptools@f7d30a9](f7d30a9529).
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Now that qiskit-aer 0.12.0 is out the door we should bump the version
string on main to show that the version we're installing is newer
than what's been released. This commit opens development for 0.13.0
on the main branch.
* Prepare 0.12.0 release
This commit prepares for the 0.12.0 release. It moves the release notes
to a self contained directory for the release and updates the wording
and details of the release notes. Once this commit merges it should be
the tagged commit for the release.
* Add aer density matrix release note
* Apply suggestions from code review
Co-authored-by: Jake Lishman <jake@binhbar.com>
* Update releasenotes/notes/0.12/add-NoiseModel-from_backendproperties-1a3d6d976133a661.yaml
Co-authored-by: Jake Lishman <jake@binhbar.com>
* Update releasenotes/notes/0.12/tensor_network_gpu-e8eb3e40be3c35f7.yaml
* Use full path for intersphinx refs
---------
Co-authored-by: Jake Lishman <jake@binhbar.com>
With this commit, Aer simulates `QuantumCircuit` without converting it to QObj.
Previously, QObj is generated from `QuantumCircuit` objects in python, and then
C++ parses QObj to construct own circuit representation `AER::Circuit` for simulation.
Now, Aer binds this `AER::Circuit` with a python class `AerCircuit` and directly
generates from `QuantumCircuit` to `AerCircuit`. In addition, configuration for simulation
is changed from json to `AerConfig` that be bound to `AER::Config`.
This commit will improve performance of low-qubit simulation without any modification
of application codes.
* add AerCircuit and a path to run simulation without QObj
* Remove AerOp from AerCircuit
* fix lint errors
* revert qobj deprecation
* fix executor specification in AerBackend
* fix bugs in direct execution
* set final operation in AerCircuit
* fix lint errors
* use AerJob and add reno
* support directly-added qubits
* fix qobj execution
* fix qobj execution, contd.
* fix set state with a matrix
* inline malloc in matrix
* rename malloc_array in AER::Vector to resolve conflicts of signature
* rename methods to handle QuantumCircuit in AerBackend and deprecate AerJob.qobj()
* simplify AerCircuit
* avoid pickling of AerCircuit in assemble_circuits
* back _execute_circuits as abstract method
* introduce AER::Config to reduce JSON overheads for configuration
* fix a bug in get_value to load config
* enable AerConfig
* fix lint
* deprecate backend.run(validate=True) and clean codes in AerBackend
* add assertion in test_auto_method
* fix bugs in last commits
* correct test cases to test auto option
This commit adds a new CI job for publishing documentation on release.
Now that qiskit-aer is a self contained package with it's own namespace
the documentation build no longer needs to be combined into the main
qiskit docs anymore. As such this commit will enable aer ci to publish
built documentation for the project to:
https://qiskit.org/documentation/aer
on every release.
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Remove deprecated functions in noise module, e.g. NoiseModel.add_nonlocal_quantum_error, support of json-like input for QuantumError and standard_gates argument in many standard_errors.
Note that NoiseModel.from_dict is NOT removed exceptionally until alternative methods for serialize/deserialize NoiseModel objects are provided.
* Remove deprecated functions related with NoiseModel
* Remove deprecated functions in QuantumError
* Remove deprecated functions in utils
* Remove deprecated errorutils
* Remove deprecated arguments of functions in standard_erros
* Update tests not to use deprecated functions
* Lint
* Add release note
* Fix a mistake in warnings
* Improve release note
* Fix typos
* Move imports to the top level
* Fix docs and lint
---------
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Provides `AerDensityMatrix` that inherits `qiskit.quantum_info.states.DensityMatrix` with
Aer's kernel to calculate density matrix for a `QuantumCircuit`.
* Implement AerDensityMatrix and its tests
* Add a release note
* Add 2023 to Copyright
* Update explanation for data
* Fix lint errors
* Fix a lint error
* Set different seed for each sampling in AerDensityMatrix
This commit allows developers to build custom blas libtaries with BLA_VENDOR.
Previously, this BLA_VENDOR was always set to OpenBLAS and other blas
libraries were only set if OpenBLAS is not found.
* fix conan version
* add reno and allow the latest 1.X of Conan
* fix_blas_vendor: set properly a specified BLAS type
* fix_blas_vendor: add release note
---------
Co-authored-by: Hiroshi Horii <horii@jp.ibm.com>
Adds `initialize_density_matrix()` that allows `AerState` to initialize its density matrix.
This new function is not public and will not affect any public interface of Aer.
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Co-authored-by: Jun Doi <doichan@jp.ibm.com>
Co-authored-by: derwind <uncertainty_principle_ss@yahoo.co.jp>
Co-authored-by: Jake Lishman <jake@binhbar.com>
* Deprecate PulseSimulator backend
This commit deprecates the PulseSimulator backend for qiskit aer. For
the past several releases development on the pulse simulator has mostly
been frozen as the combined efforts for improving pulse level simulation
have been working on Qiskit Dynamics instead. This commit marks the
legacy PulseSimulator as deprecated and points existing users to Qiskit
Dynamics instead.
Closes#1722
* handle deprecation of pulse simulation in tests
---------
Co-authored-by: Hiroshi Horii <horii@jp.ibm.com>
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Specify a version of conan to build Aer with 1.X.
This is a quick fix to work around an issue related to API changes in conan 2.0.
* fix conan version
* add reno and allow the latest 1.X of Conan
Improves performance to convert parameter structure for Aer's bindings.
Aer uses index-based parameter-bindings that specify position of value
in gate array and parameter arrays. Qiskit uses a dict that associate
`Parameter`s with values. That is, Aer converts the dict-based to Aer's bindings
while resolving `ParamterExpression` by setting specified values.
Previously, the logic of this conversion was not efficient to resolve
`ParameterExpression` with redundant value specification. With this commit,
values are efficiently selected and performance to resolve `ParamterExpression`
is improved. Consequently, performance to simulate parameterized circuits will be
improved.
* improve _convert_circuit_binds
* add error message
* add test
Correct API break due to #1716 Add abelian_grouping to Estimator.
abelian_grouping an argument of the constructor of Estimator is ignored
if approximation an other argument of the constructor is True.
* AerError to warn
* warn to docstring
* rm warn
* add test
Add support of abelian_grouping for Estimator.
In default, Estimator groups the qubit-wise commutable observables to improve performance
by reducing the number of circuits to be simulated.
* Add abelian_grouping option.
* refactor
* refactor
* ignore W503 in pycodestyle
* add reno
---------
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Optimizes stabilizer simulator performance by changing data layout of its state.
Most of its data access become contiguous and CPU cache effectively work for it.
In addition, integer bit operations are refactored for performance.
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
`AerSimulator` supports `break_loop` and `continue_loop` instructions when used
as backends for the Terra `qiskit.compiler.transpile` function. The simulators already
did support these, but had just not been reporting it.
* support break_lopp and continue_loop
* add reno
* move break_loop and continue_loop from BASIS_GATES to _CUSTOM_INSTR
* Update releasenotes/notes/support_break_and_continue_gates-bf30316fcacd4b6b.yaml
* run break_loop and continue_loop instructions in test
---------
Co-authored-by: Jake Lishman <jake@binhbar.com>
`AerStatevector` supports `kraus` gate that applies one of the Kraus operators is applied randomly
to the quantum state based on the error probabilities.
* use more gates for AerState to call state_controller
* take assertion for parameter checking to use IndexError and take debug codes
* add more tests for AerStatevector
* fix lint
* update aer_runtime to use cu that has four parameters
* update seed for multiple calls of sample_memory
* correct seed_simulator update in AerStatevector
* support kraus in AerStatevector
* add release note
* slightly simplify test_kraus for AerStatevector
* Fix a test
- The correct answers are made from an error-free circuit
- Take global phases into account
* fix test for AerStatevector
* Update releasenotes/notes/support_kraus-ec31e636c6793b8c.yaml
---------
Co-authored-by: derwind <uncertainty_principle_ss@yahoo.co.jp>
Co-authored-by: Jake Lishman <jake@binhbar.com>
Changed the apply_measure algorithm so that it does not move the qubits to the sorted positions before measuring. Instead, we measure the qubits in the order of the current MPS structure and then sort the measurement outcomes as a post-process. Beside fixing the issue, this is expected to improve performance and enable more accurate representation of entangled states.
* Changed the apply_measure algorithm so that it does not move the qubits to the sorted order before measurement. Instead it sorts the measurement outcomes as a post-processing step.
* Update releasenotes/notes/mps_fix_apply_measure-84c29a728ae0e717.yaml
Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
* Update src/simulators/matrix_product_state/matrix_product_state_internal.cpp
Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
* Update src/simulators/matrix_product_state/matrix_product_state_internal.cpp
Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
* Added const to the new methods. Added comment to sort_qubits_by_ordering
* Added comments with examples
---------
Co-authored-by: Yael Ben-Haim <yaelbh@il.ibm.com>
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
`BaseSampler` and `BaseEstimator` in terra deprecated circuits, observables and
parameters as arguments for their constructors. They will be reduced in the next
release of terra (0.24). Because it took three months since terra started warning of
deprecation for these arguments, Aer reduces them from their arguments before
terra's PR (Qiskit/qiskit-terra#9480) is released.
* Remove deprecated methods and args in Primitives
* add reno
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Implement tensor network simulator by using cuTensorNet
Implementing general tensor network simulator for GPU accelerated by
NVIDIA's cuTensoNet APIs of cuQuantum SDK. Any quantum circuits can
be translated into tensor network and can be simulated.
This method supports both statevector and density matrix simulations,
noise simulation can be done by single shot with density matrix
if there is no save_statevector operation.
This method supports parallelization by multiple GPUs and MPI processes
by using tensor network slicing technique.
* fix aer_simulator.py
* return values in TensorNetContractorDummy
* Fix for cuQuantum 22.11.0
* remove dependencieis to shot branching
* fix test cases, remove remaining shot-branching options
* add release note, fix available_methods to handle tensor_network
* fix available_methods
* spdlog version
---------
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Guarantee np.ndarray contiguity
* Add __init__.py to run tests for terra.states
based on the approval in #1673
* Guarantee np.ndarray contiguity if not
* Install matplotlib for plot_state_qsphere according to CI log
* Addressed pylint's point (W0621)
* Install seaborn for plot_state_qsphere according to CI log
* Fix typo: Install seaborn for plot_state_qsphere according to CI log
* Fix suppressions for Jupyter warnings
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Add __init__.py to run tests for terra.states
* Update tests to follow https://github.com/Qiskit/qiskit-terra/pull/8273
* Install matplotlib for plot_state_qsphere according to CI log
* Install seaborn for plot_state_qsphere according to CI log
* Fix suppressions for Jupyter warnings
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Add classmethod from_backend_properties for NoiseModel
* Add test for NoiseModel.from_backend_propeties
* Delete deperecated arguments form from_backend_properties
* Shorten the document for :func:`from_backend_properties`
* Add release note for `from_backendproperties`
* Delete unncessary warning
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
* Delete unncessary warning
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
* Add type annotation for the definitiion of dt.
* Delete unnecessary the `with` clouse
* Change :func: to :meth:
* Delete devices limitation on the docstring of from_backend_poroperties
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
* Add the introduction of this new function at release note
* Correct the main document of from_backend_properties
* Add argument `dt` for `from_backend_properties`
The document is based
on https://qiskit.org/documentation/stubs/qiskit.providers.BackendV2.html#qiskit.providers.BackendV2.
* Correct docstring for Exception in `from_backend_properties`
* Add trucate_t2_value to get delay_pass in `from_backend_properties`
* format code
* change dt: float =0 to dt: Optional[float] = None
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
* Change document of the dafulat value of dt to None.
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
* Correct docstring to add the description of `dt`.
* Correct docstring to explicitly show the argument gate_lengths and dt is Optional.
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Batched shots execution uses classical registers on GPU memory, and memory space for creg is reserved before allocating chunks. To reserve this, bits count for classical register should be set before allocation, but bits count was not set correctly. This caused infinite loop to find available memory on GPU.
This fix set bits count of classical register before the allocation for batched shots execution.
* Fix creg bits is not set before reserving memory on GPU
* added release note
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* replaced IBMQ with IBM Quantum fixing #1633
* replaced IBMQ with IBM Quantum fixing #1633
* Update aer_simulator.py
* Fixed IBM QUANTUM to IBM Quantum
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Remove setup_requires and forced pip installs in setup.py
Executing manual `pip install` commands from within `setup.py` is
somewhat frowned upon from a Python packaging perspective. By far the
preferred mechanism now is to clearly state the build dependencies in a
non-code format (`pyproject.toml`), and let a PEP-517-compatible builder
handle virtual-environment isolation and dependency management.
We already had the dependencies declared statically, this commit just
removes the residual code in `setup.py`.
* Update CI build scripts
* Add missing build install
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Previously the root of the qiskit_aer we were exporing certain modules
and objects using relative imports to do this. However, the qiskit
package sets up a metaimporter to redirect imports from
qiskit.providers.aer to qiskit_aer (for backwards compatibility with the
old aer name) the source package for these relative imports can get
confused on subsequent imports if something also uses the legacy name
(which qiskit itself does on it's optional imports to aer, so that it
supports >1 version). While all the code functions correctly in this
case Python emits a warning saying the package __spec__ doesn't match
anymore. The simplest way to address these warnings is to use an
absoulte import with the package name in it so there is no ambiguity in
the source package on imports.
This commit makes that change to the root of the pacakge which fixes the
warnings. The only thing I'm not sure of is if any other relative
imports elsewhere in the qiskit_aer package will have the same problem
or if this is fixed by just updating the root package. We might need to
do further testing to check.
Fixes#1692
* Fix BackendV2 support in AerSimulator.from_backend()
This commit fixes supported for insantiating a AerSimulator object with
the from_backend() method using a BackendV2 instance. Previously this
method pre-emptively raised an AerError as the code wasn't present to
correctly handle creating an AerSimulator instance using the backend.
This commit fixes this so this no longer errors and works as expected.
Fixes#1617
* Use assertDictAlmostEqual in v2 tests
Currently, there are non-Python needed in the qiskit_aer package:
`VERSION.txt` and `instructions_table.csv`. These are included in the
wheel through the use of the `include_package_data=True` option to
`setup()`, but scikit-build, in a deviation from setuptools' behavior,
ends up including everything in `MANIFEST.in` when this option is used,
as reported
[here](https://github.com/scikit-build/scikit-build/issues/590). This
behavior results in many extraneous files being included in the wheel.
This PR works around this quirk by explicitly including the necessary
files with the `package_data` argument of `setup()` instead of using
`include_package_data`.
Closes#1457
* Add ECR gate support to aer simulators
This commit adds support for the ECR (echo cross resonance) gate as
described in [1] and [2] to aer. This is an entangling gate used on
some IBM backends and being able for aer to simulate is import to be
able to simulate those backends. Support for the gate is added to the
density matrix, statvector, super operator, and unitary simulators.
[1] https://arxiv.org/abs/2008.08571
[2] https://qiskit.org/documentation/stubs/qiskit.circuit.library.ECRGate.html
* Fix matrix definition
* Add tests
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
* Deprecate Python 3.7 support in Qiskit Aer
This commit deprecates Python 3.7 support. During the deprecation window
we will continue to fully support Python 3.7 and test it in CI, but it will
emit a warning that we will be removing support for 3.7 in the future to
inform users to upgrade to Python 3.8 or newer. The removal will occur
during a future release at some point over the summer as the upstream
Python EoL date is in June 2023. [1]
[1] https://devguide.python.org/versions/
* Fix lint
* Move comment before if block
* update seed for multiple calls of sample_memory
* correct seed_simulator update in AerStatevector
* set seed in AerState explicitly and reuse AerState in AerStatevector for sampling
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commits fixed a bug in NoiseModel.from_backend where using the temperature kwarg with
a non-default value would incorrectly compute the excited state population for the specified temperature.
Previously, there was an additional factor of 2 in the Boltzman distribution calculation leading to
an incorrect smaller value for the excited state population.
* Fix a bug in computation of excited population
* Improve reno
* Reword reno
`AerStatevector` wrongly assumed that methods of `AerState` support `mc*` instructions.
With this commit, `AerStatevector` use basic gates supported in specified method.
* use more gates for AerState to call state_controller
* take assertion for parameter checking to use IndexError and take debug codes
* add more tests for AerStatevector
* fix lint
* update aer_runtime to use cu that has four parameters
* Fix devide noise model from target
* Add release note
* Upgrade device noise models not to have errors on resets
* Revert the previous upgrade and fix the bug so that the behevior is the same as for backend v1
This commit allows construct of `AerStatevector` directly from Terra's `Statevector`.
* Support for initialization from Statevector
* Add release note
* Initialize with AerStatevector prior to Statevector
* add a test to initialize with AerStatevector
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>