Repository navigation
[None][feat] modeling_v2 qwen4_exp: PLE host table per rank, per server or per node - #22077
Closed
Wanli-Jiang wants to merge 10 commits into
Closed
Wanli-Jiang wants to merge 10 commits into
Wanli-Jiang wants to merge 10 commits into
Conversation
…kpoint's shapes Family operations of qwen4_exp gain what the Qwen3.8-Flash-Next-FP8 target needs, without changing what the NVFP4 target launches: - hc_lowrank_act, renorm_moe_routing_op, fp8_quantize_1x128: certified cells under CUDA-graph capture at the FP8 target's decode batches. - qsa_paged_index_scores: opt-in prefill query-tile path and wide split (prefill_query_tile=, wide_split=; both default off, so the NVFP4 target's launches are unchanged), one-row-tile variant, no batch specialization of the group kernel, memory-clobbering PDL wait. - qsa_topk_expand_decode: opt-in ordered wide launch (ordered_wide=, default off). - ple_gate_conv_inject_norm, qwen4_exp_hc_up_gate_mean, qwen4_exp_hc_inject_norm, spec_rollback_commit: new parameters, defaulted to the current behavior. - jit_variants: warms the Triton variants a family op launches, so no variant compiles in a served step. - fused_sigmoid_mul_inplace, rms_norm_gated_token_major: direct_launch= (default off), the op's own launch without the custom-op dispatch, same results. - The family operations the FP8 target calls as they are (causal_conv1d_update, gdn_decode_rows_gated_norm, gdn_prefill_conv_post, bf16_to_fp32) list the FP8 target's shapes in their tests. Signed-off-by: Wanli Jiang <[email protected]>
… TP1/TP2/TEP2/DEP2/TP4/TEP4/DEP4 on GB300 One modeling_v2 target, qwen4_exp/qwen3_8_flash_next_fp8__sm_103__unified, serves Qwen3.8-Flash-Next-FP8 (routed experts FP8 with 128x128 block scales, bf16 elsewhere) on GB300 at every single-node layout routing admits for it: tp1, tp2/tp4, tep2/tep4 and dep2/dep4, with CUDA graphs, the overlap scheduler, one-model MTP-Eagle (1-7 drafts) and IndexShare, KV cache auto/FP8/NVFP4, a bf16 recurrent-state cache, chunked prefill, block reuse with recurrent-state snapshots, the breakable prefill CUDA graph under attention TP, disaggregated serving and image and video input. routing.py sends a checkpoint the engine resolves as FP8_BLOCK_SCALES to this target at the NVFP4 target's layouts plus tp2 and tep2; the target's check_deployment declines the checkpoints and engine choices it does not run. Every other checkpoint routes as before. The target's own CUDA kernels build into the family library (models/qwen4_exp/csrc): the TP-block decode MoE (8-CTA clusters, one launch per layer for <= 8 rows at tp4/tep4, opt-in through TRTLLM_MODELING_V2_DECODE_MOE_TPB=rr), the hyper-connection TP sum fused with the injection and grouped norm (one IPC Lamport launch on the stock all-reduce workspace), and the one-launch decode routing + 1x128 quantization in front of the trtllm-gen FP8 block-scale MoE runner. The prefill experts use a target copy of the CuTe blockwise GEMM with a contiguous grouped mode. The target calls the catalog's cublas_mm, thop_attention and fused_qk_norm_rope and the family's operations directly, with its shapes as TARGET_CELLS in those operations' tests; its own ops/ holds only the operations it runs differently. The TP sum and the attention-DP gather and scatter are the shared catalog/comm entries. Under attention DP the MoE round trip is the all-gather / reduce-scatter; with TRTLLM_MODELING_V2_MOE_ALLTOALL=1 it is instead an all-to-all dispatch / combine on the stock NVLink one-sided MoE all-to-all (ops/comm/moe_a2a__dp_dispatch_combine), a reference of that path. Unit tests (tests/unittest/_torch/modeling_v2/models/qwen4_exp/<target>/) cover routing, the core and pool layout per rank, rank-local weight shards, speculative rollback, the in-forward snapshot, the vision tower against Hugging Face, every target operation's certified cells and the 2- and 4-rank collectives, the all-to-all round trip included. The accuracy class TestModelingV2Qwen38FlashNextFp8Sm103Unified (tests/integration/defs/accuracy/modeling_v2/qwen4_exp/<target>/test_accuracy.py) runs GSM8K with three drafts, block reuse and chunked prefill at tep4 (FP8 KV, breakable prefill graph) and at dep4 (also with the all-to-all round trip), and disaggregated dep2, against the FP8_BLOCK_SCALES references. Signed-off-by: Wanli Jiang <[email protected]>
…mat to the FP8 target's native code Signed-off-by: Wanli Jiang <[email protected]>
…vous files without following symlinks The rendezvous directory (default /dev/shm) is writable by every user of the host. The lock, descriptor and temporary descriptor files are now opened with O_NOFOLLOW, created 0600 (the temporary one with O_EXCL), and read only when the calling uid owns them. Resolves bandit B108 on the default directory. Signed-off-by: Wanli Jiang <[email protected]>
…eference, check gdn_in_proj_conv's bf16 conv operands Signed-off-by: Wanli Jiang <[email protected]>
…inject-norm warps test Signed-off-by: Wanli Jiang <[email protected]>
…ize support and precompiles Signed-off-by: Wanli Jiang <[email protected]>
…ot run, honor PDL and all-reduce settings Signed-off-by: Wanli Jiang <[email protected]>
TRTLLM_MODELING_V2_PLE_SHARED_HOST mapped one host copy of the PLE n-gram table per node through a rendezvous in /dev/shm and pidfd_getfd. It needs ptrace rights over the owner, holds a lock for the whole weight load and keys the table by sampled rows. Remove it: the FP8 target keeps one host-resident copy per rank, as the NVFP4 target does. A family-level replacement that works for both targets follows separately. Signed-off-by: Wanli Jiang <[email protected]>
…er or per node The PLE n-gram table (47.7 GiB of FP8 rows on Qwen3.8-Flash-Next) is host-resident with one copy per rank. qwen4_exp/ple_host_table.py stores it as TRTLLM_MODELING_V2_PLE_HOST_TABLE says, for both targets: * rank (default): one private copy per rank, as before. * server: the rows are cut into 8 fixed chunks; under attention TP each rank stores only its chunks (tp 2: 4, tp 4: 2), the n-gram gather reads those rows and writes zeros for the others (ple_ngram_embed's new row_window), and the target sums the gathered rows over the TP group. Every element has one nonzero term, so the sum is exact. One copy per server; no inter-process state. * node: each chunk is one CUDA VMM allocation on host NUMA memory. The first process of the host to bind the chunk's abstract Unix socket creates and fills it and passes its POSIX fd to the others with SCM_RIGHTS (qwen4_exp/chunk_broker.py: peers of another uid are refused through SO_PEERCRED, an owner that exits or aborts hands the chunk to its waiters, nothing is written to the filesystem). Every rank maps all chunks back to back and gathers locally. A rank fills the chunks of its share first, so the ranks of a server load the table in parallel; servers on one node (disaggregated context and generation) share it. The table is keyed by the checkpoint directory's safetensors files (names, sizes, modification times), and attached chunks are checked against the checkpoint's rows. server needs attention TP over a size dividing 8, else it runs as rank. When a rank cannot take part in node (no VMM host NUMA allocation, no checkpoint identity, no owner within the timeout), every rank of the server runs server instead, or rank. The FP8 target keeps its PLE front on the main stream when the rows are summed. Tests: the chunk layout, the broker across processes (publish, late attach, owner exit), the four storage outcomes against the checkpoint's bytes, and row-window shares that sum bitwise to the whole table's output on both gather kernels. Signed-off-by: Wanli Jiang <[email protected]>
1 task done
Collaborator
|
Could you please rebase this branch onto the latest upstream |
Collaborator
|
Hi, heads-up: #22286 has merged, so ModelingV2 now lives at Since this PR touches modeling_v2, please rebase it onto the latest main. You can use these migration commands to move any files you added under the old directory and update any remaining references to the old path. |
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.
@coderabbitai summary
Description
Stacked on #21621 (the Qwen3.8-Flash-Next FP8 modeling_v2 target). Until that merges, the diff here also shows its commits; this PR is the last two:
[None][chore] modeling_v2 qwen4_exp fp8: drop the shared host PLE tableremoves the FP8 target'sPLE_SHARED_HOSTsharing (flock, a JSON descriptor in a shared directory,pidfd_getfd).[None][feat] modeling_v2 qwen4_exp: PLE host table per rank, per server or per nodereplaces it with one implementation for both Qwen3.8-Flash-Next targets.The PLE n-gram table is 47.7 GiB of FP8 rows (320,001,536 x 160) and lives in host memory, one private copy per rank.
qwen4_exp/ple_host_table.pycuts its rows into 8 fixed chunks (each a multiple of 2 MiB) and stores them asTRTLLM_MODELING_V2_PLE_HOST_TABLEsays:rank(default)servernodeserveris exact: every element has one nonzero term.ple_ngram_embedgainsrow_window=(lo, hi, base); the default reads the whole table, sorankand other callers are unchanged. It needs attention TP over a size that divides 8; under attention DP it runs asrankand says so in the log. The FP8 target keeps its PLE front on the main stream when the rows are summed.node(qwen4_exp/chunk_broker.py): the first process to bind a chunk's abstract Unix socket creates and fills the chunk's allocation, then passes its POSIX fd withSCM_RIGHTSto the processes that connect. Peers of another uid are refused throughSO_PEERCRED. When the owner exits or aborts before publishing, the kernel closes its socket and a waiter takes the chunk over. Nothing is written to the filesystem, and no ptrace permission is needed. Each rank fills the chunks of its own share first, so the ranks of a server load the table in parallel, and servers on one node (disaggregated context and generation) share one copy.node(no VMM host NUMA allocation, no checkpoint identity, no owner within the timeout), every rank of the server agrees and runsserverinstead, orrank.Compared with the removed FP8 sharing: no ptrace requirement (it fell back to one copy per rank without it), no lock held across weight loading, no files to own or clean up, an identity that does not rest on sampled rows, both targets instead of FP8 only, and a fallback of one copy per server instead of per rank.
Evidence (GB300, 4 GPUs a node, GSM8K with real acceptance):
rankservernoderank(attention DP)node: each process created 2 chunks and attached 6. Disaggregatednode: the two context ranks created 4 and attached 4, the two generation ranks attached all 8.rankabout 293 GiB,server143 GiB,nodeabout 143 GiB (theory: 3 x 47.7 GiB less).rankand 62.6 / 69.1 GiB withserver/node.serverTP sum.Test Coverage
qwen3_8_flash_next_fp8__sm_103__unified/test_weights.py:test_host_table_chunks_cover_the_rows: chunk alignment, coverage, and the shares of every TP size (CPU).test_chunk_broker_hands_over: across processes, a waiter attaches to what the owner publishes and so does a late process, or the waiter binds the socket and creates the chunk itself when the first process exits before publishing; no files are left (CPU).test_host_table_modes[rank|server|node|node-fallback]: mode, window, host residency, and bytes equal to the checkpoint's (GPU;nodeneeds VMM host NUMA).ops/ple/test_modeling_v2_ple_ngram_embed.py::test_row_windows_sum_to_the_whole_table: both gather kernels, 2 and 4 ranks, from a slice and from the whole table; each share equals the reference and the shares sum bitwise to the whole table's output.ops/ple, 205 passed; the accuracy runs in the table above.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.