Open
Conversation
…tioned on observations using a fixed linear-beta DDPM scheduler, following Diffusion Policy (Chi et al., RSS 2023).
… into feat/diffusion-actor
Implements the ε-prediction denoising loss from Diffusion Policy (Chi et al., RSS 2023) as a TorchRL LossModule, completing Phase-1 of the diffusion policy feature alongside DiffusionActor (pytorch#3596). - torchrl/objectives/diffusion_bc.py: DiffusionBCLoss subclassing LossModule, uses _DDPMModule.add_noise() for the forward diffusion step and computes MSE between predicted and actual noise. Supports configurable reduction and set_keys() for observation/action key remapping. - torchrl/objectives/__init__.py: register DiffusionBCLoss in alphabetical order. - test/objectives/test_diffusion_bc.py: 17 tests covering output keys, scalar loss, backward, gradient flow, reduction modes, custom keys, and a training convergence check. - examples/diffusion_bc_pendulum.py: end-to-end BC training on Pendulum-v1 with expert data collection, training loop, and evaluation.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3604
Note: Links to docs will display an error until the docs builds have been completed.
|
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.
[Feature] Add DiffusionBCLoss objective and Pendulum BC example" --body
Summary
Fixes #3149
DiffusionBCLossintorchrl/objectives/diffusion_bc.py— aLossModulesubclass that computes the ε-prediction (noise-prediction) denoising loss from Diffusion Policy (Chi et al., RSS 2023)DiffusionActor([Feature] Diffusion Actor DDPMModule #3596)Design
The loss:
tper batch element_DDPMModule.add_noise(clean_action, t)(forward diffusion)(noisy_action || observation || t)loss_diffusion_bcSupports
set_keys()for observation/action key remapping and configurablereduction.Files changed
torchrl/objectives/diffusion_bc.pyDiffusionBCLossimplementationtorchrl/objectives/__init__.pyDiffusionBCLosstest/objectives/test_diffusion_bc.pyexamples/diffusion_bc_pendulum.pyTest plan
pytest test/objectives/test_diffusion_bc.py— 17/17 passingpre-commit run— all hooks passing