feat(act): add torch.compile support for ACT policy#3061
Open
jashshah999 wants to merge 1 commit intohuggingface:mainfrom
Open
feat(act): add torch.compile support for ACT policy#3061jashshah999 wants to merge 1 commit intohuggingface:mainfrom
jashshah999 wants to merge 1 commit intohuggingface:mainfrom
Conversation
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.
Open
Contributor
Author
|
Gentle ping -- this follows the same pattern already merged for DiffusionPolicy (#2486) and PI0. Happy to address any feedback. |
5 tasks
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.
What this does
Adds
compile_modelandcompile_modeconfig options to ACTPolicy, following the same pattern used by DiffusionPolicy, PI0, and SAC.When
compile_model=True,self.model(the innerACTnn.Module) is wrapped withtorch.compile(), providing inference speedups with no changes to the model architecture.This works cleanly because all
.item()calls and action queue logic live inACTPolicy(which stays uncompiled), whileACT.forward()is pure tensor computation.Changes
configuration_act.py: Addcompile_model: bool = Falseandcompile_mode: str = "reduce-overhead"config fieldsmodeling_act.py: Applytorch.compiletoself.modelinACTPolicy.__init__when enabledtests/policies/test_compile.py: Correctness test verifying compiled and non-compiled outputs match, plus training forward pass testCloses #2061