Skip to content

[Web] Expose RNG state for deterministic restore#20034

Open
akaashrp wants to merge 2 commits into
apache:mainfrom
akaashrp:upstream-rng-state
Open

[Web] Expose RNG state for deterministic restore#20034
akaashrp wants to merge 2 commits into
apache:mainfrom
akaashrp:upstream-rng-state

Conversation

@akaashrp

@akaashrp akaashrp commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Expose tvmjs RNG state so callers can save and restore deterministic sampling progress. Adds the following:

  • RNGState as the exported state type for LinearCongruentialGenerator
  • LinearCongruentialGenerator.getState()
  • LinearCongruentialGenerator.setState(state)
  • Instance.getRNGState()
  • Instance.setRNGState(state)

@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 introduces the ability to get and set the state of the internal LinearCongruentialGenerator (RNG) for deterministic restoration. It adds getRNGState and setRNGState methods to the Instance class, and corresponding getState and setState methods to the LinearCongruentialGenerator class, along with validation checks and comprehensive unit tests. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@akaashrp
akaashrp requested a review from guan404ming July 20, 2026 22:23

@guan404ming guan404ming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, left some nits. Thanks!

Comment thread web/src/support.ts
Comment thread web/src/support.ts Outdated
Comment thread web/tests/node/test_random_generator.js Outdated

@guan404ming guan404ming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks great.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants