-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[unitaryHACK] Controlling the Insertion of Multi-Qubit Gates in the G…
…eneration of Random Circuits #12059 (#12483) * unitaryHACK Controlling the Insertion of Multi-Qubit Gates in the Generation of Random Circuits #12059 * Fixed linting issues * Fixed long lines and unused variable * Added requested changes * Removed unused imports * Added a test * Added the stochastic process comment and edited releasenotes * Update qiskit/circuit/random/utils.py * lint... --------- Co-authored-by: Sebastian Brandhofer <148463728+sbrandhsn@users.noreply.github.com>
- Loading branch information
1 parent
d18a74c
commit 0b1c8bf
Showing
3 changed files
with
201 additions
and
24 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
21 changes: 21 additions & 0 deletions
21
releasenotes/notes/extended-random-circuits-049b67cce39003f4.yaml
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,21 @@ | ||
--- | ||
features_circuits: | ||
- | | ||
The `random_circuit` function from `qiskit.circuit.random.utils` has a new feature where | ||
users can specify a distribution `num_operand_distribution` (a dict) that specifies the | ||
ratio of 1-qubit, 2-qubit, 3-qubit, and 4-qubit gates in the random circuit. For example, | ||
if `num_operand_distribution = {1: 0.25, 2: 0.25, 3: 0.25, 4: 0.25}` is passed to the function | ||
then the generated circuit will have approximately 25% of 1-qubit, 2-qubit, 3-qubit, and | ||
4-qubit gates (The order in which the dictionary is passed does not matter i.e. you can specify | ||
`num_operand_distribution = {3: 0.5, 1: 0.0, 4: 0.3, 2: 0.2}` and the function will still work | ||
as expected). Also it should be noted that the if `num_operand_distribution` is not specified | ||
then `max_operands` will default to 4 and a random circuit with a random gate distribution will | ||
be generated. If both `num_operand_distribution` and `max_operands` are specified at the same | ||
time then `num_operand_distribution` will be used to generate the random circuit. | ||
Example usage:: | ||
from qiskit.circuit.random import random_circuit | ||
circ = random_circuit(num_qubits=6, depth=5, num_operand_distribution = {1: 0.25, 2: 0.25, 3: 0.25, 4: 0.25}) | ||
circ.draw(output='mpl') | ||
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