[Support] Linear Congruential Random Engine#8642
Merged
junrushao merged 7 commits intoapache:mainfrom Aug 6, 2021
Merged
Conversation
junrushao
reviewed
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
junrushao
approved these changes
Aug 4, 2021
Member
junrushao
left a comment
There was a problem hiding this comment.
Thanks Xiyou! It overall looks good to me, especially the random numbers in cpptests :-) Please fix the minor comments
junrushao
reviewed
Aug 4, 2021
Member
|
The CI got stuck so I retriggered just now |
comaniac
reviewed
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
Member
To be crystal clear, the engine cannot be "serialized" because it is stateless. Its state is managed by the outside environment via a pointer to |
junrushao
reviewed
Aug 4, 2021
comaniac
approved these changes
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
junrushao
reviewed
Aug 4, 2021
Member
|
CC @areusch @electriclilies if you guys are interested in review |
Member
|
Going to merge it in by the end of the day if there are no more comments :-) |
Member
mehrdadh
pushed a commit
to mehrdadh/tvm
that referenced
this pull request
Aug 11, 2021
* Add linear congruential engine. * Fix typo. * Minor fix. * Fix comments and intros. * Change to unsigned. * Minor comment fix. * Fix unsigned rand state to signed.
62 tasks
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Sep 29, 2021
* Add linear congruential engine. * Fix typo. * Minor fix. * Fix comments and intros. * Change to unsigned. * Minor comment fix. * Fix unsigned rand state to signed.
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Jan 13, 2022
* Add linear congruential engine. * Fix typo. * Minor fix. * Fix comments and intros. * Change to unsigned. * Minor comment fix. * Fix unsigned rand state to signed.
MasterJH5574
pushed a commit
that referenced
this pull request
Mar 15, 2024
…16722) This PR implements `LinearCongruentialGenerator` in TVMjs, following the C++ counterpart in #8642. The motivation is that we want to seed autoregressive generation to make results reproducible, supporting the OpenAI field `seed`. The main function is `nextInt()`, which generates a number `(0, 2^32 - 1)` non-inclusive. Subsequently, we change all `Math.random()` in `runtime.ts` to `this.rng.randomFloat()`, exposing API `Instance.setSeed()`. Unit tests are added for `LinearCongruentialGenerator` for testing seed and coverage.
thaisacs
pushed a commit
to thaisacs/tvm
that referenced
this pull request
Apr 3, 2024
…pache#16722) This PR implements `LinearCongruentialGenerator` in TVMjs, following the C++ counterpart in apache#8642. The motivation is that we want to seed autoregressive generation to make results reproducible, supporting the OpenAI field `seed`. The main function is `nextInt()`, which generates a number `(0, 2^32 - 1)` non-inclusive. Subsequently, we change all `Math.random()` in `runtime.ts` to `this.rng.randomFloat()`, exposing API `Instance.setSeed()`. Unit tests are added for `LinearCongruentialGenerator` for testing seed and coverage.
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.
This PR introduce a new implementation of linear congruential engine and its test. This linear congruential engine is a drop-in replacement for and strictly corresponds to
std::minstd_randbut designed to be serializable and strictly reproducible. Specifically implemented for meta schedule but also reusable for other purposes.The main differences are as follows:
int64_tvariable. Therefore, the state of the random engine can be serialized as a singleint64_t.std::minstd_rand.