[Feature] Added Lazy implementation of priority updates for replaybuffer prototype#3507
[Feature] Added Lazy implementation of priority updates for replaybuffer prototype#3507ParamThakkar123 wants to merge 23 commits intopytorch:mainfrom
Conversation
This reverts commit 1f6f327.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3507
Note: Links to docs will display an error until the docs builds have been completed.
|
- Remove dead _is_int check in _update_priority_tree (always False after _normalize_index which guarantees ndim >= 1). - Avoid double index normalization on the flush path: _update_priority_tree now expects pre-normalized, pre-filtered inputs; callers (update_priority, mark_update, _flush_pending_updates) handle normalization and negative-index filtering themselves. - Add docstring to mark_update explaining the lazy semantics. - Add tests for multiple-extend accumulation, empty-clears-pending, and state_dict round-trip with pending updates. Co-authored-by: Cursor <cursoragent@cursor.com>
| priority = priority[valid_index] | ||
| self._update_priority_tree(index, priority) | ||
|
|
||
| def mark_update( |
There was a problem hiding this comment.
mark_update is called by the writer on every single extend(). Should look into adding an upperbound the list only ever shrinks when _flush_pending_updates() runs. I would recommend implementing something like this
"""
self._pending_updates.append((index.clone(), priority))
if len(self._pending_updates) > self._max_pending:
self._flush_pending_updates()
"""
|
@ParamThakkar123 could you look into writing a quick efficiency test/benchmark? A simple before/after timing of extend() throughput would justify the added complexity |
Description
Describe your changes in detail.
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax
close #15213if this solves the issue #15213Fixes #616
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
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!