Repository navigation
0.3.2a1: long-context MLX training - #53
Merged
Merged
Conversation
…oE, recompute policy, RoPE scaling, packing) Blockwise causal attention (full-causal blocks use the kernel's causal mode), chunked cross-entropy, chunked MoE dispatch, selective recompute policy on MLX and Torch, training-time RoPE scaling (yarn/linear/ntk), document masking with a separate lookahead document switch, a pretrain length curriculum and SFT packing. All switches default to off. 64k full-model step: 24.5 GiB extra peak at 6.6k tok/s. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
Long-context MLX training on one Mac. Every switch is off by default, so existing configs and checkpoints behave as before.
attention_block_size: blockwise causal attention. A block that ends at its last visible key uses the kernel's"causal"mode with no mask array, which removes the[nH, block, span]score storage from the VJP. One MLA layer at 64k: 148.6 GiB -> 2.5 GiB extra.ce_chunk_size,moe_chunk_tokens: chunked cross-entropy and chunked MoE dispatch, both recomputed in the backward pass.recompute_policy(all|mla|swa|alternate) on MLX and Torch.rope_train_scaling(yarn|linear|ntk), MLX and Torch tables agree to 2e-5.document_masking,reset_router_at_documents, andreset_lookahead_at_documents(own switch for the lookahead terms). Fixes a document-id batch-size mismatch for grouped lookahead.PhaseSpec.seq_len_curriculumandPhaseSpec.pack_sft(SFTRecords.packed_batch).Measured (full MLX step, H512, 8 layers, 16 experts top-2, bf16, batch 1, M5 Max)
Test plan
tests/test_long_context.py: 38 passed (exactness against the reference paths, Torch parity)test_mlx_training_six_stage_loss_pathsdeselected: known MLX CPU segfault)🤖 Generated with Claude Code