Repository navigation
fix(openqasm): reject invalid random seeds - #4219
Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
alexcastgonz (pcbeingused333) wants to merge 1 commit into
Conversation
alexcastgonz (pcbeingused333)
requested review from
Bill Ticehurst (billti) and
Ian Davis (idavis)
as code owners
November 9, 2026 05:20
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4162
The source-string execution path silently drops Python extraction errors for
seed, causing floats, negative integers, and integers outside the unsigned 64-bit range to run without a seed.Return
PyResult<Option<u64>>fromget_seedand propagate conversion errors to the caller. Missing seeds and explicitNoneretain their existing behavior. Regression tests cover invalid inputs, deterministic execution with valid seeds (including zero and the maximum unsigned 64-bit value), and optional seeds.A valid seed close to 2^64 used with several shots still overflows in the per-shot increment (
s + i), which the issue also mentions; that is unchanged here, so this PR only covers the seeds that get dropped.Testing: with the native extension built from this branch,
tests/test_openqasm_seed.pypasses (7 passed); with the originalinterop.rsthe three invalid-seed cases fail and the four controls pass. The issue's repro now raisesTypeErrorforseed=1.5andOverflowErrorforseed=-1. Qiskit interop tests covering seeds,cargo clippy -p qdkandcargo fmt --checkpass.AI assistance was used to prepare this change and its tests.