Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Generator object for seed in QuantumVolume circuit #4867

Merged
merged 9 commits into from
Aug 5, 2020

Conversation

chriseclectic
Copy link
Member

Summary

Allows passing in a Numpy random Generator object as seed value for QuantumVolume circuit.

Closes #4866

Details and comments

@chriseclectic chriseclectic requested a review from a team as a code owner August 4, 2020 16:35
@mtreinish mtreinish added this to the 0.15 milestone Aug 4, 2020
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, but can you add a release note about support for passing a generator (and also maybe about the name change).

@nonhermitian
Copy link
Contributor

It would be nice if the circuit name had the seed and the offset from this seed in the name. Then each circuit could be reconstructed from the name alone.

@chriseclectic
Copy link
Member Author

@nonhermitian As far as i know this info can't be extract from the PCG64 Generator since it doesn't actually use an integer seed internally but using the int to generate a SeedSequence to generate a BitGenerator.

@nonhermitian
Copy link
Contributor

I am basically advocating for something like I did here:

https://github.com/Qiskit/qiskit-terra/blob/81216e55b339ef0cdab50d43d116eeb261dff540/qiskit/circuit/library/quantum_volume.py#L95

where the seed used to start the generator is attached to the circuit, plus the number of times the generator was called. Flor example if the seed was 2231, and I just seeded (offset=0) it then the name would be like QuantumVolume_10x10_2231+0.

With this convention I can reproduce the circuit, I would just re-seed with the same seed, and then call offset number of times before generating the circuit.

Note that if seed is a generator object the name contain [num_qubits, depth, Generator(PCG64)at<memory>]
This means we are not using the shared Generator object, but instead instantiating new generator objects with fixed integer seeds for each call to random_unitary.
@chriseclectic chriseclectic reopened this Aug 5, 2020
@mergify mergify bot merged commit e4c3b39 into Qiskit:master Aug 5, 2020
@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow passing in a Generator object for seed in QuantumVolume circuit
4 participants