feat: public RandomState API + Updatable impl#321
Merged
minghuaw merged 2 commits intooxiglade:mainfrom Feb 26, 2026
Merged
Conversation
- Make RandomState methods public (new, with_seed, next_key, seed) - Implement Updatable trait for compile_with_state compatibility - Add Default impl for RandomState - Add helper methods (from_key, as_array, as_array_mut)
b7c207e to
d8557d6
Compare
- Change doc example from `ignore` to `no_run` for compile-time checking - Fix `# Safety` to `# Note` on non-unsafe as_array_mut method - Document Default impl panic conditions - Add tests for new(), with_seed(), next_key(), from_key(), Updatable, Default
Contributor
Author
Collaborator
Contributor
Author
|
@dcvz appreciate it, let me know if you need any changes to this etc. PMetal depends on a public RandomState API. All the best! |
Contributor
Author
|
@dcvz I definitely understand if its a busy week. Please keep me posted if you think it may be a while before you have a chance to look this over. We missed our launch window on Tuesday but we may move to ship our fork as a temporary work around and deprecate once we can depend on the the upstream fork. |
Collaborator
|
LGTM! |
minghuaw
approved these changes
Feb 26, 2026
Contributor
Author
Contributor
Author
Contributor
Author
|
crates.io rejects pinned git dependencies unfortunately |
Contributor
Author
|
I'm happy to do any legwork needed for the release, please let me know. This is the final blocker for PMetal v0.1.0 release |
Contributor
Author
|
Ideally the release would include #320 as well. I can see you're overloaded for now, we will ship our v0.1.0 with our fork for now. |
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.
Summary
Makes
RandomStatepublic with a complete API for compiled random number generation.RandomStateconstructors public:new(),with_seed(),from_key()next_key()for explicit state advancementas_array()/as_array_mut()for direct state accessUpdatabletrait forcompile_with_statecompatibilityDefaulttraitThis enables the Rust equivalent of Python's
@partial(mx.compile, inputs=mx.random.state, outputs=mx.random.state)pattern, which is essential for compiled text generation with sampling.