Skip to content

Deterministic gen v2#915

Merged
kaikalii merged 10 commits intouiua-lang:mainfrom
ndren:deterministic-gen
Feb 15, 2026
Merged

Deterministic gen v2#915
kaikalii merged 10 commits intouiua-lang:mainfrom
ndren:deterministic-gen

Conversation

@ndren
Copy link
Contributor

@ndren ndren commented Jan 6, 2026

(Hi @amatgil! Thanks for the original PR)

This uses unreleased features in the rand crate to make gen deterministic and portable. Currently a draft as these features are only in a release candidate of rand. From reading the documentation, HighwayHash and Xoshiro256PlusPlus should both be reproducible and deterministic but I haven't tested myself, more testing is welcome.

Test vector: ⍤⤙≍ gen [] 1 0.2791433297717809

@kaikalii
Copy link
Member

kaikalii commented Jan 6, 2026

This is great. Can you please resolve the merge conflict? Sorry I recently bumped a bunch of deps.

@ndren
Copy link
Contributor Author

ndren commented Jan 6, 2026

@kaikalii I've used the Cargo.lock from main and then ran cargo build, I understand that's the process to get the right dependencies?

@kaikalii
Copy link
Member

kaikalii commented Jan 6, 2026

Yes

@kaikalii
Copy link
Member

I've resolved the conflicts, but it doesn't seem to generate the same results on native vs pad.

@ndren
Copy link
Contributor Author

ndren commented Feb 15, 2026

I've updated the hashing of shape to use u64 rather than usize (which varies in hash implementation by platform, I wasn't aware when looking through the write_usize code).

I will note all the standard hashing will only work on the same endianness (granted almost all platforms are little endian, including wasm and amd64, so that should be fine)

Some other notes here: https://github.com/hoxxep/portable-hash?tab=readme-ov-file#whats-wrong-with-the-stdhash-traits
Do you know if there are other similar ones that need updating?

@ndren ndren marked this pull request as ready for review February 15, 2026 13:53
@ndren
Copy link
Contributor Author

ndren commented Feb 15, 2026

I tested it out and it does actually work on the web target now
Should this be made portable with other things (e.g. hash maps, since those use usize I think) or is f64/u8 arrays the only thing? I'm assuming you only really expect to use arrays anyway (selfgen ... for example)

@ndren
Copy link
Contributor Author

ndren commented Feb 15, 2026

image

@kaikalii
Copy link
Member

I think hashmaps using this is unnecessary for now.

@kaikalii kaikalii merged commit 1f5e65c into uiua-lang:main Feb 15, 2026
5 checks passed
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