Skip to content

Remove global random seed fixture - #1458

Open
SripriyaDevarapalli wants to merge 4 commits into
quantumlib:mainfrom
SripriyaDevarapalli:issue-1060-local-rng
Open

SripriyaDevarapalli wants to merge 4 commits into
quantumlib:mainfrom
SripriyaDevarapalli:issue-1060-local-rng

Conversation

@SripriyaDevarapalli

Copy link
Copy Markdown

Addresses #1060.

The test suite previously reset Python and NumPy global random state
before every test. This removes that autouse fixture so tests can rely
on pytest-randomly for per-test random-state handling.

The collection-time seeds in pytest_configure are retained because they
are used for deterministic parameterization during test collection.

Tests:

  • 190 RNG-related tests passed
  • Full suite: 2223 passed, 66 skipped, 1 pre-existing Windows/Python 3.14
    forkserver failure

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request removes the set_random_seed autouse fixture from conftest.py, which previously set a fixed random seed using random.seed(0) and np.random.seed(0) during testing. There are no review comments, and I have no additional feedback to provide.

@mhucka

mhucka commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@SripriyaDevarapalli Is this still a work in progress? If so, please change this to a draft PR.

@mhucka mhucka added the s: awaiting-response Status: waiting on a response from someone label Oct 9, 2026
@SripriyaDevarapalli

Copy link
Copy Markdown
Author

@SripriyaDevarapalli Is this still a work in progress? If so, please change this to a draft PR.

Thanks for checking! This is still a work in progress. I’m reviewing the remaining global random-number usage in the tests to make sure the changes fully address the issue. I’ll mark the PR as a draft while I finish the updates and tests.

@SripriyaDevarapalli
SripriyaDevarapalli marked this pull request as draft October 9, 2026 06:18
@SripriyaDevarapalli

Copy link
Copy Markdown
Author

Hi! I’ve pushed an initial set of changes replacing global random-number usage with local random generators in the circuit tests. The updated tests pass with multiple pytest-randomly seeds.

I’m continuing to work through the remaining tests that rely on global random state, following the incremental approach suggested in the issue. I’ll run the relevant tests with different seeds as I make further changes, and I’ll remove the global seeds from the root conftest.py once enough tests have been converted.

Feedback on the current changes or suggestions on which tests to prioritize would be very welcome. Thank you!

@SripriyaDevarapalli
SripriyaDevarapalli marked this pull request as ready for review October 9, 2026 08:06
@SripriyaDevarapalli

Copy link
Copy Markdown
Author

Hi! I’ve marked this PR as ready for review. The current changes convert random number usage to local RNGs in the circuit tests and molecular data test, and all active CI checks are passing.

I understand that additional tests may still rely on global random seeds. I’d appreciate your feedback on whether I should convert more tests in this PR before removing the global seeds from conftest.py, or whether the current changes are a good incremental step.

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s: awaiting-response Status: waiting on a response from someone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants