Skip to content

[BugFix] Update replay priorities when the Trainer has an optimization stepper - #4716

Merged
theap06 merged 1 commit into
pytorch:mainfrom
sramireddy2:fix/stepper-post-loss-priority
Dec 1, 2026
Merged

theap06 merged 1 commit into
pytorch:mainfrom
sramireddy2:fix/stepper-post-loss-priority

Conversation

@sramireddy2

@sramireddy2 sramireddy2 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #4715. With an optimization_stepper, Trainer.optim_steps skipped the post_loss ops, which is where ReplayBufferTrainer updates replay priorities. CQLTrainer always uses a stepper, so a prioritized buffer kept its initial priorities.

The stepper branch now runs the post_loss ops after optimization_stepper.step(...), unless the stepper sets updates_replay_priority (as TD3OptimizationStepper does). This is the rule the Ray backend already uses. Among the built-in trainers only CQLTrainer is affected: GRPO, TD3 and TD-MPC2 register no post_loss ops.

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

I used an AI assistant (Claude Code) to help find the bug and run the checks. I've read and tested every changed line.

@pytorch-bot

pytorch-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures, 1 Unrelated Failure

As of commit 95cd7e4 with merge base a711ef9 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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 Nov 10, 2026
@sramireddy2

Copy link
Copy Markdown
Contributor Author

Hi @theap06, could you take a look at this and approve CI when you have time? It makes CQLTrainer update replay priorities, so the prioritized-replay weights from your #4694 take effect.

@theap06 theap06 closed this Nov 30, 2026
@theap06 theap06 reopened this Nov 30, 2026
@sramireddy2

sramireddy2 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for running CI, @theap06! The bot lists the three Python 3.10 jobs as new, but they fail at the torchrl build step (IndexError in cpp_extension.py), which also fails on main (e.g. a68419e). tests-gpu (3.12, 13.0, 2) failed on an NVIDIA package download before any test ran. Could you re-run that one when you have a moment?

@theap06

theap06 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for running CI, @theap06! The bot lists the three Python 3.10 jobs as new, but they fail at the torchrl build step (IndexError in cpp_extension.py), which also fails on main (e.g. a68419e). tests-gpu (3.12, 13.0, 2) failed on an NVIDIA package download before any test ran. Could you re-run that one when you have a moment?

I think that this missed the tests-cpu matrix, which still has 3.10 and installs nightly torch. We are currently migrating to the set the lower dep for python for 3.11. As for this PR, everything LGTM!

@theap06
theap06 merged commit 90da634 into pytorch:main Dec 1, 2026
121 of 125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Trainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Trainer skips replay priority updates when an optimization_stepper is set, so CQLTrainer never updates PER priorities

2 participants