Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

High-level simulator random seed for circuit jobs #1463

Closed
yaelbh opened this issue Dec 1, 2020 · 8 comments
Closed

High-level simulator random seed for circuit jobs #1463

yaelbh opened this issue Dec 1, 2020 · 8 comments

Comments

@yaelbh
Copy link
Contributor

yaelbh commented Dec 1, 2020

Fixing the random seed when using Aqua consists, to my knowledge, of three steps:

  1. Setting aqua_globals.random_seed.
  2. Setting the seed_transpiler parameter in QuantumInstance.
  3. Setting the seed_simulator parameter in QuantumInstance.

The fixing of the seed_simulator causes an undesired behavior, where each execution of the variational circuit begins with the same random seed. Since the parameter values (to bind to the circuit) are only slightly modified between executions, often several consecutive executions result in the same counts.

The desired behavior is to be able to control the randomizations of the simulations, with different randomizations in different simulations.

@woodsp-ibm
Copy link
Member

So don't set seed_simulator in that case, leave it as default which will be random,

I believe Aer and BasicAer behave differently in regards of the seed_simulator when there are multiple circuits in a job - or at least they did in the past, I do not know if it has been changed. Chris knew about the differences.

@yaelbh
Copy link
Contributor Author

yaelbh commented Dec 1, 2020

But, what if I want the entire QAOA run to be restorable?

@woodsp-ibm
Copy link
Member

I take it that the expected outcome should be different but small. The sample size here means that this difference might be lost. Can you not increase the shot count? Or change the eps of the optimizer to make larger differences if its an issue with finite gradient. As I said Aer and BasicAer differ on what they do if these circuits are batched in job as to how seed_simulator is used. I cannot recall which one does what - Aer might use the seed for the whole job, whereas BasicAer for each circuit in the job. It sounds as though you are asking to have a different higher level seed for the simulator that would be set on quantum instance but used to generate an pseudo-random seed for seed_simulator each time a job (set of circuits is run). Even so if circuits are grouped into ajob for execution then its still dependent on the simulator behavior which as I mentioned differs (or at least did when I last talked to Chris about differences I had seen between Aer and BasicAer in regards of execution)

@yaelbh
Copy link
Contributor Author

yaelbh commented Dec 2, 2020

I'm indeed thinking of a higher level seed, as you describe. It would help me if it existed. But if you disagree, then it's OK to close this issue, or label it as "enhancement" rather than "bug".

@yaelbh
Copy link
Contributor Author

yaelbh commented Dec 2, 2020

Once the experiment class is ready and integrated with Aqua, this request of a high level random seed will fit naturally there.

@Cryoris Cryoris changed the title Simulator random seed is fixed for every simulator execution High-level simulator random seed for circuit jobs Dec 2, 2020
@woodsp-ibm
Copy link
Member

A seed-experiment sounds fine for whatever integration becomes of QuantumInstance and experiment class. I am still doubtful of its applicability to your described problem. It seems that when things are close to somehow try to rely on different outcome from a different seed may not turn out as expected and still give the same outcome. For sure with the exact same seed there is no chance for a different outcome. In general though if I did a batch of the identical ccts in an experiment (or job) I might reasonably expect them to have different outcomes and not all be identical - I think for a job this is how Aer behaves and last I saw BasicAer was identical results (but this was a while ago and as I said Chris was aware of the differences and it had been raised as an issue before). To assure things over a single job though is now simulator dependent - and of course we often want to group ccts together to minimize overhead. Anyway simulation within a job would need looking at too I think.

@yaelbh
Copy link
Contributor Author

yaelbh commented Dec 2, 2020

I suggest to close the issue for now, and return to this topic later with the experiment class.

@woodsp-ibm
Copy link
Member

Closing as suggested.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants