Skip to content

Commit bf67cba

Browse files
committed
Allow configuring pytorch compilation mode
1 parent e6b0441 commit bf67cba

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/openpi/models/pi0_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ class Pi0Config(_model.BaseModelConfig):
3232
# This config option is not used directly by the model, but it is read by the ModelTransformFactory.
3333
discrete_state_input: bool = None # type: ignore
3434

35+
pytorch_compile_mode: str | None = "max-autotune"
36+
3537
def __post_init__(self):
3638
if self.max_token_len is None:
3739
object.__setattr__(self, "max_token_len", 200 if self.pi05 else 48)
3840
if self.discrete_state_input is None:
3941
object.__setattr__(self, "discrete_state_input", self.pi05)
42+
if self.pytorch_compile_mode is not None:
43+
assert self.pytorch_compile_mode in ["default", "reduce-overhead", "max-autotune", "max-autotune-no-cudagraphs"]
4044

4145
@property
4246
@override

src/openpi/models_pytorch/pi0_pytorch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def __init__(self, config):
109109
self.action_time_mlp_out = nn.Linear(action_expert_config.width, action_expert_config.width)
110110

111111
torch.set_float32_matmul_precision("high")
112-
self.sample_actions = torch.compile(self.sample_actions, mode="max-autotune")
112+
if config.pytorch_compile_mode is not None:
113+
self.sample_actions = torch.compile(self.sample_actions, mode=config.pytorch_compile_mode)
113114

114115
# Initialize gradient checkpointing flag
115116
self.gradient_checkpointing_enabled = False

0 commit comments

Comments
 (0)