[Feature] Add ACTModel and ACTLoss for robot learning#3639
Open
theap06 wants to merge 2 commits intopytorch:mainfrom
Open
[Feature] Add ACTModel and ACTLoss for robot learning#3639theap06 wants to merge 2 commits intopytorch:mainfrom
theap06 wants to merge 2 commits intopytorch:mainfrom
Conversation
Implements Action Chunking with Transformers (Zhao et al., 2023, arxiv.org/abs/2304.13705) as a composable model + loss pair. ACTModel (torchrl/modules/models/act.py): - CVAE encoder: [CLS | action_tokens | obs_token] → z_mu, z_log_var - DETR-style Transformer decoder: learned action queries attend to [obs_token, z_token] → action chunk of shape (chunk_size, action_dim) - Training mode: pass action_chunk to activate encoder and sample z - Inference mode: omit action_chunk; defaults to z=0 (prior mean) - Sinusoidal positional encoding, configurable hidden_dim / nheads / num_encoder_layers / num_decoder_layers / latent_dim / dropout ACTLoss (torchrl/objectives/act.py): - loss = L1(action_pred, action_chunk) + kl_weight * KL(q(z|o,a)||N(0,I)) - Returns loss_act (differentiable), loss_reconstruction and loss_kl (detached, for logging) - kl_weight defaults to 10.0 per the original paper - Follows the LossModule / convert_to_functional / to_module pattern established by DiffusionBCLoss Also: - Registers ACTModel in torchrl.modules.models and ACTLoss in torchrl.objectives - Adds 31 tests covering shapes, training/inference modes, KL decomposition, reductions, and gradient flow - Adds docs entries in objectives_other.rst and modules_models.rst
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3639
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below:
|
Contributor
Author
|
@vmoens lmk if you need any outputs before mergings. |
Contributor
Author
|
@vmoens lgtm |
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.

Implements Action Chunking with Transformers (Zhao et al., 2023, arxiv.org/abs/2304.13705) as a composable model + loss pair.
Implements - #3636
ACTModel (torchrl/modules/models/act.py):
ACTLoss (torchrl/objectives/act.py):
Also: