Skip to content

Support MLA for DeepSeek-V2 with Triton - step 1 - #905

Merged
zhyncs merged 7 commits into
sgl-project:mainfrom
ispobock:mla
Aug 4, 2024
Merged

zhyncs merged 7 commits into
sgl-project:mainfrom
ispobock:mla

Conversation

@ispobock

@ispobock ispobock commented Aug 3, 2024 •

Copy link
Copy Markdown
Collaborator

Motivation

MLA implementation.

Modification

  • MLA forward
  • memory & triton kernel adaptation
  • benchmark & evaluation

@zhyncs

zhyncs commented Aug 3, 2024

Copy link
Copy Markdown
Contributor

@ispobock Nice work!

@zhyncs zhyncs self-assigned this Aug 3, 2024
@zhyncs
zhyncs marked this pull request as draft August 3, 2024 18:24
@zhyncs zhyncs added the wip label Aug 3, 2024
@merrymercy
merrymercy marked this pull request as ready for review August 4, 2024 02:19
@ispobock

ispobock commented Aug 4, 2024 •

Copy link
Copy Markdown
Collaborator Author

Logits diff

HF:

prefill logits tensor([14.9297, 12.5312, 11.5078,  ...,  3.4199,  3.7383,  3.7520], device='cuda:0')
prefill logits tensor([14.2188, 11.8984, 11.7734,  ...,  3.7812,  4.0625,  4.0664], device='cuda:0')
prefill logits tensor([19.5938, 13.4219, 11.8906,  ...,  3.6426,  3.6973,  3.8281], device='cuda:0')

sglang MLA:

prefill logits (final) tensor([[14.8750, 12.5000, 11.5000,  ...,  3.3594,  3.6719,  3.6875],
        [14.0625, 11.8125, 11.7500,  ...,  3.5000,  3.7656,  3.7812],
        [19.3750, 13.2500, 11.7500,  ...,  3.4844,  3.5312,  3.6562]],
       device='cuda:0')

Benchmark

  • model: DeepSeek-V2-Lite
  • dataset: ShareGPT
  • num_prompts: 5000
  • A100-80G

main branch + triton kernel:

============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    128.0
Successful requests:                     5000
Benchmark duration (s):                  561.05
Total input tokens:                      1187865
Total generated tokens:                  1089941
Total generated tokens (retokenized):    1088599
Request throughput (req/s):              8.91
Input token throughput (tok/s):          2117.20
Output token throughput (tok/s):         1942.66
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   229316.60
Median E2E Latency (ms):                 234510.04
---------------Time to First Token----------------
Mean TTFT (ms):                          205445.14
Median TTFT (ms):                        211642.51
P99 TTFT (ms):                           413023.93
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          117.57
Median TPOT (ms):                        113.63
P99 TPOT (ms):                           307.47
---------------Inter-token Latency----------------
Mean ITL (ms):                           1079.55
Median ITL (ms):                         80.03
P99 ITL (ms):                            681.20
==================================================

main branch + flashinfer kernel:

============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    128.0
Successful requests:                     5000
Benchmark duration (s):                  488.49
Total input tokens:                      1187865
Total generated tokens:                  1089941
Total generated tokens (retokenized):    1088617
Request throughput (req/s):              10.24
Input token throughput (tok/s):          2431.72
Output token throughput (tok/s):         2231.26
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   217337.71
Median E2E Latency (ms):                 221728.97
---------------Time to First Token----------------
Mean TTFT (ms):                          195409.99
Median TTFT (ms):                        200734.20
P99 TTFT (ms):                           401025.53
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          106.12
Median TPOT (ms):                        103.63
P99 TPOT (ms):                           183.47
---------------Inter-token Latency----------------
Mean ITL (ms):                           1023.47
Median ITL (ms):                         71.94
P99 ITL (ms):                            675.86
==================================================

MLA (this PR):

============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    128.0
Successful requests:                     5000
Benchmark duration (s):                  454.67
Total input tokens:                      1187865
Total generated tokens:                  1089941
Total generated tokens (retokenized):    1088651
Request throughput (req/s):              11.00
Input token throughput (tok/s):          2612.61
Output token throughput (tok/s):         2397.23
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   157306.30
Median E2E Latency (ms):                 135071.76
---------------Time to First Token----------------
Mean TTFT (ms):                          4326.20
Median TTFT (ms):                        1761.04
P99 TTFT (ms):                           22399.46
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          1415.77
Median TPOT (ms):                        890.21
P99 TPOT (ms):                           6931.18
---------------Inter-token Latency----------------
Mean ITL (ms):                           744.06
Median ITL (ms):                         541.06
P99 ITL (ms):                            3870.68
==================================================

reproduce:

# main branch triton
python3 -m sglang.launch_server --model-path DeepSeek-V2-Lite --port 30000 --trust-remote-code --disable-flashinfer --disable-radix-cache
# main branch flashinfer
python3 -m sglang.launch_server --model-path DeepSeek-V2-Lite --port 30000 --trust-remote-code --disable-radix-cache
# mla
python3 -m sglang.launch_server --model-path DeepSeek-V2-Lite --port 30000 --trust-remote-code --disable-radix-cache --enable-mla

python3 -m sglang.bench_serving --backend sglang --tokenizer DeepSeek-V2-Lite --dataset-path ShareGPT_V3_unfiltered_cleaned_split.json --num-prompts 5000 --request-rate 128

Evaluation

mmlu average accuracy:

  • main branch: 0.579
  • MLA: 0.579

gsm8k accuracy:

  • main branch: 0.360
  • MLA: 0.365

reproduce:

# main branch
python3 -m sglang.launch_server --model-path DeepSeek-V2-Lite --port 30000 --trust-remote-code --disable-radix-cache
# mla
python3 -m sglang.launch_server --model-path DeepSeek-V2-Lite --port 30000 --trust-remote-code --disable-radix-cache --enable-mla

python3 benchmark/mmlu/bench_sglang.py
python3 benchmark/gsm8k/bench_sglang.py

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

Hi @ispobock Very impressive throughput improvement, may you test the eval, such as MMLU and gsm8k, and also do a regression test on Llama 3 8B Instruct with/without FlashInfer? Thanks.

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

Hi @ispobock You may add --disable-radix-cache to disable the tree cache.

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

After completing the benchmark and evaluation, we might add a switch to the MLA feature, keeping FlashInfer as the default for now on DeepSeek V2. Currently, even the main branch struggles with running DeepSeek V2 on H100s due to issues with Triton's implementation. #913

We could look into adding weight fusion support in another PR. Special thanks to @ispobock's contribution and @grimoire for previously implementing the MLA version of DeepSeek V2 in LMDeploy PyTorch Engine, which has been incredibly helpful and inspiring. https://github.com/InternLM/lmdeploy/pull/1621/files

The initial MLA implementation on Triton significantly outperforms MHA on Triton. We're considering incorporating MLA Attention into FlashInfer moving forward and would appreciate if @ispobock could explore this possibility. Looking forward to an update from @yzh119.

Do you have any suggestions? Thanks. @merrymercy @Ying1123 @hnyls2002 @yzh119

@zhyncs zhyncs removed the wip label Aug 4, 2024
@zhyncs zhyncs changed the title Support MLA for DeepSeek-V2 Support MLA for DeepSeek-V2 with Triton - step 1 Aug 4, 2024
@zhyncs zhyncs mentioned this pull request Aug 4, 2024
3 tasks done
@ispobock

ispobock commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator Author

You may add --disable-radix-cache to disable the tree cache.

Benchmark result is updated.

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

A100 80G
ShareGPT 1k

# vLLM
python -m vllm.entrypoints.openai.api_server --model  deepseek-ai/DeepSeek-V2-Lite --disable-log-requests --trust-remote-code --max-model-len 4096
# main FlashInfer
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-Lite --disable-radix-cache --trust-remote-code
# main Triton
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-Lite --disable-radix-cache --trust-remote-code --disable-flashinfer
# MLA Triton
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-Lite --disable-radix-cache --trust-remote-code

# client
python3 -m sglang.bench_serving --backend vllm
python3 -m sglang.bench_serving --backend sglang
============ Serving Benchmark Result ============
Backend:                                 vllm
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  172.72
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215357
Request throughput (req/s):              5.79
Input token throughput (tok/s):          1367.22
Output token throughput (tok/s):         1248.36
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   84630.85
Median E2E Latency (ms):                 85899.10
---------------Time to First Token----------------
Mean TTFT (ms):                          48520.47
Median TTFT (ms):                        43484.37
P99 TTFT (ms):                           135740.63
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          191.38
Median TPOT (ms):                        190.46
P99 TPOT (ms):                           482.57
---------------Inter-token Latency----------------
Mean ITL (ms):                           394.61
Median ITL (ms):                         150.76
P99 ITL (ms):                            494.64
==================================================

# FlashInfer
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  89.33
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215327
Request throughput (req/s):              11.19
Input token throughput (tok/s):          2643.61
Output token throughput (tok/s):         2413.80
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   41187.40
Median E2E Latency (ms):                 40548.85
---------------Time to First Token----------------
Mean TTFT (ms):                          24502.59
Median TTFT (ms):                        23297.79
P99 TTFT (ms):                           62219.05
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          94.00
Median TPOT (ms):                        86.57
P99 TPOT (ms):                           263.22
---------------Inter-token Latency----------------
Mean ITL (ms):                           192.80
Median ITL (ms):                         59.62
P99 ITL (ms):                            271.23
==================================================

# Triton
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  106.50
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215344
Request throughput (req/s):              9.39
Input token throughput (tok/s):          2217.31
Output token throughput (tok/s):         2024.55
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   44904.45
Median E2E Latency (ms):                 44066.16
---------------Time to First Token----------------
Mean TTFT (ms):                          26872.67
Median TTFT (ms):                        26855.06
P99 TTFT (ms):                           67354.23
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          100.41
Median TPOT (ms):                        92.15
P99 TPOT (ms):                           278.48
---------------Inter-token Latency----------------
Mean ITL (ms):                           210.10
Median ITL (ms):                         62.88
P99 ITL (ms):                            360.94
==================================================

# Triton MLA
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  93.36
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215355
Request throughput (req/s):              10.71
Input token throughput (tok/s):          2529.41
Output token throughput (tok/s):         2309.53
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   38101.47
Median E2E Latency (ms):                 33589.46
---------------Time to First Token----------------
Mean TTFT (ms):                          7483.10
Median TTFT (ms):                        7373.59
P99 TTFT (ms):                           13939.18
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          335.31
Median TPOT (ms):                        168.04
P99 TPOT (ms):                           2129.49
---------------Inter-token Latency----------------
Mean ITL (ms):                           181.06
Median ITL (ms):                         115.35
P99 ITL (ms):                            444.42
==================================================

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

After this commit 94b1578, when we want to use MLA, we should add --enable-mla.

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

A100 80G x8
ShareGPT 1k

# main FlashInfer
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2 --disable-radix-cache --trust-remote-code --tp 8
# mla enable-mla
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2 --disable-radix-cache --trust-remote-code --tp 8 --enable-mla

# main FlashInfer
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  635.63
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215021
Request throughput (req/s):              1.57
Input token throughput (tok/s):          371.51
Output token throughput (tok/s):         339.22
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   312719.92
Median E2E Latency (ms):                 318283.73
---------------Time to First Token----------------
Mean TTFT (ms):                          289771.06
Median TTFT (ms):                        294630.15
P99 TTFT (ms):                           577199.48
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          98.64
Median TPOT (ms):                        52.54
P99 TPOT (ms):                           1393.25
---------------Inter-token Latency----------------
Mean ITL (ms):                           1467.39
Median ITL (ms):                         46.78
P99 ITL (ms):                            275.39
==================================================

# Triton MLA
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  267.62
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215061
Request throughput (req/s):              3.74
Input token throughput (tok/s):          882.36
Output token throughput (tok/s):         805.66
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   109370.04
Median E2E Latency (ms):                 108220.54
---------------Time to First Token----------------
Mean TTFT (ms):                          58931.99
Median TTFT (ms):                        38989.13
P99 TTFT (ms):                           148840.96
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          276.88
Median TPOT (ms):                        258.92
P99 TPOT (ms):                           748.81
---------------Inter-token Latency----------------
Mean ITL (ms):                           512.84
Median ITL (ms):                         185.41
P99 ITL (ms):                            720.15
==================================================

@zhyncs zhyncs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ying1123

Ying1123 commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

LGTM. Very nice work!! 🎉

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

hold on

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

@ispobock We may add a regression testing with Llama 3.

@ispobock

ispobock commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator Author

We may add a regression testing with Llama 3.

There is an issue when disabling flashinfer, let me fix it.

@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

We may add a regression testing with Llama 3.

There is an issue when disabling flashinfer, let me fix it.

ok

@ispobock

ispobock commented Aug 4, 2024 •

Copy link
Copy Markdown
Collaborator Author

Evaluated the average accuracy on mmlu by python3 benchmark/mmlu/bench_sglang.py --nsub 10:

Llama-3-8B:

  • flashinfer: 0.619
  • triton: 0.618

DeepSeek-V2-Lite:

  • flashinfer: 0.543
  • triton: 0.540
  • mla triton: 0.549

@zhyncs zhyncs changed the title Support MLA for DeepSeek-V2 with Triton - step 1 [DO NOT MERGE] Support MLA for DeepSeek-V2 with Triton - step 1 Aug 4, 2024
@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

TP cases

# flashinfer
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-lite --disable-radix-cache --trust-remote-code --tp 2

# triton
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-lite --disable-radix-cache --trust-remote-code --tp 2 --disable-flashinfer

# mla
python -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V2-lite --disable-radix-cache --trust-remote-code --tp 2 --enable-mla
python3 -m sglang.bench_serving --backend sglang

python3 benchmark/mmlu/bench_sglang.py --nsub 10
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  47.37
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215356
Request throughput (req/s):              21.11
Input token throughput (tok/s):          4984.92
Output token throughput (tok/s):         4551.58
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   20699.26
Median E2E Latency (ms):                 18888.38
---------------Time to First Token----------------
Mean TTFT (ms):                          5280.38
Median TTFT (ms):                        4278.32
P99 TTFT (ms):                           12355.53
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          140.18
Median TPOT (ms):                        87.34
P99 TPOT (ms):                           668.44
---------------Inter-token Latency----------------
Mean ITL (ms):                           98.27
Median ITL (ms):                         54.34
P99 ITL (ms):                            501.68
==================================================

subject: abstract_algebra, #q:100, acc: 0.300
subject: anatomy, #q:135, acc: 0.511
subject: astronomy, #q:152, acc: 0.586
subject: business_ethics, #q:100, acc: 0.600
subject: clinical_knowledge, #q:265, acc: 0.630
subject: college_biology, #q:144, acc: 0.646
subject: college_chemistry, #q:100, acc: 0.420
subject: college_computer_science, #q:100, acc: 0.470
subject: college_mathematics, #q:100, acc: 0.400
subject: college_medicine, #q:173, acc: 0.601
Total latency: 16.818
Average accuracy: 0.541

============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  71.50
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215353
Request throughput (req/s):              13.99
Input token throughput (tok/s):          3302.80
Output token throughput (tok/s):         3015.69
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   24554.45
Median E2E Latency (ms):                 21974.87
---------------Time to First Token----------------
Mean TTFT (ms):                          6747.84
Median TTFT (ms):                        5495.57
P99 TTFT (ms):                           14803.86
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          157.37
Median TPOT (ms):                        96.33
P99 TPOT (ms):                           698.46
---------------Inter-token Latency----------------
Mean ITL (ms):                           117.50
Median ITL (ms):                         60.15
P99 ITL (ms):                            536.09
==================================================

subject: abstract_algebra, #q:100, acc: 0.340
subject: anatomy, #q:135, acc: 0.541
subject: astronomy, #q:152, acc: 0.579
subject: business_ethics, #q:100, acc: 0.630
subject: clinical_knowledge, #q:265, acc: 0.642
subject: college_biology, #q:144, acc: 0.639
subject: college_chemistry, #q:100, acc: 0.430
subject: college_computer_science, #q:100, acc: 0.470
subject: college_mathematics, #q:100, acc: 0.400
subject: college_medicine, #q:173, acc: 0.618
Total latency: 17.655
Average accuracy: 0.553

============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Successful requests:                     1000
Benchmark duration (s):                  71.77
Total input tokens:                      236142
Total generated tokens:                  215614
Total generated tokens (retokenized):    215342
Request throughput (req/s):              13.93
Input token throughput (tok/s):          3290.49
Output token throughput (tok/s):         3004.44
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   25321.60
Median E2E Latency (ms):                 22072.11
---------------Time to First Token----------------
Mean TTFT (ms):                          6508.90
Median TTFT (ms):                        6170.12
P99 TTFT (ms):                           10115.41
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          198.78
Median TPOT (ms):                        99.93
P99 TPOT (ms):                           1205.42
---------------Inter-token Latency----------------
Mean ITL (ms):                           121.54
Median ITL (ms):                         67.46
P99 ITL (ms):                            412.39
==================================================

subject: abstract_algebra, #q:100, acc: 0.360
subject: anatomy, #q:135, acc: 0.504
subject: astronomy, #q:152, acc: 0.572
subject: business_ethics, #q:100, acc: 0.630
subject: clinical_knowledge, #q:265, acc: 0.653
subject: college_biology, #q:144, acc: 0.653
subject: college_chemistry, #q:100, acc: 0.410
subject: college_computer_science, #q:100, acc: 0.450
subject: college_mathematics, #q:100, acc: 0.410
subject: college_medicine, #q:173, acc: 0.607
Total latency: 18.795
Average accuracy: 0.550

@zhyncs zhyncs changed the title [DO NOT MERGE] Support MLA for DeepSeek-V2 with Triton - step 1 Support MLA for DeepSeek-V2 with Triton - step 1 Aug 4, 2024
@zhyncs

zhyncs commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

Conclusion:

  1. For the lite model, using tp1 is sufficient, and the default FlashInfer can be used (currently).
  2. For the v2 model, when using tp8, it is recommended to --enable-mla.

@zhyncs
zhyncs merged commit e1eae1f into sgl-project:main Aug 4, 2024
@yzh119

yzh119 commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator

Great work! I might have some bandwidth to work on flashinfer's MLA next week.

@Ying1123 Ying1123 mentioned this pull request Aug 4, 2024
15 of 29 tasks
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
shun8686 pushed a commit to shun8686/sglang that referenced this pull request Jul 8, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
…, so 411 declines have no verdict

Routing from the write-side agent (sgl-project#872) narrowed Posten 0 correctly: the store
is healthy, 24277 canonical pages live during the R7 window, and the historic
"store is empty" readings probed a path this boot does not use. So the 671
refused walks are a MATCH problem, not a content problem. The question that
follows immediately is the one nobody could answer: a walk that matches nothing
should fall through to an L3 prefetch, and prefetch was attempted on only 264
of 675 sampled walks.

THE OBVIOUS ANSWER IS WRONG, and the code says why. It is tempting to read the
411 as the same MambaComponent refusal declining twice -- one root, two numbers.
It is not:

  * The prefetch anchor IS mamba-gated, but by an aliasing the base contract
    does not describe. base_prefix_cache.py:201-210 separates `last_host_node`
    (the L3 prefetch anchor) from `best_match_node` (the validator-consensus L2
    anchor) -- two fields, two purposes. UnifiedRadixCache sets them equal under
    HiCache (unified_radix_cache.py:1443-1449). Deliberate and commented, but it
    contradicts the field's own documentation, and two fields that are
    documented different and implemented identical are a drift source (sgl-project#747's
    shape). Named, not changed here.
  * Even so, the refusal does NOT decline the prefetch. Total refusal leaves
    best_match_node at the root, and the caller admits the root on purpose:
    `locally_eligible = last_host_node.backuped or last_host_node is
    self.tree_cache.root_node` (scheduler.py:4933-4935). A cold request with no
    match is supposed to prefetch. The first term holds.
  * The second term (>= 256 new tokens) holds for agent prompts of thousands.

That leaves the rate limiter -- AND THERE THE EVIDENCE STOPS, which is the
actual finding. None of the three terms is counted or logged. The 411 declines
are silent. Nobody can attribute them from this boot, and no amount of
re-reading the log will change that.

    eligible = (locally_eligible
                and prefetch_length >= self.prefetch_threshold
                and not self.cache_controller.prefetch_rate_limited())

Three unrelated verdicts wearing one boolean, remedies in three different
files. The sgl-project#914 shape one module over: blame without a defect.

So this is an instrument and NOT a policy change. The three terms are the same
three, evaluated in the same order, with the same outcome; `eligible` is now
`reason is None`, one expression, so the predicate and its explanation cannot
drift apart the way sgl-project#747 records these very lineages drifting. The first
failing term is named rather than all of them -- a request can trip several,
and summing them would double-count exactly as
`refused_tokens_by_component` is documented to.

Not env-gated, unlike the sgl-project#904 match census. That one builds an object and
walks validators a second time, so it pays for itself only when armed. This is
one integer increment on a path that already builds a RadixKey and takes a host
lock -- and a counter you must remember to arm cannot answer "was it ever
tried", which is the whole question. `attempted` is counted alongside the
refusals so the denominator is local (sgl-project#873: a denominator reconstructed from
another log is how a narrowed candidate set reads as a decomposition), and an
unrecorded gate says "no observation" rather than a silent zero (sgl-project#829).

HYPOTHESIS, RECORDED AS ONE. prefetch_capacity_limit is `0.5 *
mem_pool_host.size` (cache_controller.py:729), and that size is not constant
across a phase flip: sgl-project#905 measured the two host tiers at 703472 rows (PP) and
30518 (TP), 23x apart, putting the TP-phase budget near 15259 tokens -- under
four prefetches of the 4096 this window actually completed, against 5
concurrent requests per flip. The order of magnitude fits 411/675, and I am
deliberately not fitting it exactly: the PP phase has ample budget, so the
number cannot come from there alone. If it holds, the same host-tier asymmetry
behind sgl-project#905's double-free is also starving the TP-phase prefetch budget -- one
defect, two effects, to be checked rather than assumed. The counter decides it
on the next boot instead of re-arguing it.

RED-FIRST, four mutants, each red, restored green (14 tests):
  revert to the shipped conjunction (no counter) ......... 4 failed
  eligible computed twice instead of derived from reason . 2 failed
  attempts not counted (denominator lost) ................ 2 failed
  no-observation reported as attempted=0 ................. 1 failed

ONE SELF-INFLICTED DEFECT, found and fixed in the same pass, recorded because
the form is evidently easy to commit. My first version of
test_the_rate_limit_check_is_still_called_at_most_once counted occurrences in
the function's RAW source and went red because a PRE-EXISTING comment at :2674
mentions `prefetch_rate_limited()`. That is the sgl-project#908 substring defect -- prose
used to reach a verdict about code -- in a test of mine, an hour after I
rejected the same form in someone else's patch. Comment lines are now stripped
before counting.

GATE test/registered/unit/mem_cache serial, CVD="": 3 failed, 1950 passed,
1658 skipped. Both axes agree (summary 3, ANSI-stripped extraction 3). Two are
test_acceptance_emitters_758::RefillTiming, baseline-proven pre-existing
earlier in this branch; the third is test_pool_invariant_double_owned_912, a
concurrently-developed test belonging to sgl-project#912 and untouched by this commit.
The sgl-project#904 census suite is green against this change (62 passed together with
the sgl-project#913/sgl-project#914/sgl-project#915 suites), which is the regression that matters: note_refused
gained an optional third argument and its existing callers must not care.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
… suite relit against the sgl-project#856 contract) into the flip train
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 27, 2026
…ker per abort

The abort path is the leading candidate for the rank-local slot divergence
behind the PP output-ring wedges, and the code says why itself. `abort_request`
carries sgl-project#631 pin 4 verbatim: "an abort applied on one rank before its peers
DIVERGES THE REPLICATED LIVE SET mid-flip" -- and the guard that prevents it is
conditional, `if window is not None and window.active`. The
`phase_flip_abort_window` is activated only on arming and drained after the
cutover, so OUTSIDE an armed flip `_abort_request_now` runs directly, on
whichever rank processes it, in whichever pass it lands. The hazard is
recognised, named, and closed only inside the flip window.

THE CHECK COULD NOT BE MADE, WHICH IS THE POINT OF THIS COMMIT. Grepping the
three wedge logs for an abort near the onset returns nothing -- and that
nothing is worthless. Every marker inside `_abort_request_now` is
`logger.debug` and the boots run `log_level='info'`: measured, ZERO DEBUG
lines in boot_accept2e0827_0827_0454, boot_accept2e0827b6_0827_0613 and
boot_802f_staged1_0822_1716. So "no abort before the wedge" is a LOGGING GAP,
not a finding. This is the marker-absence trap sgl-project#843 hit on this same path
("the only refusal marker was a logger.debug on a boot running
log_level='info', so it could never appear"), and reporting the null as
evidence would have been the second instance.

ONE SUMMARY LINE, not the per-request ones. `abort_all` can name the whole
live set, so promoting those would trade a blind spot for a flood -- the sgl-project#801
void-streak shape in reverse. This says an abort happened, when, whether the
flip window deferred it, and what it targeted, which is everything the
discriminator needs to place it against a wedge onset. `deferred` is now read
once into a local and used for both the log and the branch, so the line cannot
disagree with the path taken.

WHAT THE SAME SWEEP DID FIND, recorded because it is real and does NOT support
the abort hypothesis:

* Boot 1's wedge onset (last progress 05:08:59) is preceded by EIGHT SECONDS
  by `sgl-project#905 HOST-POOL DOUBLE-FREE about to raise ... 8192 of 8192 index(es) are
  in range but not allocated, span [3530, 14937]` on all three ranks, and the
  `[sgl-project#703 flip-writeback]` drain fails with it. Boot-1-specific: zero such
  lines in boot 6 and zero in 1712. The magnitude is the same 8192 the sgl-project#927
  hit prefix carries, on the HOST pool rather than the device one, which is
  worth linking rather than filing twice.
* Specimen 1712 shows a rank-local admission-congruence retraction (`sgl-project#797
  PP-ADMISSION pass voided on rank 1 ... told=147456 local=139264`) -- that is
  the in-loop site, already covered by the void relay whose default sgl-project#801
  widened.
* So the three wedges do NOT share one proximate cause in these logs, and the
  single-class assumption should not be carried further without evidence.

NO BEHAVIOUR CHANGE. The branch is byte-identical; only the marker is new.

Import smoke + wiring check green (the marker precedes both branches, and the
branch reads the same `deferred` the line printed).
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 31, 2026
…asure WHY, with a denominator

Boot 29 re-admitted the same four requests nine to thirteen times each and 714 of
771 `#969B READMIT-MATCH` lines carried ` host_hit=0`, so every lap re-prefilled
~33k tokens to buy one output token. The standing user design
(Cutover-Full-Reset-Re-Entry, 2026-08-28) is "flip = zero everything, re-admit by
HiCache READ" -- which PRESUPPOSES the host/storage copy survives the flip. It
does not, and three candidates look identical downstream (an empty
prefix_indices): the device tree was dropped and nothing re-read; the host pool
was cleared (`sgl-project#905 HOST-POOL CLEAR`, 63 times against 51 flips, emitted one line
BEFORE the RESIDENTS RELEASED line that promises the read-through); or the
storage tier was never consulted.

THE DISCRIMINATOR IS THE CLEAR EPOCH ACROSS TWO CONSULTS OF THE SAME RID, not
the tier states at one instant. `clear_between > 0` on an empty match says a
host-pool clear fell between that rid's previous consult and this one;
`no_clear_between` REFUTES the clear for that observation. The counter-evidence
that makes this a measurement rather than a confirmation is already in boot 29:
54 re-admissions DID recover (host_hit=28297) and prefetch_registration does not
correlate with recovery (HIT/False=40, HIT/True=17, MISS/False=666, MISS/True=48).

DENOMINATOR LAW IN THE SHAPE, not in the memory: every observation increments
`seen` and EXACTLY ONE outcome bucket; the tier flags are counted independently
beside them so overlapping causes stay visible instead of a decision tree eating
them; an unreadable probe increments `probe_unreadable` rather than silently
scoring a tier absent. Emission inherits #1058b's lesson rather than re-learning
it: wall-clock cadence plus unconditional emission at teardown and on the
scheduler's death path, so `seen=0` is a printed measurement ("the consult was
never reached on this rank") and not a missing line.

REACHABILITY IS NOT ASSUMED: the census sits behind the same SEAM_READMIT_ATTR
guard as `#969B READMIT-MATCH`, which emitted 771 lines on boot 29. Present AND
populated, argued from a measured line count rather than from the code shape --
the check sgl-project#1059 did not make.

MATCHED CHECK for this edit's failure class (an instrument that is wired and
never executes, or an emitter gated on an observation count -- both invisible to
py_compile and to an import smoke): the census arithmetic is driven directly,
asserting one-bucket-per-observation, the clear-epoch discriminator on all three
of its states, the unreadable-probe path, the seen=0 print, and a
DANGER-DIRECTION MUTANT (drop the per-rid epoch stamp -> every empty match scores
clear_unknown and both real buckets stay 0). 6/6 green, and it demonstrated it
can fail (first run red on a real assertion bug). ruff clean on the added lines.

MEASURE ONLY. Nothing is gated, refused or repaired on this boot.

Evidence: /spinning/evidence-665-f1/specimen_1059uw_boot29_prefill_loop/
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 2, 2026
… (905 double, 1035c stub)

Two test stand-ins that the branch's new production contracts outgrew
(sgl-project#624/sgl-project#978 stand-in-drift class). Production is the reviewed, accepted
contract in both cases and is NOT touched; only the stand-ins move.

DRIFT 1 -- the sgl-project#905 census-scheduler double missed the A12.2 cutover clearer.
  test/registered/scheduler/seam_census_double.py:417 (FaithfulCensusScheduler)
  binds the REAL Scheduler.readmit_seam_residents, which since the slice-3 fix
  calls self._clear_prefetch_deferral_for_reissue(population) at
  python/sglang/srt/managers/scheduler.py:5810 (definition :6292, lifecycle
  CLEARER (c) in the table at :5969). The double bound the caller but not the
  helper -> AttributeError, surfacing as "retry() exceed maximum number of
  retries".
  Fix: bind BOTH real methods (_clear_prefetch_deferral_for_reissue and the
  _clear_prefetch_deferral_fields it calls) from the real class, not a no-op.
  A no-op stand-in would be the W29 direction again: the double would pass a
  cutover that never cleared, i.e. exactly the defect the clearer exists for.
  The A12.2 fields are deliberately NOT pre-planted on FaithfulReq -- the real
  Req does not declare them either (no occurrence in schedule_batch.py); they
  are planted dynamically by _apply_prefetch_deferral and every reader uses
  getattr(..., default). Absence is the faithful state.
  This is the same edit the slice-3 fix already made in the two sibling
  doubles (test/registered/unit/managers/test_seam_readmission_w31.py:87-89
  and test_prefetch_deferral_1068.py:195-197); the 905 double was the one
  instance missed by that sweep.

DRIFT 2 -- the #1035c stub missed the termination protocol.
  python/sglang/srt/mem_cache/hybrid_cache/hybrid_cache_controller.py:752
  reads operation.is_terminated() DIRECTLY (branch commit 846c679, slice 2
  fix 4). That override is a FULL replacement of the base probe -- one
  batch_exists call over the whole span, no per-batch loop -- so the base
  class's per-batch guard never reaches it, and the class-agnostic getattr
  form at managers/cache_controller.py:851 is a different pass and does not
  apply here. The stub at
  test/registered/unit/mem_cache/test_zero_answer_partition_1035c.py:172 built
  the operation without the protocol.
  Fix: the stub answers is_terminated() -> False (a live operation, which is
  what all four fixtures are about), modelling
  StorageOperation.is_terminated at managers/cache_controller.py:287.
  mark_terminate is deliberately NOT added: this path never calls it, and a
  stub method nothing drives is surface without a contract behind it.
  hybrid_cache_controller.py:752 is NOT weakened to a getattr.

TALLY (hermetic: CUDA_VISIBLE_DEVICES="", PYTHONPATH=<worktree>/python,
pytest -q -p no:cacheprovider, per file, run once each)
  test_seam_census_double_905.py       before 6 failed / 14 passed
                                       after  0 failed / 20 passed
  test_zero_answer_partition_1035c.py  before 4 failed /  5 passed
                                       after  0 failed /  9 passed

THE FOUR 905 REDS THAT PRE-DATE THIS BRANCH
  test_every_resident_is_retracted_readmitted_and_off_the_live_set,
  test_no_row_belongs_to_nobody_afterwards, test_the_drop_evicted_before_it_
  reset, test_the_seam_stamped_its_own_retractions were already RED at the pin
  228a66d, so the branch gate counted only the other two as truly new.
  They go GREEN here with the same stand-in fix and no further edit. Their
  pin-era cause is therefore not present on this branch: the sgl-project#1068 slice work
  rewrote the production seam and this suite together (git diff
  228a66d..HEAD touches seam_census_double.py +47/-33 and
  test_seam_census_double_905.py +60), and the clearer binding was the last
  piece missing. Not carried forward as debt -- the file is 20/20.

Checks: both files run once each (above); import smoke of
sglang.srt.managers.scheduler and
sglang.srt.mem_cache.hybrid_cache.hybrid_cache_controller OK; ruff check and
ruff format --check clean on both files. No production file touched.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 12, 2026
…dules, decided per file

WHY: four modules could not be COLLECTED on this tree, so EVERY gate baseline
here ended rc=3 / VERDICT: INCONCLUSIVE -- an automated NEW=0/GONE=0 verdict was
structurally impossible, which cost half a verdict cycle on 2026-09-11. The exit
code is not the tree's redness: gate_tier2_partitioned.py:614-616 is
`if inconclusive and rc == 0: rc = 3`.

NOT A SKIP (sgl-project#910): a skip can darken a working test; here it darkens nothing --
there is nothing behind these imports to run -- so it would only make rc=3
permanent under a friendlier name. sgl-project#905's form instead: delete a retired promise
with its reason, and leave ONE tripwire that fires the day the mechanism returns
and NAMES the arms then owed.

DECIDED PER FILE, not in bulk:

DELETED test_phase_flip_decode_relay_631.py (7 tests). Its only subject was
`phase_flip_resident_carry.reseed_decode_input_relay`, deleted by 069f98c
"[sgl-project#969 CUT K] Delete the resident carry: the cutover is a re-entry, not object
surgery" -- also standing user design (a flip nulls everything and re-admits
through HiCache; object surgery at the cutover is the root class of ~15 boot
killers). A retired promise.

DELETED test_pp_proxy_stamp_631.py. It bound
`SchedulerPPMixin.pp_flip_drain_tensor_dicts` at CLASS-BODY level (:334), which
is why it failed at import while test_pp_presence_stash_on_real_wire_800.py,
which names the same symbol inside a function, still collects.
THE RENAME HYPOTHESIS IS REFUTED: `pp_flip_drain_leftover_dicts` is not the same
mechanism under a new name. Its own docstring calls it "CORPSE S DONE CORRECTLY"
and records that the old drain was kind-blind and ATE AN OWED OUTPUT (PP1,
07:33:30Z), while the successor demultiplexes first; HANDOFF_656.md:1348 says
"Do not re-enable pp_flip_drain_tensor_dicts as written". The promise it carried
is held by the successor, which six live test modules already cover, so
retiring this file loses no coverage.

REWROTE test_phase_flip_spec_seam_631.py: dropped the dead
`harvest_resident_batches` import and the THREE tests that drove it, two of them
sgl-project#905-shape falsifiers whose counterfactual can no longer be constructed. The
seven tests over `_reachable_batches` and
`clear_spec_info_for_unspeculated_phase` -- both live -- survive unchanged.

REWROTE test_phase_flip_draft_bootstrap_631.py, three separate repairs:
 (a) dropped the dead `ResidentCarryError` import;
 (b) retired the cap-refusal test and the two-ceilings-agree pin. The product
     states the reason itself (phase_flip_draft_bootstrap.py:456-461): the
     defect-M ceiling is gone with the carry, "a count above the cap can no
     longer be the signature of a corrupted carried set -- it would just be the
     load", and BOTH copies of IN_FLIGHT_CHUNKED_ALLOWANCE are gone, so there is
     no second ceiling to agree with;
 (c) FIXED FIVE STALE-DOUBLE FAILURES that only appeared once the module could
     be collected again: `retune_carried_batches_for_phase` enumerates through
     `_harvest(scheduler)` -> `scheduler._resident_batches()`, which sgl-project#969 moved
     ONTO the Scheduler (scheduler.py:7040, "eight lines replacing
     harvest_resident_batches ... 911 LOC"), and this file's SimpleNamespace
     double predates that move. The double now BINDS THE PRODUCT'S OWN METHOD
     rather than copying its eight lines: the identity dedupe is load-bearing
     (running_batch is normally an alias of one slot) and a second copy is free
     to drift. NO production file was touched -- `_resident_batches` exists and
     has live callers (phase_flip_runtime.py:941/3765), so this was test drift,
     not a product defect, and I verified that before editing anything.

TRIPWIRE test_1347_retired_631_mechanisms_stay_retired.py, three assertions over
the retired mechanisms, each naming the arms owed on red and where to recover
them (04cd920). CAN-FAIL PROVEN, four mutants, all fire: re-importable
resident carry -> red; the kind-blind drain back on the mixin -> red; the
SUCCESSOR also gone -> red (so the file cannot pass by the whole family
vanishing, the green-by-vacancy direction); the arming allowance back -> red.

MEASURED: 47 tests collect and 47 pass across the two rewritten modules plus the
tripwire (before: 0 collected, 4 modules uncollectable, 11 pytest ERROR
entries). Running them was not optional -- collection alone would have traded
rc=3 for five new GENUINE names.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…oaded increment; follower limit is absolute

Boot xsn119 (58e574f), rid eb03bfc5 (Q1 prefix 4316 + ~6.8k appendix ->
LONG -> P): P READ THE STORE for the first time on this form -- PP0
'#1028B FETCH CAP kv=4308 claimed=4095 caps={mamba: 4095}', anchor at 4094,
'sgl-project#905 PREFETCH-COMPLETE completed=4095' -- but told carried
`prefetch_loaded_tokens_by_reqid` = 4031 (64 pages were already in PP0's host
tree from the Q2 miss, loaded = 4095 - 64). PP1 registered [0, 4031): no
anchor in range, '#1028B FETCH CAP kv=4030 claimed=0 ... anchors (0, -1)',
completed 0, and the named Weg2StoreToldMismatch (told=4031 own_loaded=0)
stopped the group -- the refusal worked as designed, the quantity was wrong.

Fix: told = the terminated prefetch's COMPLETED PREFIX (sgl-project#1175
`completed_prefetch_tokens` = matched + loaded on the tree that has it; None
-> 0), and `_prefetch_kvcache(limit_tokens=)` is an absolute prefix end
(`_match_end = min(_match_end, told)`), so every follower registers [0, told)
with the anchor inside. Admission compares each rank's completed prefix to
told and returns the rank's own loaded increment as the credit.

Tests: test_weg2_store_told_1400: 14 passed (two new: told = completed prefix
with 64 pre-existing pages; follower refuses on a shorter completed prefix
even after loading something).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 26, 2026
…tch SGLANG_WEG2_TOLD_PROBE_TREE_KEY, default off)

27B agent boots 0925/0926 (bar1agent 1922/2206, nvfp4bar1agent 2328,
bar1final 0145): every P leg cached_tokens=0. PP0's store read found the
previous turn's prefix in the arena (sgl-project#1439 ARENA-PRESENT leading_complete=
22934 first_stem=c90c5e64, sgl-project#905 PREFETCH-COMPLETE completed=22934), then the
sgl-project#1416 clamp probe asked the same arena with UNIGRAM keys (first_stem=f9ec16cd,
leading_complete=0, sgl-project#1035 R13 EMPTY KV PREFIX) and clamped told to 0
(sgl-project#1416 ANCHOR-CLAMP completed=22934 anchored=0) -- sgl-project#1419 caps every rank's
match at told, so P re-prefilled the whole prompt. The tree keys bigram
(is_eagle / SGLANG_HICACHE_BIGRAM_KEYS, sgl-project#1233: c90c5e64 bigram vs f9ec16cd
unigram); the probe passed origin_input_ids[:told] as plain ids. Since
xsn171 (first clamp boot) every clamp answered anchored=0.

Switch on: RadixKey(ids[:told+bigram], is_bigram=tree.is_eagle), sgl-project#1442
handoff keys substituted like _storage_hit_query. Off: byte-identical.
Decision stays on PP0 only (told on the wire), followers unchanged.

Tests: test_weg2_store_told_1400.py 24 passed (+5: off reproduces the 0,
on keeps told, on still clamps beyond the leading run, unigram tree
unchanged, handoff keys).

UNIFY (UN6, Operator 26.09. Vorrang): pick of desk/27b-pprefix-0926 (4d216bb, PX) onto the
unified head, clean. Modellneutral (NF MTP bigram alike), switch default off.
dup_defs_gate vs 27b-rc9-103712cdb2 + nf-rc2.1l-d1c7094ba6: 0 new. test27b.sh:
test_weg2_store_told_1400.py 24 passed.
YAMY1234 added a commit to YAMY1234/sglang that referenced this pull request Sep 27, 2026
…very shared/deep virtual page a target forward writes must be owned and published on the GPU map; CPU test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
YAMY1234 added a commit to YAMY1234/sglang that referenced this pull request Sep 27, 2026
…ast the new reservation on publication (sgl-project#905)

A just-finished request's extra verify under the overlap scheduler can write deep KV past its reservation; those
entries still pointed at an earlier occupant's released private pages whose physical units now belong to other
pages, corrupting a cached prefix's Scheme-C latent row ('malformed TP gap8 stream before scatter'). Point the tail
at private page 0 (never reserved; physical unit 0 is the padding sink). CPU test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 14, 2026
…checks every settle member; the termination collective carries the rid

NF h18 fe799c4 died twice on D with a gloo collective mismatch (16:23:24Z "8 vs 4",
boot ..._1014_161406; 16:38:56Z "16 vs 4", boot ..._1014_162636). Same chain both times:
- a read record differs by rank under the Form A END vote (TP0's span base 0, the workers'
  19008/67584: TP0 'matched=0 completed_synced=0' vs '19072'), so _1471_short (from the rank's
  own record) is set on TP0 only;
- the sgl-project#1471 settle tick: '#1471w SETTLE-WRITER rid=weg2-10-28 (6-68) ... action=reread' on TP0
  ONLY, the next tick TP0's action is 'decide' -- and loop 1 skipped _refetch (the progress
  check's collectives: can_terminate_prefetch MAX, the reap MIN) for a decide/wait member;
- TP0's next collective was the next member's while the workers checked the skipped one: TP0
  'sgl-project#905 ... req=weg2-12-29 completed=96256 min_synced=62848' (the workers' 10-28 number),
  TP1/TP2 'req=weg2-10-28 completed=62848'; in death 2 TP1/TP2 6-68 (94336/67584) vs TP0 10-71
  (67584/67584) -- two rids in one collective. TP0 deferred and re-issued alone, its prefetch
  thread ran an operation the workers did not, the claim reduces met with different sizes.
STORE-HELD-DECIDE ruled out: it decides on the reduced END and the absolute deliverable, the
W88-REROUTE lines of death 1 (store_held=62848 / 95680, cycles=2 bound=1) are identical on all
three ranks, death 2 has no fallback in its window; pinned below on the Form A END harness.

(2) SETTLE-UNIFORM-1014 (SGLANG_WEG2_SETTLE_UNIFORM_CHECK, default on): loop 1 of the settle tick
runs _refetch(req, now, allow_reissue=False) for every non-capwait member on every rank; the
rank-local writer action shapes only the vote (_pre/_dec), never whether a collective is entered.
A wait member is checked, never re-read. Off: the old skip.

(3) PREFETCH-RID-NET-1014 (SGLANG_WEG2_PREFETCH_RID_NET, default on): can_terminate_prefetch
carries the rid's fingerprint (crc32, 30 bit) as h and -h in the same MAX (5 slots on every
rank). max != min = the ranks stand at different rids; every rank sees it alike, answers 'not
done' and logs PREFETCH-RID-MISMATCH -- nothing reaped, no rid's numbers mixed into another,
no one-sided DEFERRED/re-issue, no gloo abort. Off: the 3-slot form.

Tests (pytest_gedeckelt.sh, no GPU): test_weg2_h18_settle_uniform_rid_net_1014 (new, 11):
the h18 tick on three ranks with TP0 'decide' / workers 'poll' runs the same progress checks;
RANK-EQUALITY MUTANT: the switch off (the h18 code) splits the ranks (TP0 first at 12-29); a
wait member is checked but not re-read; defaults on; the net: same rid terminates, the h18
pairing (12-29 vs 10-28) is 'not done' and named on both sides, net off cannot see it, the
fingerprint is stable; STORE-HELD-DECIDE on the real drain chain with the metal's Form A bases
answers alike on every rank on every pass, its mutant on completed_local splits them.
Regression (42 files touching the settle, the progress check, the store-short drain):
409 passed + the 2 adapted pins (xsn296 window 6000 -> 9000, h45 termination tensor len 3 -> 5):
28 passed. 9 failures (test_prefetch_progress_symmetry_580 x8, test_allreduce_admission_pin_1537
p5) are red at the base 82263ce as well, not touched.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 14, 2026
…every rank checks every settle member; a rid mismatch at the termination collective stops the group by name

Cherry-pick of 5456b18 onto h16 (a2cfc77), with the net changed to the user law
raenge-nie-uneins-crash-stop (29.08.: a detected rank disagreement is a CRASH/STOP, never a
'not done' and on).

The h18 chain (NF fe799c4, D 16:23:24Z "8 vs 4", 16:38:56Z "16 vs 4"): a read record differs
by rank under the Form A END vote, _1471_short is set on TP0 only, '#1471w SETTLE-WRITER ...
action=reread' on TP0 only, next tick 'decide' -- and loop 1 of the settle tick skipped _refetch
(the progress check's collectives) for a decide/wait member; TP0's next collective met the
workers' skipped rid (TP0 'sgl-project#905 ... req=weg2-12-29 ... min_synced=62848' vs TP1/TP2
'req=weg2-10-28'), TP0 deferred and re-issued alone, the prefetch threads fell out of step.
The path exists unchanged on h16 (span bases, _zero/_1471_short, settle writer, the decide skip).

SETTLE-UNIFORM-1014 (SGLANG_WEG2_SETTLE_UNIFORM_CHECK, default on): every rank runs the
progress check for every non-capwait settle member; the rank-local action shapes only the vote.

PREFETCH-RID-NET-1014 (SGLANG_WEG2_PREFETCH_RID_NET, default on): can_terminate_prefetch carries
the rid's fingerprint (crc32 30 bit, h and -h in the same MAX; 5 slots on every rank). max != min
is seen alike on every rank: every rank raises PrefetchRidMismatch (a RuntimeError)
'PREFETCH-RID-MISMATCH rids=[local=... h=... group_max_h=... group_min_h=...]' -- the group stops
by name. The settle's five 'the hold must never die on a top-up' handlers re-raise it
(_prefetch_rid_stop()), so it is never swallowed into 'complete'.

Tests (pytest_gedeckelt.sh, no GPU, on h16): test_weg2_h18_settle_uniform_rid_net_1014: the h18
tick on three ranks runs the same checks; RANK-EQUALITY MUTANT (switch off = the h18 code) splits
the ranks; wait checked, not re-read; the net: same rid terminates, the h18 pairing raises the
named stop on both sides, net off cannot see it, the settle handlers re-raise it, a stop raised
inside the settle tick escapes; the two STORE-HELD-DECIDE cases skip (not on this line) + the two
adapted pins (xsn296 window, h45 tensor len 5): 28 passed, 2 skipped.
@nogumanov nogumanov mentioned this pull request Nov 13, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants