Repository navigation
fix: draw random trajectory noise from a private generator - #64
Merged
Merged
Conversation
random_trajectory_3d seeded the process-wide generator, so every later random draw in the calling script silently restarted from that seed. Draw from a private generator instead. A generator on the target device replays the stream the process-wide one produced, so seeded trajectories stay bit-identical on CPU, MPS and CUDA (checked against 2.5.0 on an RTX 4090: max abs diff 0.0). int() keeps the seed forms torch.manual_seed accepted, which a fresh Generator would otherwise reject.
Owner
|
Thanks! I pushed two small follow-ups: the noise now follows the trajectory tensors' dtype and device (angle tensors can override the device and dtype arguments), and a missing per-device generator now raises instead of silently switching to a CPU stream with different values. The tests compare against a local copy of the previous algorithm, so they do not need git history. |
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.
random_trajectory_3dcalledtorch.manual_seed(seed), which seeds theprocess-wide generator: every random draw in the calling script after that call
silently restarted from the trajectory's seed.
Draw from a private
torch.Generatoron the target device instead. It replaysthe same stream the process-wide one produced, so seeded trajectories stay
bit-identical (checked against 2.5.0 on an RTX 4090: max abs diff 0.0).
int()keeps the seed forms
torch.manual_seedaccepted, which a fresh generatorrejects.
Tests: three cases in
tests/test_geometry_input_validation.py- the globalgenerator is untouched, the seed is reproducible, and a seeded trajectory still
replays the previous stream. 188/188 in that file.