[Feature] Add geometric trajectory window sampler - #4130
Draft
vmoens wants to merge 3 commits into
Draft
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4130
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
from
August 20, 2026 19:57
bcef2bc to
db7910c
Compare
gtnv
reviewed
Aug 26, 2026
Comment on lines
+459
to
+477
| def _maybe_refresh_index(self, storage: Storage) -> None: | ||
| revision = int(storage._mutation_revision) | ||
| if self._trajectory_positions is None or self._cache_storage_id != id(storage): | ||
| self._full_rebuild(storage, revision) | ||
| return | ||
| if self._pending_indices and self._pending_storage_id == id(storage): | ||
| changed_revisions = { | ||
| pending_revision | ||
| for pending_revision in self._pending_revisions | ||
| if pending_revision > self._cache_revision | ||
| } | ||
| expected_revisions = set(range(self._cache_revision + 1, revision + 1)) | ||
| if changed_revisions == expected_revisions: | ||
| self._apply_pending(storage, revision) | ||
| else: | ||
| self._full_rebuild(storage, revision) | ||
| return | ||
| if self._cache_revision != revision: | ||
| self._full_rebuild(storage, revision) |
Contributor
There was a problem hiding this comment.
a write during _full_rebuild mixed 27/32 windows. the smaller rebuild-on-revision path passed 14 behavior tests and both probes. can we replace the pending-repair path and recheck after rebuilding?
Suggested change
| def _maybe_refresh_index(self, storage: Storage) -> None: | |
| revision = int(storage._mutation_revision) | |
| if self._trajectory_positions is None or self._cache_storage_id != id(storage): | |
| self._full_rebuild(storage, revision) | |
| return | |
| if self._pending_indices and self._pending_storage_id == id(storage): | |
| changed_revisions = { | |
| pending_revision | |
| for pending_revision in self._pending_revisions | |
| if pending_revision > self._cache_revision | |
| } | |
| expected_revisions = set(range(self._cache_revision + 1, revision + 1)) | |
| if changed_revisions == expected_revisions: | |
| self._apply_pending(storage, revision) | |
| else: | |
| self._full_rebuild(storage, revision) | |
| return | |
| if self._cache_revision != revision: | |
| self._full_rebuild(storage, revision) | |
| def _maybe_refresh_index(self, storage: Storage) -> None: | |
| while True: | |
| revision = int(storage._mutation_revision) | |
| if ( | |
| self._trajectory_positions is not None | |
| and self._cache_storage_id == id(storage) | |
| and self._cache_revision == revision | |
| ): | |
| return | |
| self._full_rebuild(storage, revision) | |
| if int(storage._mutation_revision) == revision: | |
| return |
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
from
August 28, 2026 08:48
db7910c to
dd007e3
Compare
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
3 times, most recently
from
August 28, 2026 14:56
cef5db0 to
24d44e3
Compare
vmoens
force-pushed
the
codex/fragmented-slice-sampler
branch
from
August 28, 2026 14:58
b2f5902 to
32ce20c
Compare
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
from
August 28, 2026 14:58
24d44e3 to
c0bf582
Compare
vmoens
force-pushed
the
codex/fragmented-slice-sampler
branch
from
August 28, 2026 15:12
32ce20c to
303c6cf
Compare
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
from
August 28, 2026 15:12
c0bf582 to
ecc02ea
Compare
vmoens
force-pushed
the
codex/fragmented-slice-sampler
branch
from
August 28, 2026 15:13
303c6cf to
8ff8f99
Compare
vmoens
force-pushed
the
codex/geometric-trajectory-sampler
branch
from
August 28, 2026 15:14
ecc02ea to
70f29d2
Compare
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.
Stack
Depends on #4180, which adds the reusable fragmented-trajectory index and
SliceSampler(fragmented=True). This PR is targeted at that branch so its diff contains only the geometric window policy and its public integration.Summary
GeometricTrajectoryWindowSampleron top of the shared fragmented-trajectory indexvalidity_mask,future_offset, andanchor_indexmetadatatorch.compile(fullgraph=True)Semantics
One geometric future offset
kis drawn per batch, then anchors are sampled uniformly from stored trajectory steps with complete requested history and at leastkconsecutive future steps.max_futurebounds the draw and fixes the returned shape to[batch_size, history + max_future + 1].Positions before trajectory step zero and after
t+krepeat a valid storage index and are markedFalseinvalidity_mask. Missing non-negative steps remain unavailable rather than being treated as padding.Performance
Local CPU benchmark with
batch_size=64,history=8, andmax_future=32after stacking on #4180:Validation
pytest test/rb/test_samplers.py -k GeometricTrajectoryWindowSampler -q(15 passed)pytest benchmarks/test_replaybuffer_benchmark.py -k geometric_trajectory_window_sampler --benchmark-only --benchmark-min-rounds=3 -q(4 passed)torch.compilesmoke test andfullgraph=Truetestgit diff --check