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.84k stars 2.29k forks source link

Generation of Random Circuits with Pre-Defined Inter-Qubit Connectivity #12364

Open sbrandhsn opened 2 months ago

sbrandhsn commented 2 months ago

What should we add?

The generation of random circuits should be extended by the ability to specify a circuit connectivity or interaction graph $G$ that the random graph should should adhere to. The interaction graph $G$ of a circuit is determined by the set of two-qubit gate interactions $g{1}=(v{1}, u{1}), ..., g{n}=\{v{n},u{n}\}$ with qubits $V=\{v{i}\}$ in the circuit such that $G=(V, E)$ where $E=\{g{i}\}$. You can generate the interaction graph of a circuit using vf2_utils.build_interaction_graph. For instance, let $G=(V, E)$ be a line graph over $n$ qubits such that $E=\{\{v{i}, v{i+1}\} | $ for $i=0...n-2$ $\}$, then each two-qubit gate in the random circuit may only interact on neighboring qubits $v{i}, v{i+1}$.

To realize this behavior, please create a new function random_circuit_from_graph to https://github.com/Qiskit/qiskit/blob/main/qiskit/circuit/random/utils.py with the parameters interaction_graph, max_operands=2, measure=False, conditional=False, reset=False, seed=None that represents the graph $G$ as above. The number of vertices in interaction_graph define the number of qubits in the circuit to be generated and the depth parameter specifies how often each qubit-pair must at least be used in a two-qubit gate before the circuit is returned. The remaining parameters should follow the definition of random_circuit in https://github.com/Qiskit/qiskit/blob/main/qiskit/circuit/random/utils.py#L23.

Optional edge weights in interaction_graph must be positive and should be normalized to sum up to 1.0. The now normalized edge weights represent the probability with which each qubit-pair interaction is inserted into a layer. An uniform edge weight would indicate that each two-qubit gate between the pairs specified in interaction_graph are equally likely to get inserted into a layer of the generated random circuit.

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 and connected to #12059. :-)

jakelishman commented 2 months ago

This sounds highly specific, so is it worth making a different function for it? The behaviour sounds really quite different to the existing random_circuit, but random_circuit_with _graph might give more room for expansion?

sbrandhsn commented 2 months ago

Sounds good to me, thanks for that comment! I was a bit worried because of code duplication but I think it makes sense to have a separate function - I edited the issue to reflect that. :-)

MozammilQ commented 1 month ago

Does one need to do PR first and then the issue gets assigned or the issue gets assigned and then one does the PR? is the issue assignable only between 29th May - 12th June or can it be assigned earlier?

MozammilQ commented 1 month ago

I have come up with a solution to this issue in PR #12474 Since, I have not been assigned to this issue so I haven't linked this issue to this PR.

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).