Repository navigation
[Perf] deepseek-v4.1: Integrate FlashMLA MegaAttention with NVFP4 KV - #43922
Merged
kpham-sgl merged 39 commits intoOct 16, 2026
Merged
Conversation
kpham-sgl
changed the base branch from
codex/flashmla-mega-build-apis
to
main
October 12, 2026 21:56
kpham-sgl
force-pushed
the
codex/dsv41-mega-attention-nvfp4
branch
3 times, most recently
from
October 14, 2026 10:43
0ddd929 to
2c6b9ff
Compare
kpham-sgl
force-pushed
the
codex/dsv41-mega-attention-nvfp4
branch
from
October 14, 2026 15:58
7434dff to
8054840
Compare
# Conflicts: # python/sglang/srt/managers/scheduler_components/dp_attn.py # python/sglang/srt/model_executor/runner/prefill_cuda_graph_runner.py
# Conflicts: # python/sglang/srt/layers/attention/deepseek_v4_backend.py
kpham-sgl
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve,
hebiao064 and
yuan-luo
as code owners
October 15, 2026 20:55
Collaborator
Author
|
/rerun-test test/registered/kernels/ops/attention/dsv4/test_mega_attention.py test/registered/kernels/ops/moe/test_mega_moe_pre_dispatch.py test/registered/e2e/models/test_deepseek_v41_flash_gb300.py test/registered/e2e/models/test_deepseek_v41_mega_attention.py test/registered/unit/server_args/test_dsv41_mega_attention.py test/registered/unit/models/test_deepseek_v4_rope_policy.py |
Contributor
|
🚀 🚀 🚀 |
hnyls2002
approved these changes
Oct 15, 2026
Collaborator
Author
|
/rerun-test test/registered/kernels/ops/attention/dsv4/test_mega_attention.py test/registered/e2e/models/test_deepseek_v41_flash_gb300.py |
Contributor
|
🚀 🚀 |
akhilg-nv
added a commit
to akhilg-nv/sglang
that referenced
this pull request
Oct 16, 2026
Resolve conflicts with sgl-project#43922 (MegaAttention) by keeping both sides. After sgl-project#41303 floors the bounded-replay tail at seq_len - SWA_WINDOW, tail rows bound their SWA columns by the floored swa_topk_lengths instead of the tail offset. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 5 tasks
detain
added a commit
to detain/sglang
that referenced
this pull request
Nov 11, 2026
… commits since 2a6c204 @ merge-sgl-project#5) Conflicts: 110 files (106 content / 4 add-add / 0 modify/delete) at the settled 321 tip 2d87757 -- vs merge sgl-project#5's 167; the smaller count despite 950 commits (merge sgl-project#5: 1,120) is the merge-era's re-plant landing INSIDE upstream's new window (many fork families -- qwen4 varlen, fast_file, hicache-liveness, the 209-218 controller semantics -- now collide as DUAL IMPLEMENTATIONS: upstream grew the same families independently in the window). By class: A 7 (auto-takes-upstream, dedupe-verified), B 36 (mechanical union/custom splices), C 46 (upstream structure taken, fork hunks extracted for re-plant), D 21 (fork-owned flips + dual-impl adjudications, incl. the whole fast_file family). 228 conflict regions total: 69 union (all def/class-collision-checked), 118 take-upstream (104 marked, 14 dedupe-verified), 25 keep-fork (17 fold-marked, 8 strict supersets), 16 custom import/region splices. 121 TODO(merge6) markers planted (tree census): b1 12 / b2 23 / b3 18 / b4 39 / b5 17 / b6 12. (Resolver census at region-resolution was 117; the cascade-repair grafts below added the rest.) REPLANT INVENTORY: /tmp/opencode/merge6-dossier/ replant/ -- per conflicted file: <name>.fork-hunks.patch (full 2a6c..321 delta), <name>.upstream-side.patch (full 2a6c..eb73 delta), <name>.ours-dropped.txt / <name>.theirs-dropped.txt region snapshots, MANIFEST.tsv (file, zone, regions, kinds, fork-hunk counts, per-region notes). Work records (conflict census JSON, decision tables, class table, logs) under .../work/. D-list outcomes (must-not-auto-resolve, handled deliberately): - sgl-project#45520 (entry 302): STILL OPEN upstream at eb73a50 (gh-verified + ZERO "sgl-project#45520" strings in the +950 window). Entry-230's fail-safe layer is UNTOUCHED and stays (standard.py warn-once + published-auto guards intact; the re-apply rule armed in CAVEATS was NOT needed this merge). - sgl-project#44590 (entry 228): the window did NOT move the floor further -- upstream pyproject stays sglang-kernel==0.4.10 (absorbed at merge sgl-project#5 via sgl-project#43922) and the engine assert_pkg_version stays 0.4.9 in BOTH trees; the _load_inline_fragment_probes_available() probe never existed on either side (docs-mention only). Nothing to re-assert; both pins kept byte-identical. - flashinfer_cutlass.py (fork-owned per merge-sgl-project#5 flip): did NOT conflict; 56 b12x refs intact, dispatcher reads untouched. - modelopt_quant sgl-project#44993/sgl-project#44994-ERA B12X W4A16 arms: the fork's defer-swizzle/b12x conditions at L2941-2996 are CONTESTED against upstream's skip_swizzled_blockscales rewrite -> took upstream, b5 markers + region snapshots (boot-integrity fields live in the fork-owned cutlass file, which survived; the b12x selection ARMS need the B5-style re-plant). - DUAL-IMPLEMENTATION FAMILIES (the new pattern of this merge; upstream grew the same features the fork replanted -- take-upstream + fold-diff replant, NEVER a silent pick): kernels/ops/mamba/qwen4_short_conv.py + its test suite, srt/models/qwen4_exp.py varlen trio, mem_cache/storage/fast_file/fast_file_store.py + test_hicache_fast_file_unit.py, test_hicache_sidecar_restore.py, fused_moe_triton/layer.py nvfp4-deferred clause, tokenizer_manager _validate_top_logprobs_num, hicache_best_practices.mdx. All fork-side versions snapshotted; replant batches diff ours-dropped.txt against the taken upstream. - environ.py: took upstream's SGLANG_EXACT_CHUNK_FILL removal; kept ONLY the fork-added SGLANG_SPLIT_PREFILL_AT_MAMBA_FORK line (custom splice). - entry-219 gauge schema: per-pool hicache_host_pool_{used,total}_tokens names SURVIVED the auto-merge (metrics_collector/hicache_pool_stats/metrics_reporter/ urc all intact); the marked b3 controller regions must RE-VERIFY the producer dict end-to-end at re-plant, not assume it. Cascading silent-auto-merge repairs (files NOT in the conflict set, broken by auto-merge splices -- all found by the ruff-F821/check_* gates, all fixed here): utils/common.py upstream prune RE-HOMED the fork's get_mixed_precision_moe_quant_algos into configs/quant_utils.py (next to the moved siblings) + the make_layers empty_cache into layers/utils/layer_list.py, importers rewired; mem_cache/pool_host/base.py silently LOST the entry-sgl-project#44462-era host_memory_budget_bytes() helper whose caller survived -- grafted back; model_executor/runner/eager_runner.py CP helpers retargeted to upstream's NEW layers/cp/utils (cp_shard_model_inputs/cp_gather_after_forward) replacing the retired runner_utils.cp_extend pair; runner/flashinfer_autotune.py + qsa/mqa.py + modelopt_quant.py import retargets for the utils/device + layers/dp_attention move; mem_cache/memory_pool.py lossless-verify tuple buffers re-grafted around upstream's replayssm skip-chain; unified_radix_cache.py host-capacity deadline preamble re-grafted (marker kept); qwen4_exp.py _use_qwen4_direct_decode re-grafted (its kernels survived); qwen4_exp_ple_table.py _HOST_PAGE_TABLES memo dict re-grafted; rotary_embedding/factory.py get_rope param restored; multimodal_gen forward_context teacache_plan param restored + server_args.py Literal import; parallel_executor.py rebuilt as fork-owned + upstream's raise_if_cancelled guards folded into the fork loop structure; hybrid_cache_controller.py _reduce_prefetch_ack if/zero_ splice repaired; python_bindings.rs pyo3 signature REORDERED to match the unioned fn new() argument order (mamba_value_seqlen position -- a positional-bind footgun, fixed pre-commit); test_io_struct.py get_context/MAX_PARALLEL_SAMPLES imports; stat_loggers_di + test_flashinfer_autotune_sync + fused_lora_compose + tp_worker + compressed_tensors + minimax_h3 + hc_mix + scheduler_mixin + pool_configurator + scheduler/tokenizer_manager import prunes/grafts. Gates at commit (CVD=9, prod venv, worktree PYTHONPATH): import sglang OK; check_registered_tests / check_no_bare_pytest_main / check_no_registered_tests_in_package ALL rc=0; ruff (F401,F821,F823,UP037 @ v0.17.1 vs pinned 0.15.1) ZERO new errors on the 3,269 merge-touched .py -- the residual 161 are BYTE-IDENTICAL INHERITED rows present at BOTH parents (kernels/aot, api_types, mm entrypoints/utils, etc.; 0.17-only detections, not merge damage); ruff format clean on the same set; py_compile clean; CARGO sglang-radix-tree check+test GREEN: 966 passed / 0 failed / 1 ignored (vs merge-sgl-project#5-era 943P -- upstream grew the suite +23; NOTE the crate is now `exclude`d from the rust/ workspace with extension-manifests metadata -- `cargo -p sglang-radix-tree` from rust/ no longer works; run inside the crate). NON-ADOPTIONS honored: sglang-kernel floor 0.4.9 (engine assert) untouched; sgl-project#45520 not brought (fail-safe layer intact by rule). Re-plant batches owed (per marker zones): B2-2026 test re-home (23), B3-2026 mem_cache/controllers/rust (18), B4-2026 scheduler/managers/runner (39), B5-2026 moe/quant/kernels/qwen4 (17), B6-2026 environ/arg_groups/docs re-pins (12), B1-2026 diffusion folds (12). PROD BOOT FORBIDDEN until the B3/B4 zones re-plant the entry-209/218 controller semantics (the trailing_endpoint gate will read RED at this commit, exactly as at merge-sgl-project#5's damage state).
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.
Integrate MegaAttention
CI States
Latest PR Test (Base): ❌ Run #38822011188
Latest PR Test (Extra): ❌ Run #38822011044
Latest PR Test (AMD ROCm 10): ❌ Run #38822011012