forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance and randomness of
QuantumVolume
(Qiskit#12097)
* Improve performance and randomness of `QuantumVolume` This hugely improves the construction time of `QuantumVolume` circuits, in part by removing the previous behaviour of using low-entropy indiviual RNG instances for each SU4 matrix. Now that we need larger circuits, this would already have been a non-trivial biasing of the random outputs, but also, calling Scipy random variates in a loop is _much_ less efficient than vectorising the entire process in one go. Along with changes to the RNG, this commit also adds a faster path to `UnitaryGate` to shave off some useless repeated calculations (this can likely be used elsewhere in Qiskit) and reworks the `QuantumVolume` builder to use more efficient circuit construction methods. * Make test explicitly test reproducibility * Protect best-effort seed retrieval against old Numpy
- Loading branch information
1 parent
44cbb7c
commit c99f325
Showing
4 changed files
with
82 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
features_circuits: | ||
- | | ||
Construction time for :class:`.QuantumVolume` circuits has been significantly improved, on the | ||
order of 10x or a bit more. The internal SU4 gates will now also use more bits of randomness | ||
during their generation, leading to more representative volume circuits, especially at large | ||
widths and depths. | ||
- | | ||
:class:`.QuantumVolume` now has a ``flatten`` keyword argument. This defaults to ``False``, | ||
where the constructed circuit contains a single instruction that in turn contains the actual | ||
volume structure. If set ``True``, the circuit will directly have the volumetric SU4 matrices. | ||
- | | ||
:class:`.UnitaryGate` now accepts an optional ``num_qubits`` argument. The only effect of this | ||
is to skip the inference of the qubit count, which can be helpful for performance when many | ||
gates are being constructed. | ||
upgrade_circuits: | ||
- | | ||
The random-number usage of :class:`.QuantumVolume` has changed, so you will get a different | ||
circuit for a fixed seed between older versions of Qiskit and this version. The random-unitary | ||
generation now uses more bits of entropy, so large circuits will be less biased. | ||
- | | ||
The internal :class:`.UnitaryGate` instances in the definition of a :class:`.QuantumVolume` | ||
circuit will no longer have a :attr:`~.Instruction.label` field set. Previously this was set | ||
to the string ``su4_<seed>`` where ``<seed>`` was a three-digit number denoting the seed of an | ||
internal Numpy pRNG instance for that gate. Doing this was a serious performance problem, and | ||
the seed ought not to have been useful; if you need to retrieve the matrix from the gate, simply | ||
use the :meth:`.Gate.to_matrix` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters