-
Notifications
You must be signed in to change notification settings - Fork 328
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
[BugFix] buffer __iter__ for samplers without replacement + prefetch #2185
Conversation
For replay buffers with prefetch enabled while having a sampler without replacement (that can "run out"), the buffer's `__iter__` method will not yield all samples. This is because its while loop terminates on sampler `ran_out` which is set as soon as a prefetch job is executed that triggers running out. However, there might still be prefetch jobs in the queue that could yield samples. Therefore, new flags are added for adding jobs to the prefetch queue and for terminating the yield loop only if available prefetch jobs are completed
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2185
Note: Links to docs will display an error until the docs builds have been completed. ❌ 5 New Failures, 14 Unrelated FailuresAs of commit 46ddf76 with merge base 672b50e (): NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@vmoens Somehow, for me the example you provided in #2182 seems to run fine (at least no errors apparent).
|
I still get the error. Besides, I think that this won't really solve it because Making a step back, what we want to avoid is that
I gave an attempt here, we still have the issue that there can be run conditions between the workers so we need to guard the accessed to ran_out and auto_reset with a lock I think. |
I believe this PR now solves this problem |
Reopen #2178 (see #2182)
Description
Adds loop termination condition in replay buffer
__iter__
method for yielding samples in prefetch queue and another condition in itssample
method for only adding new jobs to the prefetch queue if the sampler has not yet run out.Motivation and Context
For replay buffers with prefetch enabled while having a sampler without replacement (that can "run out"), the buffer's
__iter__
method will not yield all samples. This is because its while loop terminates on samplerran_out
which is set as soon as a prefetch job is executed that triggers running out. However, there might still be prefetch jobs in the queue left that could yield samples, therefore their samples are simply skipped.Types of changes
What types of changes does your code introduce? Remove all that do not apply:
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!