Skip to content

fix: respect gradient checkpointing configuration - #1

Open
XieWeikai wants to merge 1 commit into
RLinf:mainfrom
XieWeikai:fix/respect-gradient-checkpointing-config
Open

fix: respect gradient checkpointing configuration#1
XieWeikai wants to merge 1 commit into
RLinf:mainfrom
XieWeikai:fix/respect-gradient-checkpointing-config

Conversation

@XieWeikai

Copy link
Copy Markdown

Summary

  • Stop forcing gradient checkpointing on during training.
  • Respect the state set by PI0Pytorch.gradient_checkpointing_enable() and gradient_checkpointing_disable().
  • Preserve checkpointed execution when gradient checkpointing is explicitly enabled.

Problem

PaliGemmaWithExpertModel.forward unconditionally set gemma_expert.model.gradient_checkpointing to true whenever the model was in training mode. This overrode callers that explicitly disabled gradient checkpointing, including RLinf SFT configurations with gradient_checkpointing: false.

The existing use_gradient_checkpointing expression already reads the expert model flag and training state, so removing the forced mutation lets the configured setting control the forward path.

Validation

  • python -m py_compile src/openpi/models_pytorch/gemma_pytorch.py
  • git diff --check
  • ruff format --check src/openpi/models_pytorch/gemma_pytorch.py
  • ruff check matches origin/main: the only diagnostic is the pre-existing FBT001 warning for use_cache on line 97; this patch adds no lint diagnostics.
  • Ran RLinf PI0.5 LIBERO SFT with FSDP on 8 GPUs for 20 optimizer steps, global batch size 200, and gradient_checkpointing: false. All ranks reported gradient checkpointing disabled, no forced-enable message appeared, and training completed successfully.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant