Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.87k stars 2.3k forks source link

Controlling the Insertion of Multi-Qubit Gates in the Generation of Random Circuits #12059

Closed sbrandhsn closed 1 month ago

sbrandhsn commented 3 months ago

What should we add?

The generation of random circuits should be extended by the ability to specify a distribution num_operand_distribution that specifies the ratio of 1-qubit, 2-qubit, ..., n-qubit gates in the random circuit. For instance, random_circuit with num_operand_distribution={1: 0.5, 2:0.5} should yield random circuits with roughly 50% single-qubit quantum gates and 50% two-qubit gates while disallowing n-qubit gates with n>2.

The parameter max_operands should take precedence, i.e. if max_operands is set, draw a random distribution num_operand_distribution. Raise an error if sum(num_operand_distribution.values()) != 1.0 or if max_operands is set at the same time as num_operand_distribution or if any key in num_operand_distribution is larger than the largest available n-qubit gate (see get_standard_gate_name_mapping).

Please also add tests to validate your changes and add a release note according to https://github.com/Qiskit/qiskit/blob/main/CONTRIBUTING.md

Note that this is a subtask of #11718. :-)

1ucian0 commented 1 month ago

This issue is participating on UnitaryHack 2024, between May 29 and June 12, 2024.

Because the nature of the event, there is no need to request to be assigned: just go ahead and PR your fix. The first/best PR can get the bounty (or it could be shared if they complement each other).

shravanpatel30 commented 1 month ago

@sbrandhsn Thanks for reviewing and accepting the PR. Please assign this issue to me.