Enable PCP for GDN models - #3386
Open
wenxindongwork wants to merge 7 commits into
Open
Conversation
DescriptionStart with a short description of what the PR does and how this is a change from The rest of the description includes relevant details and context, examples:
If the change fixes a Github issue, please include a link, e.g.,: TestsPlease describe how you tested this change, and include any instructions and/or ChecklistBefore submitting this PR, please make sure:
|
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
August 17, 2026 22:19
4b787e1 to
50a4260
Compare
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
5 times, most recently
from
August 31, 2026 18:15
ba01674 to
4bdf97d
Compare
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
August 31, 2026 20:29
4bdf97d to
bdfeb83
Compare
wenxindongwork
marked this pull request as ready for review
August 31, 2026 20:36
wenxindongwork
requested review from
a1yssan13,
gpolovets1,
gxd3,
jrplatin,
kyuyeunk,
lk-chen,
mrjunwan-lang,
sixiang-google and
vanbasten23
as code owners
August 31, 2026 20:36
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
September 2, 2026 19:54
ded8f5e to
4d62508
Compare
Collaborator
|
Can you please run the quality/accuracy test at pcp=4,tp=2 (where rest of the performance was benchmarked) to ensure we are not regressing even from the 0.80 score on pcp=8 |
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
September 3, 2026 19:46
89fca44 to
a0e9dd7
Compare
Collaborator
Author
|
pcp=4,tp=2 also gives 0.832 lm_eval result |
bhuvanpkaruturi
approved these changes
Sep 3, 2026
weiyu0824
reviewed
Sep 3, 2026
weiyu0824
reviewed
Sep 3, 2026
weiyu0824
reviewed
Sep 3, 2026
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
September 4, 2026 07:54
e9ca434 to
73b5b9c
Compare
weiyu0824
approved these changes
Sep 4, 2026
jrplatin
approved these changes
Sep 4, 2026
gxd3
approved these changes
Sep 4, 2026
wenxindongwork
enabled auto-merge (squash)
September 4, 2026 18:37
Makes Qwen3.5-397B (hybrid GDN) run end-to-end under prefill context parallelism (pcp=4 x tp=2, MODEL_IMPL_TYPE=vllm). Design: PCP is attn_dp whose data axis splits within a request. In the MoE/GDN domain tokens are replicated over pcp and weights shard over pcp as extra tensor parallelism (DENSE_TENSOR/MOE_TENSOR/EXPERT include pcp; DENSE_DATA is the dp-without-pcp token axis). Only the attention domain shards tokens over pcp; GSPMD inserts the boundary collectives. - GDN: shard_map token/metadata/state specs use DENSE_DATA (the scan needs the full sequence per rank); dp_size from DENSE_DATA only, so pcp is not conflated with attn_dp; un-permute the head-tail rank-ordered buffer to token order before the scan and back after. - Residual stream replicated over pcp: attention slices it in (DENSE_DATA -> ATTN_DATA) and gathers out. Deferred shared-expert / MoE partials are carried as an honest [n_shards, T, H] stack and summed once (sum_partials), never returned unreduced through a replicated out_spec (that miscompiles under GSPMD). - Sharding readability: SEQUENCE->DENSE_DATA, SEQ_TENSOR->DENSE_TENSOR, PREFILL_CONTEXT->PCP; matmul input/output shardings passed explicitly. - Drop the stale pcp_size arg from the _select_from_array_fn warmup calls in the compilation manager (crashed precompiled serving). - Keep the "For GQA/MQA," prefix on the KV-head divisibility error. Requires max-num-seqs=1 (single-request PCP) and a vLLM with the pcp block-size scaling. Signed-off-by: wenxindongwork <wenxindong@google.com>
… and quantized matmul rank - QuantLinearConfig: derive bias_sharding/n_shards from output_sharding[1] instead of weight_sharding[1]; a batched einsum weight can have an empty/ND spec, so weight_sharding[1] raised IndexError (test_batched_einsum_tnh_anh_tna). - _is_attention: also exclude linear_attention (not just linear_attn) from the prefix match, since linear_attn is not a substring of linear_attention. - sharded_quantized_matmul: pad input/output specs with replicated batch dims for arbitrary-rank activations, mirroring sharded_matmul. Signed-off-by: wenxindongwork <wenxindong@google.com>
main's pcp_vs_tp_benchmark.py referenced ShardingAxisName.PREFILL_CONTEXT, which this branch renamed to PCP; update it so the name resolves. Signed-off-by: wenxindongwork <wenxindong@google.com>
Per review: BATCH == DENSE_DATA == ('data', 'attn_dp', 'attn_dp_expert')
(and 'data' in the 2D config), so the two names were duplicates. Drop BATCH
and shard the KV-cache batch/block (leading) axis on DENSE_DATA everywhere
(kv_cache, cp_attention, deepseek v3/v4, model_loader, runner).
Signed-off-by: wenxindongwork <wenxindong@google.com>
Signed-off-by: wenxindongwork <wenxindong@google.com>
Signed-off-by: wenxindongwork <wenxindong@google.com>
… types Restores the base-config leniency (a bare LinearBase / unusual layer warns and defaults to replicated sharding) instead of raising NotImplementedError, which broke test_compressed_tensors_w4a4_nvfp4::test_get_scheme (it mocks a generic LinearBase). Real layers still hit the specific Row/Column/Replicated branches. Signed-off-by: wenxindongwork <wenxindong@google.com>
wenxindongwork
force-pushed
the
wxd-qwen35-pcp
branch
from
September 6, 2026 04:35
b6829b6 to
7a3c35d
Compare
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
Makes Qwen3.5-397B (hybrid GDN) run end-to-end under PCP (
MODEL_IMPL_TYPE=vllm).Design: PCP replicates tokens throughout MoE, GDN, and splits the tokens dimension in Full Attention. I.e. PCP acts just like TP for all layers other than full attention where it shares the tokens instead of heads.
Performance
Qwen3.5-397B-A17B-FP8, fp8 KV cache, single request, 4k chunk, v7x-8. Prefill latency via
examples/tpu_profiling.py(2 warmup iters + 1 profiled pass = pure execution).Non-PCP parity vs main
To confirm this stack does not regress non-PCP shardings, an online-serving benchmark on tp8 + attn_dp + EP (
enable_dp_attention:true), 512 prompts, 8k in / 1k out, concurrency 256, was run on this branch vsorigin/main.Quality
Qwen3.5-35B-A3B-FP8, gsm8k (full 1319 unless noted), fp8 KV, 8 chips
pcp8 = 0.80 is pre-existing bug before this PR, which will be resolved in a separate PR.
Repro
The full commands each config was run with. All need
PYTHONPATHpointing at the PCP-patched vLLM (SingleTypeKVCacheManager.block_size *= pcp_world_size+ the scheduler passing the realpcp_world_size).1. Prefill latency (Performance table)
examples/tpu_profiling.py—SKIP_JAX_PRECOMPILE=1+ 2 warmup iters ⇒ the profiled pass is pure execution. 256k (shown forpcp4xtp2):SKIP_JAX_PRECOMPILE=1 PROFILE_SINGLE_DEVICE=1 PYTHON_TRACER_LEVEL=0 \ MODEL_IMPL_TYPE=vllm NEW_MODEL_DESIGN=1 USE_MOE_EP_KERNEL=0 \ ATTN_BUCKETIZED_NUM_REQS=true ATTN_CUSTOM_NUM_REQS_BUCKETS=4 \ ONEHOT_MOE_PERMUTE_THRESHOLD=32768 VLLM_MOE_CHUNK_SIZE=256 SLICE_ROPE_CACHE=1 \ DP_SCHED_BATCH_PREFILL=false NUM_PRECOMPILE_WORKERS=8 VLLM_ENGINE_READY_TIMEOUT_S=7200 \ LIBTPU_INIT_ARGS=' --xla_tpu_use_minor_sharding_for_major_trivial_input=true --xla_tpu_enable_sparse_core_collective_offload_reduce_scatter=false --xla_tpu_ars_combiner_threshold_in_bytes=0 --xla_tpu_enable_async_collective_merger=false --xla_tpu_check_legacy_constraints_in_reduce_scatter_legalizer=false' \ python examples/tpu_profiling.py \ --model=Qwen/Qwen3.5-397B-A17B-FP8 \ --max-model-len=262144 --max-num-batched-tokens=4096 --max-num-seqs=1 \ --gpu-memory-utilization=0.9 --language-model-only --kv-cache-dtype=fp8 \ --enable-expert-parallel --block-size=256 --enable-chunked-prefill \ --input-len 262134 --output-len 10 --batch-size 1 --num-iters-warmup 2 --num-iters 1 \ --profile-result-dir ./prof \ --tensor-parallel-size=2 --prefill-context-parallel-size=4Swap the last line for the other configs:
1M: add
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1to the env, set--gpu-memory-utilization=0.95 --max-model-len=1048576 --input-len 1048566, and add--hf-overrides='{"rope_scaling":{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":262144},"max_position_embeddings":1048576}'(YaRN ×4 makes 1M positions valid; latency-only).2. Quality (gsm8k)
Serve Qwen3.5-35B-A3B-FP8, then
lm_eval. Clear~/.cache/vllm/xla_cachefirst after any libtpu change (a stale cache silently garbles fp8-KV). Shown forpcp8(--tensor-parallel-size=1 --prefill-context-parallel-size=8):Other configs:
tp8=--tensor-parallel-size=8;attn_dp8=--tensor-parallel-size=8 --additional_config='{"sharding":{"sharding_strategy":{"enable_dp_attention":true,"attn_dp_size":8}}}'(bumpnum_concurrentfor the DP configs).3. Non-PCP parity (online serving)
Serve Qwen3.5-397B-FP8 (tp8 + attn_dp + EP), precompiled at startup (no
SKIP_JAX_PRECOMPILE), thenbenchmark_serving.py. Run once per checkout (branch vsorigin/main) with vLLM held constant: