Repository navigation
Pipeline parallel: DeepSeek-V4.1 LoRA cells with gloo evidence, and a text-only model over a composite config is not multimodal - #18037
Merged
Conversation
… not multimodal The native DeepSeek-V4.1 config keeps the release's vision_config, but DeepseekV41ForCausalLM has no tower and its forward takes no image input. pp_native read the config key alone, asked for PPConfig(text_only = True) and then refused for want of towers. A media config key now counts only when the model's forward names a media input; a multimodal model whose forward cannot be read keeps the old path, and towers left beside the decoder are still refused.
The registry had no MoE row for deepseek_v41, so pp=2 was refused with "no numeric parity / engagement / compile evidence". The stage forward, cut points, per-stage engram tables and carried mHC streams were already in pp_native; this adds the evidence and the cells: - parity: pp2 gpipe / 1f1b, pp4, interleaved and ZBV vs one process in fp32 (losses, every LoRA gradient, saved adapter), now also with zoo's non-reentrant checkpoint replay (gpipe 4 micro-batches, 1f1b) and with LoRA on the routed experts (target_parameters). - engagement: one pipeline_stage_forward call per micro-batch and step, each rank holds only its own layers' adapters, every layer owned once, the replay ran under checkpointing. - flip: a plain reentrant checkpoint without the replay leaves kv_proj gradients wrong; the existing unsafe-cut flip still raises. - the gloo config carries the release's vision_config. Cells: deepseek_v41 x lora and lora+experts x aux off x pp, eager attention, memory none / gc / unsloth_offload (the same replay runs under Unsloth's offloading checkpoint). QLoRA and full stay refused. _kernels no longer reads a native port's own attention (unsloth/models/<name>/modeling.py) as Unsloth's fast kernels; on CPU it marked DeepSeek-V4.1 as kernels / fused_ce.
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. Breezy! 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". |
[skip ci]
# Conflicts: # unsloth/parallel_capabilities.py
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.
Summary
DeepSeek-V4.1 (native
DeepseekV41ForCausalLM) underUNSLOTH_PARALLEL="pp=2"was refused at trainer init:The pipeline machinery itself was already on main (#17785): stages run through the model's own
pipeline_stage_forward, cuts land only wherepipeline_handoff_keysis empty (no CSA / KV group state crosses a stage), each engram table lives on the stage that owns its layer, and the mHC residual streams plus the next sublayer's mixing weights are carried between stages. What was missing:deepseek_v41, so every pp layout fell to "no supported cell".pp_native._media_keys): the release config keeps avision_config, but the class has no tower and its forward takes no image input. Past the registry, PP asked forPPConfig(text_only = True)and then refused for want of towers. A media config key now counts only when the forward names a media input. A model whose forward cannot be read keeps the old path, and towers left beside the decoder are still refused._kernelsmisread: the native port's ownDeepseekV41Attention(underunsloth/models/deepseek_v41/modeling.py) was read as Unsloth's fast kernels, so on CPU the query saidkernels=True, loss=fused_ce.Evidence (CPU gloo, fp32, vs one process)
tests/test_parallel_deepseek_v41_gloo.py::test_deepseek_v41_parallel_matches_one_process: losses, every LoRA gradient and the saved adapter.target_parameters)Engagement, asserted in every pp case: one
pipeline_stage_forwardcall per micro-batch and step on each rank; each rank holds and steps only its own layers' adapters; every layer is owned exactly once; engram tables are real only on the owning stage; under checkpointing the zoo replay ran. The gloo config now carries the release'svision_config.Flips that must fail:
test_pp_reentrant_checkpoint_without_the_replay_breaks_parity: a plain reentrant checkpoint without the replay builds the shared KV under no_grad, sokv_projgradients are wrong.test_pp_cut_at_an_unsafe_layer_breaks_parity(existing): a stage cut inside a KV / indexer sharing group raisesKeyErroron the missing group state.DeepSeek-V4.1 has no router auxiliary loss, so there is no aux term to carry.
Cells added:
MoE deepseek_v41 x {lora, lora+experts} x aux off x pp, eager attention, gpipe / 1f1b, memorynone/gc/unsloth_offload(Unsloth's offloading checkpoint runs the same zoo replay). Compile evidence: eager, no compiled region. QLoRA and full finetuning under pp stay refused.Tests
Base = 20d05c2, same venvs,
CUDA_VISIBLE_DEVICES=(CPU).test_parallel_deepseek_v41_gloo.pytest_pp_native,test_pp_env,test_pp_moe_aux,test_pp_vlm_text_only,test_pp_gemma4_per_layer) plus the file abovePre-existing on base and head alike:
test_parallel_capabilities_latent_sinks.py(2, transformers 4.57.6) and the float8 cases oftest_parallel_capabilities_precision.py(10, no torchao in the 5.22.1 CPU venv).End to end through
SFTTraineron CPU (gloo, fp32, frozen tables on disk), tiny DeepSeek-V4.1 copy, per-step loss:use_gradient_checkpointing = "unsloth"Kaggle 2x T4 (fake DeepSeek-V4.1-Flash, 16-bit LoRA, docs harness)
unsloth/DeepSeek-V4.1-Flash-1017shrunk to a random-weight copy (real config, engram tables, mHC, compress ratios), seq 1024, global batch 8 rows, 25 steps, fp16,use_gradient_checkpointing = "unsloth", adamw_8bit, torch 2.14.1, transformers 5.17.0.no numeric parity / engagement / compile evidence)Per-step loss, pp=2 against 1 GPU: largest gap 0.0014 (step 17), step 1 12.0205 vs 12.0204. The 1-GPU and base pp rows come from an earlier job of the same harness on the same build; head ran the pp arm only.
pp=2 is not faster than one T4 at this size: the second stage idles through the gpipe bubble. Its use is fitting a model whose layers do not fit one card.