Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Replace shallow copy with deepcopy in QV circuit generation #462

Merged

Conversation

mtreinish
Copy link
Collaborator

Summary

In #460 we migrated the QV circuit generation to use the QV circuit from
terra's circuit library instead of constructing it from scratch. As part
of that the circuit generation was updated to construct a single virtual
circuit via the library and just copy it for the no measure output
circuits. However, this was done using a shallow copy (in the interest
of performance) which means that any references between the circuits
will not be duplicated. For cases where the qubit_lists input is not a
contiguous list this would result in the measurements showing up in the
no measurement circuits because of shared references. This commit fixes
this by using deepcopy instead of a shallow copy so that there are no
shared references between the measurement circuit and the no measurement
circuit.

Details and comments

In qiskit-community#460 we migrated the QV circuit generation to use the QV circuit from
terra's circuit library instead of constructing it from scratch. As part
of that the circuit generation was updated to construct a single virtual
circuit via the library and just copy it for the no measure output
circuits. However, this was done using a shallow copy (in the interest
of performance) which means that any references between the circuits
will not be duplicated. For cases where the qubit_lists input is not a
contiguous list this would result in the measurements showing up in the
no measurement circuits because of shared references. This commit fixes
this by using deepcopy instead of a shallow copy so that there are no
shared references between the measurement circuit and the no measurement
circuit.
The seed parameter beign passed directly to the QuantumVolume circuit
library resulted in the generated circuits all being identical. To
ensure that we get reproducible but useful output this changes the seed
usage to create it's own random Generator and use the seed parameter as
the seed for that. Then the generator is used to generate a sequence of
random integers which get passed to each QuantumVolume object.
@chriseclectic chriseclectic merged commit a705a6e into qiskit-community:master Aug 5, 2020
@mtreinish mtreinish deleted the fix-no-meas-edge-case branch August 6, 2020 14:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants