Skip to content

feat(act): add torch.compile support for ACT policy#3061

Open
jashshah999 wants to merge 1 commit intohuggingface:mainfrom
jashshah999:feat/act-torch-compile
Open

feat(act): add torch.compile support for ACT policy#3061
jashshah999 wants to merge 1 commit intohuggingface:mainfrom
jashshah999:feat/act-torch-compile

Conversation

@jashshah999
Copy link
Copy Markdown
Contributor

What this does

Adds compile_model and compile_mode config options to ACTPolicy, following the same pattern used by DiffusionPolicy, PI0, and SAC.

When compile_model=True, self.model (the inner ACT nn.Module) is wrapped with torch.compile(), providing inference speedups with no changes to the model architecture.

This works cleanly because all .item() calls and action queue logic live in ACTPolicy (which stays uncompiled), while ACT.forward() is pure tensor computation.

Changes

  • configuration_act.py: Add compile_model: bool = False and compile_mode: str = "reduce-overhead" config fields
  • modeling_act.py: Apply torch.compile to self.model in ACTPolicy.__init__ when enabled
  • tests/policies/test_compile.py: Correctness test verifying compiled and non-compiled outputs match, plus training forward pass test

Closes #2061

Add `compile_model` and `compile_mode` config options to ACTPolicy,
following the same pattern used by DiffusionPolicy, PI0, and SAC.

When enabled, `self.model` (the ACT nn.Module) is wrapped with
`torch.compile()`, providing inference speedups without requiring
any changes to the model architecture.
@github-actions github-actions Bot added policies Items related to robot policies tests Problems with test coverage, failures, or improvements to testing labels Mar 2, 2026
@imstevenpmwork imstevenpmwork mentioned this pull request Apr 3, 2026
@jashshah999
Copy link
Copy Markdown
Contributor Author

Gentle ping -- this follows the same pattern already merged for DiffusionPolicy (#2486) and PI0. Happy to address any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

policies Items related to robot policies tests Problems with test coverage, failures, or improvements to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make policies compatible with torch.compile

1 participant