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

Feature: provide RNG seed for StructuredState simulations #114

Merged
merged 4 commits into from
May 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Modifying a comment (lines too long)
PabloAndresCQ committed May 15, 2024
commit 64b2a1c6ab9926d2899fdfea66f5113cd950ab5f
6 changes: 3 additions & 3 deletions pytket/extensions/cutensornet/structured_state/mps.py
Original file line number Diff line number Diff line change
@@ -588,9 +588,9 @@ def sample(self) -> dict[Qubit, int]:
# is shown to be a bottleneck when sampling (which is likely).
mps = self.copy()
outcomes = mps.measure(mps.get_qubits())
# If the user sets a seed for the MPS, we'd like that every copy of the MPS produces
# the same sequence of samples, but samples within a sequence may be different between
# each other. We achieve the latter by updating the state of `self._rng`.
# If the user sets a seed for the MPS, we'd like that every copy of the MPS
# produces the same sequence of samples, but samples within a sequence may be
# different from each other. Achieved by updating the state of `self._rng`.
self._rng.setstate(mps._rng.getstate())

return outcomes