-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to seed numba RNG #89
base: main
Are you sure you want to change the base?
Conversation
Hi! I'm not sure doing this part of the transforms is the optimal way as every transform with randomness will have to add it, and users have to set the seed many times. Moreover it will be ran at each batch which will slow down things. Maybe there is a better place. |
Thanks for the quick response Guillaume! I agree that this is not a great way to seed the random state in A nicer solution would be to seed the I'm not too familiar with
This numba thread suggests that it's possible to set the Hope that clarified some questions :) |
I think the best would be to do it at the start of loading and use the seed argument. Doing it in the operations mean you get the same random sequence at each batch which most likely will produce adverse results during training. |
I was able to get determinism after using
in I cannot set the |
Also, I'm confused about the threading in |
I suspect that it would work with multiple workers too as workers are only activate in the body of the transforms. Have you tried that? EpochIterator is implemented as a thread so that the augmentations (especially the CPU ones) are not blocking the main training loop of the user |
With the code above, setting I haven't confidently figured out why that's the case, but I suspect that the cause is |
Oh that's the good call in my opinion. Not sure yet how to get around that problem. Do you personally have use cases where determinism is needed. Usually determinism doesn't play well with high-performance code (cuddn deterministic mode can be significantly slower too) |
My current work is looking at how fixing different sources of randomness affects training outcomes, and data augmentations are an example. Maybe this use case is rather niche, and the changes are not worth the hit in performance. Hopefully this thread at least can help others with similar issues :) |
On a related note, is the desired default behavior of the |
Hello,
It was intended but we decided to change this in v0.0.3. the release
candidate is available on pip already. See announcements for more details .
…On Mon, Jan 24, 2022, 8:15 AM Julius Tao ***@***.***> wrote:
On a related note, is the desired default behavior of the Random
TraversalOrder to have the same shuffle order across independent runs?
The default is self.seed = self.loader.seed = 0, which implies the above
since the seed for each epoch is always self.seed + epoch.
—
Reply to this email directly, view it on GitHub
<#89 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPMOG6467F5I6ZOXAWXIBTUXV3KZANCNFSM5MSVZ37A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Did you succeed to run ffcv deterministic @juliustao? I am facing similar problem with a gap of more than 5 points in my metric with same code on different runs. I seed everything, but I was looking for how to seed the workers as in pytorch dataloaders, but could not find it. |
Calling
numpy.random.seed
at the start of code can set the global seed for allnumpy.random
methods.However, calling this method from Python does not seed the
numba
generator, sonumba
JIT-compiled code is nondeterministic (e.g., thecutout_square()
function returned bygenerate_code()
in theCutout
operation).See this
numba
documentation for further details.Adding an optional
seed
argument to such random transforms allows reproducibility across runs.