-
Notifications
You must be signed in to change notification settings - Fork 0
fix(protrain): auto-offload memory-bound VL models; compose lora_mlp_kernel with offload #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1642,6 +1642,36 @@ def post_model_load(self, cfg, model: "nn.Module") -> None: | |
| n_offload_override = getattr(cfg, "protrain_n_offload_override", None) | ||
| zero3_shard = getattr(cfg, "protrain_zero3_shard", None) | ||
|
|
||
| # The wrapper bypasses the searcher only when all four of | ||
| # n_persist/n_buffer/n_swap/n_checkpoint are set; a partial set would | ||
| # otherwise silently fall back to the auto search. Complete it with safe | ||
| # defaults so a partial override does what the user intended. | ||
| _core_overrides = { | ||
| "protrain_n_persist_override": n_persist_override, | ||
| "protrain_n_buffer_override": n_buffer_override, | ||
| "protrain_n_swap_override": n_swap_override, | ||
| "protrain_n_checkpoint_override": n_checkpoint_override, | ||
| } | ||
| _set = [k for k, v in _core_overrides.items() if v is not None] | ||
| if 0 < len(_set) < 4: | ||
| if n_persist_override is None: | ||
| n_persist_override = 0 | ||
| if n_buffer_override is None: | ||
| n_buffer_override = 2 | ||
| if n_swap_override is None: | ||
| n_swap_override = 0 | ||
| if n_checkpoint_override is None: | ||
| n_checkpoint_override = 0 | ||
| LOG.warning( | ||
| "ProTrain: partial residency override (set: %s). The override " | ||
| "path needs all four of n_persist/n_buffer/n_swap/n_checkpoint " | ||
| "or it silently falls back to the auto search. Filled unset " | ||
| "knobs: n_persist=%d n_buffer=%d n_swap=%d n_checkpoint=%d. Set " | ||
| "all four explicitly to suppress this.", | ||
| ", ".join(_set), n_persist_override, n_buffer_override, | ||
| n_swap_override, n_checkpoint_override, | ||
| ) | ||
|
Comment on lines
+1665
to
+1676
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply CI indicates formatting changes are still required in this file. 🧰 Tools🪛 GitHub Actions: lint / 0_pre-commit.txt[error] 1668-1668: ruff-format reformatting changed this file (2 files reformatted). Apply formatting changes committed by the hook. 🤖 Prompt for AI Agents |
||
|
|
||
| # auto_mode default True; wrapper picks (force_persist, zero3) post-search. | ||
| auto_mode = getattr(cfg, "protrain_auto_mode", True) | ||
| if auto_mode is None: | ||
|
|
@@ -1664,13 +1694,16 @@ def post_model_load(self, cfg, model: "nn.Module") -> None: | |
| "(force_all_persistent=False, zero3_shard=False)." | ||
| ) | ||
|
|
||
| # Fused LoRA MLP backward kernel + offloaded-activation chunk placeholders | ||
| # crash with LoRA_MLPBackward shape-mismatch (v61); pin n_offload=0. | ||
| forbid_activation_offload = bool(getattr(cfg, "lora_mlp_kernel", False)) | ||
| # The v61 LoRA_MLPBackward shape-mismatch is fixed by the unconditional | ||
| # shape-preserving placeholders, so the fused MLP kernel now composes | ||
| # with offload; opt back into the old conservative pin if needed. | ||
| forbid_activation_offload = bool( | ||
| getattr(cfg, "protrain_lora_mlp_forbid_offload", False) | ||
| ) | ||
| if forbid_activation_offload: | ||
| LOG.info( | ||
| "ProTrain: cfg.lora_mlp_kernel=True; searcher will refuse " | ||
| "n_offload>0 candidates." | ||
| "ProTrain: protrain_lora_mlp_forbid_offload=True; searcher will " | ||
| "refuse n_offload>0 candidates." | ||
| ) | ||
|
Comment on lines
+1703
to
1710
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the wrapper docstring to match this new knob source. This hunk now uses 🤖 Prompt for AI Agents |
||
|
|
||
| # PR #17c: defensive searcher tie-break on non-NVLink multi-rank rigs. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply
ruff formatfor this file before merge.CI is currently failing on this file due formatting drift; please commit formatter output.
🧰 Tools
🪛 GitHub Actions: lint / 0_pre-commit.txt
[error] 83-83: ruff-format reformatting changed this file (2 files reformatted). Apply formatting changes committed by the hook.
🤖 Prompt for AI Agents