Repository navigation
DeepSeek-V4.1: keep torch.compile on when unsloth_zoo makes the checkpoint recompute match - #17660
Merged
Merged
Conversation
…point recompute match unsloth_zoo's prepare_compiled_checkpoint() lets the non-reentrant checkpointed layers run compiled helpers in both passes. Call it for deepseek_v41 and keep the old partial compile disable only when it is missing (older unsloth_zoo) or cannot apply.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Nov 16, 2026
Final comment pass for recently merged PRs. Trims comments added by unslothai#17660, unslothai#17806, unslothai#17807, unslothai#17808, unslothai#17812, unslothai#17830, unslothai#17854, unslothai#17857 and unslothai#17870 that are still on main. Multi-line explanations are collapsed to one line, and comments that restate the code are removed. Comments that explain a version quirk or a correctness trap are kept, along with license headers and pragmas. Changed comment lines: unslothai#17660 5 -> 2, unslothai#17806 4 -> 2, unslothai#17808 1 -> 0, unslothai#17830 3 -> 1, unslothai#17857 1 -> 0. unslothai#17807, unslothai#17812, unslothai#17854 and unslothai#17870 are unchanged. Overall: 6 files, 14 lines removed, 5 added. Only comments change: the AST check (comment_tools.py check) and the pre-push gate both pass.
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.
Why
Since #17625, loading DeepSeek-V4.1 (community port) sets
UNSLOTH_COMPILE_DISABLE=partial, because a compiled helper inside a checkpointed layer did not match its recompute. The model has trained with only the loss compiled since then.unslothai/unsloth-zoo#2488 fixes the mismatch and adds
prepare_compiled_checkpoint(). With it, the non-reentrant checkpointed layers run compiled helpers in both passes.What this changes
unsloth/models/loader.py, thedeepseek_v41branch:unsloth_zoo.temporary_patches.deepseek_v41.prepare_compiled_checkpoint().UNSLOTH_COMPILE_DISABLE=partialwhen the import fails (an unsloth_zoo without the fix) or the call returns False. Either side can update first without breaking training.tests/test_deepseek_v41_lora_coverage.py: the source-level branch test now checks the call and the fallback.Evidence
Colab L4, torch 2.14.1, the port (malaiwah/transformers@62d7ebd), this branch on main 624ddb3 plus unsloth-zoo#2488. Tiny DeepSeek-V4.1, Unsloth LoRA / QLoRA on every linear, unsloth gradient checkpointing, engram tables on disk, 12 steps:
_forward_generic_experts_eagerly, the bnb 4-bit expert path, which is disabled on purpose.CheckpointError.The zoo PR has the failed alternatives (LRU cache off, automatic dynamic off, raised recompile limit) and the root cause.
Not covered