Skip to content

[Performance] Improve geometric window sampling - #4131

Open
theap06 wants to merge 4 commits into
pytorch:codex/geometric-trajectory-samplerfrom
theap06:codex/geometric-window-performance
Open

[Performance] Improve geometric window sampling#4131
theap06 wants to merge 4 commits into
pytorch:codex/geometric-trajectory-samplerfrom
theap06:codex/geometric-window-performance

Conversation

@theap06

@theap06 theap06 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • sample truncated geometric offsets on the storage device in constant time with a numerically stable inverse CDF
  • integrate the draw into the compiled tensor kernel and avoid scalar synchronization in the history/future loops
  • add distribution coverage and an offset-focused scaling benchmark

Performance

The offset benchmark is flat at roughly 8.5 microseconds for max_future=32 and max_future=4096 on CPU. In a local comparison including the maximum-availability reduction over 100,000 slots, the previous weight-vector draw took 20.0 and 72.3 microseconds respectively; the inverse-CDF draw took 19.9 microseconds in both cases.

Steady-state MPS profiling reports no item, _local_scalar_dense, or nonzero operations, and the sampled tensors remain on the storage device. Total sampling still includes an anchor-weight scan and fixed-size window construction, so this PR only makes the geometric offset draw constant-time.

Validation

  • geometric trajectory sampler tests: 16 passed, including torch.compile(..., fullgraph=True)
  • geometric replay-buffer benchmarks: 6 passed
  • replay-buffer example completed successfully
  • MPS steady-state sample/device profiler smoke test passed

Stacked on #4130.

@pytorch-bot

pytorch-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4131

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 15 Awaiting Approval

As of commit 42df30e with merge base b0eab87 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 19, 2026
@github-actions github-actions Bot added Performance Performance issue or suggestion for improvement Benchmarks rl/benchmark changes ReplayBuffers labels Aug 19, 2026
@theap06

theap06 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@torchrlbot reviewer @vmoens

@github-actions
github-actions Bot requested a review from vmoens August 19, 2026 21:31
@github-actions

Copy link
Copy Markdown
Contributor

Requested review from @vmoens (requested by @theap06).

@vmoens
vmoens force-pushed the codex/geometric-trajectory-sampler branch from bcef2bc to db7910c Compare August 20, 2026 19:57
@vmoens
vmoens force-pushed the codex/geometric-window-performance branch from 773f215 to 42df30e Compare August 20, 2026 20:03
@vmoens
vmoens force-pushed the codex/geometric-trajectory-sampler branch 7 times, most recently from ecc02ea to 70f29d2 Compare August 28, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Benchmarks rl/benchmark changes CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Performance Performance issue or suggestion for improvement ReplayBuffers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants