-
Notifications
You must be signed in to change notification settings - Fork 35
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
Seed sampling for lightning simulators #999
Labels
enhancement
New feature or request
Comments
paul0403
added a commit
that referenced
this issue
Aug 13, 2024
**Context:** Seeding for qjit was added in #936 , but only measurements were seeded, and samples were not. Hence this test is still flaky. Sample seeding needs to be done in Lightning. #999 **Description of the Change:** Marking the test test_mid_circuit_measurement.py/test_dynamic_one_shot_several_mcms as xfail. --------- Co-authored-by: David Ittah <[email protected]>
dime10
pushed a commit
that referenced
this issue
Oct 3, 2024
**Context:** There's still quite a few frontend tests stochastically failing because the `seed` option in `qjit` only controls the measurements, but not the samples. We add seeding to the samples. **Description of the Change:** When `qjit(seed=...)` receives a (unsigned 32 bit int) seed value from the user, the seed gets propagated through mlir and [eventually becomes a field of the `Catalyst::Runtime::Simulator::LightningSimulator` class, alongside the seeded `std::mt19937` rng instance ](https://github.com/PennyLaneAI/catalyst/blob/a580bada575793b780d5366aa77dff6157cd4f93/runtime/lib/backend/lightning/lightning_dynamic/LightningSimulator.hpp#L54). This was done in #936. In #936 , [the device's rng instance is used during measurements ](https://github.com/PennyLaneAI/catalyst/blob/a580bada575793b780d5366aa77dff6157cd4f93/runtime/lib/backend/lightning/lightning_dynamic/LightningSimulator.cpp#L451), but not during samples. This is because samples are performed from the `Pennylane::LightningQubit::Measures::Measurements` class through the `generate_samples` methods, which is controlled by the lightning repo. To seed samples, we use the device rng instance to generate a deterministic seed to pass it onto the state vector's `generate_samples` methods. This is the only change in catalyst. In lightning, the `generate_samples` method now can take in a seeding number. The catalyst devices pass in a seed into the lightning `generate_samples`; this seed is created deterministically from the aforementioned already seeded catalyst context rng instance. This makes the generated samples deterministc. The above is published on the lightning repo as the branch "seed_sample_lightning": PennyLaneAI/pennylane-lightning#927 PennyLaneAI/pennylane-lightning@6f3e0d5 **Benefits:** Fewer (hopefully no) stochatically failing frontend tests. **Related GitHub Issues:** #999 [sc-72878]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently only measurements are seeded for lightning simulators #936. It would be nice to have samples (aka shots) seeded too.
The text was updated successfully, but these errors were encountered: