[Feature] Add generation-stamped replay slots for round-robin writer - #4046
[Feature] Add generation-stamped replay slots for round-robin writer#4046harryfrzz wants to merge 9 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4046
Note: Links to docs will display an error until the docs builds have been completed. ❌ 38 New Failures, 19 Unrelated Failures, 1 Unclassified FailureAs of commit 88ed9b4 with merge base ae421b9 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @harryfrzz! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
theap06
left a comment
There was a problem hiding this comment.
Thanks! Left some feedback.
Description
Adds generation-stamped slots to the round-robin replay writer (step 1 of the
work in #4041). Every physical storage slot carries an int64 generation counter:
the first write of a slot has generation 0 and every reuse increments it, so a
sampled
(index, generation)pair identifies a specific record and becomesdetectably stale once its slot is reused.
writer.generations_of(index)and thetracks_generationscapability flag.Writers that do not track reuse report
-1.sample(return_info=True)returns an"index_generation"entry aligned with"index", read under the sampling lock;TensorDictbuffers surface it as asample key.
empty()is monotonic: previously handed-out(index, generation)handles arenever revived.
state_dict/load_state_dictanddumps/loads; oldercheckpoints still load. Lazy (unbounded) storages grow the counter dynamically.
The conditional priority-update API that consumes these stamps is submitted
separately. Cross-process visibility of stamps for
share()-d buffers is notyet supported and is deferred to a follow-up.
Motivation and Context
With a round-robin writer a slot can be overwritten while a learner computes a
loss, so a delayed priority update may apply a TD-error to a different record
that now occupies the same slot. Stamping each index with a generation lets
callers detect that reuse. This PR adds the generation-tracking and sampling
side.
Part of #4041.
Types of changes
Checklist