You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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#927PennyLaneAI/pennylane-lightning@6f3e0d5
**Benefits:**
Fewer (hopefully no) stochatically failing frontend tests.
**Related GitHub Issues:** #999
[sc-72878]
0 commit comments