Repository navigation
Add torchao quant (int4/int8/fp8) to llama models - #1341
Conversation
Summary: We want to hack before we work on a proper solution proper solution will be rewrite llama model with tensor parallelism: https://pytorch.org/docs/stable/distributed.tensor.parallel.html (using DTensor underneath), trying to do it here: pytorch/ao#785 Test Plan: change `ENABLE_TORCHAO` to True/False in `python/sglang/srt/models/llama.py` to test the baseline v.s. torchao int4 weight only quant performance python3 -m sglang.bench_latency --model meta-llama/Meta-Llama-3-8B --batch-size 1 --input 128 --output 8 ``` max_total_num_tokens=432196 Warmup ... Prefill. latency: 0.03214 s, throughput: 3983.19 token/s Decode. latency: 0.01383 s, throughput: 72.31 token/s Decode. latency: 0.01354 s, throughput: 73.88 token/s Decode. latency: 0.01338 s, throughput: 74.75 token/s Decode. latency: 0.01330 s, throughput: 75.17 token/s Decode. median latency: 0.01346 s, median throughput: 74.31 token/s Total. latency: 0.086 s, throughput: 1531.66 token/s Benchmark ... Prefill. latency: 0.02514 s, throughput: 5092.40 token/s Decode. latency: 0.01337 s, throughput: 74.80 token/s Decode. latency: 0.01338 s, throughput: 74.74 token/s Decode. latency: 0.01339 s, throughput: 74.68 token/s Decode. latency: 0.01321 s, throughput: 75.68 token/s Decode. latency: 0.01295 s, throughput: 77.23 token/s Decode. median latency: 0.01337 s, median throughput: 74.77 token/s Total. latency: 0.132 s, throughput: 1032.13 token/s max_total_num_tokens=505188 Warmup ... Prefill. latency: 0.10929 s, throughput: 1171.18 token/s Decode. latency: 0.00790 s, throughput: 126.57 token/s Decode. latency: 0.00738 s, throughput: 135.54 token/s Decode. latency: 0.00724 s, throughput: 138.16 token/s Decode. latency: 0.00726 s, throughput: 137.71 token/s Decode. median latency: 0.00732 s, median throughput: 136.62 token/s Total. latency: 0.139 s, throughput: 949.17 token/s Benchmark ... Prefill. latency: 0.10405 s, throughput: 1230.13 token/s Decode. latency: 0.00769 s, throughput: 129.96 token/s Decode. latency: 0.00725 s, throughput: 137.85 token/s Decode. latency: 0.00724 s, throughput: 138.11 token/s Decode. latency: 0.00731 s, throughput: 136.72 token/s Decode. latency: 0.00744 s, throughput: 134.47 token/s Decode. median latency: 0.00730 s, median throughput: 136.97 token/s Total. latency: 0.163 s, throughput: 834.99 token/s Warmup ... Prefill. latency: 0.05868 s, throughput: 2181.51 token/s Decode. latency: 0.04475 s, throughput: 22.35 token/s Decode. latency: 0.04463 s, throughput: 22.41 token/s Decode. latency: 0.04467 s, throughput: 22.39 token/s Decode. latency: 0.04478 s, throughput: 22.33 token/s Decode. median latency: 0.04471 s, median throughput: 22.37 token/s Total. latency: 0.238 s, throughput: 555.78 token/s Benchmark ... Prefill. latency: 0.05274 s, throughput: 2427.22 token/s Decode. latency: 0.04463 s, throughput: 22.41 token/s Decode. latency: 0.04456 s, throughput: 22.44 token/s Decode. latency: 0.04453 s, throughput: 22.45 token/s Decode. latency: 0.04469 s, throughput: 22.38 token/s Decode. latency: 0.04457 s, throughput: 22.44 token/s Decode. median latency: 0.04457 s, median throughput: 22.44 token/s Total. latency: 0.409 s, throughput: 332.13 token/s ``` Reviewers: Subscribers: Tasks: Tags:
|
Hi @msaroufim @jerryzh168 Nice work! It looks like the CI failures are due to a missing |
There was a problem hiding this comment.
Given the changes are very minimal. I feel that we can even merge this and start iteration. Here are a few thoughts on making it more clean.
- Add a new argument
--enable-torchaosimilar to--enable-torch-compilehere.sglang/python/sglang/srt/server_args.py
Line 432 in ab4a83b
- Alternatively, instead of adding
--enable-torchao, we can add a new quantization formattorchao-int4heresglang/python/sglang/srt/server_args.py
Line 224 in ab4a83b
- You can pass the above arguments to this global variable and read it in
sglang/python/sglang/srt/model_executor/model_runner.py
Lines 93 to 100 in ab4a83b
llama.py
@merrymercy thanks for the suggestions, I can start with https://github.com/pytorch/ao/blob/1ce7da941b311ef6ab416d9c7a22be20e65b7495/torchao/_models/llama/generate.py#L462 I think ideally we'd want to be able to specify different types of quantization like I could be using sglang/python/sglang/srt/models/llama.py Line 248 in ab4a83b |
|
Feel free to copy over the code as we will gradually remove the dependency of vLLM (likely in one month or so) |
|
@jerryzh168 Thanks for the contribution. It is merged. I pushed some updates:
|
|
I verified the performance on H100. Here are the results with a few comments:
I also got some errors with the current torchao release on Pypi when trying the following settings. Which version should I use?
|
|
Thanks @merrymercy for the fixes, tests and merging the PR!
not yet I think, but we can take a look to understand why
yeah int8 requires torch.compile to speedup, using fp8 sounds good to us as well.
yeah currently we have torchao 0.4 in pypi, we are doing a new 0.5 release this week so fp8 should be supported this week
I've seen this before, this is because of some issue in pytorch dynamo/inductor code I think, and it should be fixed in pytorch nightly, maybe you can try installing pytorch nightly first to verify that the issue can be fix first. also do you have a version requirement for pytorch in sglang? |
@jerryzh168 We use torch==2.4.0 |
|
I see, for 2.4.0 and below, we'd need to call https://github.com/pytorch/ao/blob/e1039abac7f429a8d7f489d047d9b34d6ac6afe2/torchao/utils.py#L269 for the model to be compilable I think, I'll try to verify as well when I got a chance today |
|
for 2.4.0 there seems to be some issue even with work around, trying to debug now |
|
for the second issue "torch.compile + torchao is not supported" I can only repro in 2.4.0 and not sure how to fix, also the fix could just be needed in pytorch itself I think and we can't really back port the fix to 2.4.0. I'm wondering if it's OK for you to use torch nightly for now for testing? pytorch 2.5.0 is going to be released in one month. |
Summary: Similar to sgl-project#1341 we add torchao quantization to mixtral model Test Plan: Note: compile is not working yet, and I can't install torchnightly locally and make it work either. I'll wait for pytorch 2.5 release which happens in mid Oct, or check that again later python3 -m sglang.bench_latency --model Qwen/Qwen1.5-MoE-A2.7B --batch-size 1 --input 128 --output 8 Warmup ... Prefill. latency: 0.05532 s, throughput: 2313.73 token/s Decode. latency: 0.00896 s, throughput: 111.65 token/s Decode. latency: 0.00833 s, throughput: 120.04 token/s Decode. latency: 0.00869 s, throughput: 115.06 token/s Decode. latency: 0.00842 s, throughput: 118.79 token/s Decode. median latency: 0.00855 s, median throughput: 116.89 token/s Total. latency: 0.090 s, throughput: 1471.26 token/s Benchmark ... Prefill. latency: 0.04294 s, throughput: 2980.61 token/s Decode. latency: 0.00839 s, throughput: 119.12 token/s Decode. latency: 0.00828 s, throughput: 120.78 token/s Decode. latency: 0.00857 s, throughput: 116.64 token/s Decode. latency: 0.00853 s, throughput: 117.19 token/s Decode. latency: 0.00859 s, throughput: 116.39 token/s Decode. median latency: 0.00853 s, median throughput: 117.17 token/s Total. latency: 0.111 s, throughput: 1226.84 token/s python3 -m sglang.bench_latency --model Qwen/Qwen1.5-MoE-A2.7B --batch-size 1 --input 128 --output 8 --torchao-config int4wo-128 Warmup ... Prefill. latency: 0.06413 s, throughput: 1996.05 token/s Decode. latency: 0.00764 s, throughput: 130.84 token/s Decode. latency: 0.00748 s, throughput: 133.73 token/s Decode. latency: 0.00725 s, throughput: 137.84 token/s Decode. latency: 0.00721 s, throughput: 138.74 token/s Decode. median latency: 0.00737 s, median throughput: 135.76 token/s Total. latency: 0.094 s, throughput: 1408.61 token/s Benchmark ... Prefill. latency: 0.05239 s, throughput: 2443.43 token/s Decode. latency: 0.00739 s, throughput: 135.25 token/s Decode. latency: 0.00720 s, throughput: 138.90 token/s Decode. latency: 0.00718 s, throughput: 139.21 token/s Decode. latency: 0.00722 s, throughput: 138.42 token/s Decode. latency: 0.00745 s, throughput: 134.30 token/s Decode. median latency: 0.00731 s, median throughput: 136.82 token/s Total. latency: 0.111 s, throughput: 1223.51 token/s A100, no compile python3 -m sglang.bench_latency --model Qwen/Qwen1.5-MoE-A2.7B --batch-size 1 --input 128 --output 8 --torchao-config fp8wo max_total_num_tokens=199454 Warmup ... Prefill. latency: 0.06958 s, throughput: 1839.60 token/s Decode. latency: 0.02343 s, throughput: 42.68 token/s Decode. latency: 0.02342 s, throughput: 42.70 token/s Decode. latency: 0.02368 s, throughput: 42.23 token/s Decode. latency: 0.02337 s, throughput: 42.80 token/s Decode. median latency: 0.02342 s, median throughput: 42.69 token/s Total. latency: 0.163 s, throughput: 807.48 token/s Benchmark ... Prefill. latency: 0.05767 s, throughput: 2219.36 token/s Decode. latency: 0.02293 s, throughput: 43.61 token/s Decode. latency: 0.02026 s, throughput: 49.36 token/s Decode. latency: 0.02029 s, throughput: 49.29 token/s Decode. latency: 0.02024 s, throughput: 49.41 token/s Decode. latency: 0.02026 s, throughput: 49.36 token/s Decode. median latency: 0.02025 s, median throughput: 49.39 token/s Total. latency: 0.222 s, throughput: 611.87 token/s Reviewers: Subscribers: Tasks: Tags:
@jerryzh168 I think we can give it a try, I will verify asap. |
|
interesting |
|
@jerryzh168 The main branch currently supports torch 2.5.1, and the installation method is as follows: If you have any questions, feel free to contact me anytime. Thanks! |
Co-authored-by: Lianmin Zheng <[email protected]>
…t the instrument did not print Review: /spinning/gpu-arb/weg2/REVIEW_COVERAGE_1348_0912.md against ef1b1a7. Verdict there, and it was right: what the tool PRINTS is essentially true (M1-M7 all die, the tally and SOURCE-DRIFT hold, OFF is byte-identical). The defect is what it does NOT print -- and four of the reviewer's own mutants survived all 21 tests. MF-1 SILENCE INSTEAD OF REFUSAL -- the sgl-project#1329 shape itself. The ingest iterated the dumps the glob FOUND, and `wlc.arm()` sat AFTER the `bounce_lane_armed()` gate. A rank whose hook returned early -- which is what `slots=True` did for three boots -- wrote no dump, and the report named it with no word at all: group P's reading list read as the boot's. Fixed on both sides. (a) The arm moved BEFORE the gate and leaves an immediate `legs=0` dump, so a rank that ran no leg is a printable fact. (b) The launcher writes `phase_coverage_EXPECT.json` (P=n,D=n,L=1) where the card count is first known, and every expected-but-absent pair prints `reason=rank-wrote-no-dump`. Without an expectation list the ingest REFUSES. The UNION line refuses over an incomplete group instead of shrinking to `ranks=2` -- an intersection over a subset of the ranks is a SUPERSET and named lines the absent rank executed. MF-2 A STALE DUMP WAS READ AS THIS BOOT. The dump directory is sgl-project#1292's and sgl-project#1292's is reused across boots; the blob carried no boot identity, so yesterday's dump on an unchanged tree passed the sha256 gate and printed. With MF-1 that composes into the worst output the tool can make: the silence about a missing rank gets FILLED with a confident wrong answer. Boot token (`tag:epoch:pid`, memoised on the namespace so P and D carry the same one) in the blob and the manifest; a mismatched dump is refused BY NAME and does not count as that rank having reported. MF-3 `sha256: ""` SILENTLY DISABLED THE SOURCE GUARD. `if dump_sha and dump_sha != tree_sha` -- an empty hash is falsy. The arm wrote one on any OSError. Both halves fixed: the arm no longer swallows the error, and the ingest treats an empty hash as `reason=no-source-hash` and prints no reading list against an unverified source. This strand's tree moves between boot and ingest routinely; that guard is the only thing holding. MF-4 THE TRACER RAN TO PROCESS EXIT, AND THE COST WAS NOT ALLOWLIST-BOUNDED. The build's own docstring said 2.60x "because the allowlist is eleven files and not the tree". That is the instrument-text-lies class: the allowlist bounds what is RECORDED, not what is PAID -- the trace callback fires for every Python call in the process. Review measured NON-allowlisted code at 4.04x and full tracing at 9.89x, and `note_teardown` deliberately did not stop. So every ms/round, prefill, decode and flip figure of an armed boot was confounded, and the wall-clock ring deadlines (`ring_guard.py` 2.0 s / 20.0 s, the W51 trend test) were being eaten. The tracer now runs ONLY inside the leg bracket (`begin_leg` before `run_leg_hook`, stop in `note_leg_end`, stop at teardown); coverage.py accumulates across start/stop cycles (verified: leg 2 is a superset of leg 1). `traced_ms` reports the window, `timings=CONFOUNDED` is on every DUMP line and on a new launcher `WEG2-COVERAGE ARMED` line. W51 interaction is recorded in the acceptance line as PLAUSIBLE, not measured. ALSO TAKEN (review SHOULD/NOTE): artefact_n=/artefact_lines= per module, naming the 23.7 % of lines that ran before the tracer went in rather than mixing them into the wall list (S-1); allowlist split by process role, RANK_MODULES 10 / LAUNCHER_MODULES 1, removing ~16 meaningless W90 per boot (S-2); the collision guard made two-sided (`seam_coverage.lane_coverage_armed()`) plus a PRE-SPAWN launcher refusal -- the per-rank refusal cost the whole window (S-3); `dead`/`dead_where` in the blob and `_mark_dead` now flushes (S-4); `threads_at_arm` declared, since threads predating the arm are never traced (S-5); the docstring's "all three numbers are printed" corrected to two, and `save_per_leg_ms` computed (S-6); launcher arm moved behind `--teardown` (N-6); a missing EXPECTED rank now escalates the exit code without `--strict`, so a caller reading only `$?` cannot read green over a boot that observed nothing (N-1). TEST HONESTY. The three substring wiring tests are DELETED and replaced by AST and behaviour pins: a commented-out call contains the token, which is why mutant MR4 unwired the instrument with every test green (sgl-project#1341 class). `build_env` is now CALLED rather than grepped. TWO FINDINGS OF MY OWN, both recorded rather than smoothed over: 1. THE MUTANT HARNESS LIED, in the direction its own header warns about. The round-2 block was generated by a script that turned `\n` inside the replacement patterns into real newlines; every embedded snippet was a SyntaxError, every mutation a silent no-op, and the harness reported EIGHT survivors against code that kills all eight. Same defect class as the subject: it could not tell "the mutant survived" from "the mutation never applied". `patch()` now hashes the file before and after and prints `!! MUTATION-NOOP ... Any GREEN below is the HARNESS, not the code`. Two stale round-1 entries fell out of the same check: M5's pattern had gone stale against the MF-3 split, and M7 pointed at a class deleted in round 2 (a missing pytest node errors, i.e. reads RED for the wrong reason). 2. THE LEG BRACKET MADE `launcher.py` UNMEASURABLE, found by the execution smoke and not by a test: the launcher process never calls `begin_leg`, so the ingest reported `no-lines-recorded` about the file the process had just executed. `arm_launcher` now opens the bracket itself. This is the ONE place a process-lifetime tracer is right, because MF-4's hazard does not exist there: the launcher supervises, it does not serve. EVIDENCE Red-first round 2: 19 failed / 23 passed of 42, then 44/44 green. Mutants 16/16 dead, 0 survivors, 0 no-ops (M1-M7 + MR2-MR9). MR1 is recorded in the harness as a PROVEN EQUIVALENT mutant, not dropped: the reviewer's gap is closed, but not by the line MR1 deletes -- measured on an empty directory with `--expect P=2,D=1`, three `rank-wrote-no-dump` lines and a non-zero exit appear with or without it. MR9 attacks the guarantee MR1 was reaching for. Gate pair, both arms on this box, two worktrees. The xdist arm was NOT clean and is reported as such: run A ONLY-NEW=1/GONE=10, run B (identical file set via --ignore) ONLY-NEW=4/GONE=10 -- with DIFFERENT names, which is the tell. Three lines against "my change": the NEW set is unstable across two candidate runs; all 14 named tests pass SOLO on BOTH trees; and the deterministic arm -- `mem_cache` serial, no xdist, both trees, which is where all 14 names live -- is byte-identical: baseline 28 failures / 28 names, candidate 28 / 28, ONLY-NEW=0 GONE=0. Mechanism: `-n 6 --dist loadfile` assigns files to workers as they free up, so timing changes the packing; the candidate carries one extra subtest (test_weg2_s0_unweave_1233 counts modules under srt/weg2/), and mem_cache has order-dependent tests. That is a finding about the SUITE (a candidate for sgl-project#1343's partition table), not about this change. Execution smoke, real product path: `launcher --dry-run --xchg-coverage-diff` wrote the manifest and the L dump; the ingest printed six `rank-wrote-no-dump` lines (a dry run starts no ranks) and exited 1, verbatim: WEG2-COVERAGE NO-OBSERVATION module=<all> rank=0 group=D reason=rank-wrote-no-dump expected_by=boot-manifest modules=10 refusal=W90 Weg2CoverageNoObservation ruff clean, codespell clean.
…t the instrument did not print Review: /spinning/gpu-arb/weg2/REVIEW_COVERAGE_1348_0912.md against ef1b1a7. Verdict there, and it was right: what the tool PRINTS is essentially true (M1-M7 all die, the tally and SOURCE-DRIFT hold, OFF is byte-identical). The defect is what it does NOT print -- and four of the reviewer's own mutants survived all 21 tests. MF-1 SILENCE INSTEAD OF REFUSAL -- the sgl-project#1329 shape itself. The ingest iterated the dumps the glob FOUND, and `wlc.arm()` sat AFTER the `bounce_lane_armed()` gate. A rank whose hook returned early -- which is what `slots=True` did for three boots -- wrote no dump, and the report named it with no word at all: group P's reading list read as the boot's. Fixed on both sides. (a) The arm moved BEFORE the gate and leaves an immediate `legs=0` dump, so a rank that ran no leg is a printable fact. (b) The launcher writes `phase_coverage_EXPECT.json` (P=n,D=n,L=1) where the card count is first known, and every expected-but-absent pair prints `reason=rank-wrote-no-dump`. Without an expectation list the ingest REFUSES. The UNION line refuses over an incomplete group instead of shrinking to `ranks=2` -- an intersection over a subset of the ranks is a SUPERSET and named lines the absent rank executed. MF-2 A STALE DUMP WAS READ AS THIS BOOT. The dump directory is sgl-project#1292's and sgl-project#1292's is reused across boots; the blob carried no boot identity, so yesterday's dump on an unchanged tree passed the sha256 gate and printed. With MF-1 that composes into the worst output the tool can make: the silence about a missing rank gets FILLED with a confident wrong answer. Boot token (`tag:epoch:pid`, memoised on the namespace so P and D carry the same one) in the blob and the manifest; a mismatched dump is refused BY NAME and does not count as that rank having reported. MF-3 `sha256: ""` SILENTLY DISABLED THE SOURCE GUARD. `if dump_sha and dump_sha != tree_sha` -- an empty hash is falsy. The arm wrote one on any OSError. Both halves fixed: the arm no longer swallows the error, and the ingest treats an empty hash as `reason=no-source-hash` and prints no reading list against an unverified source. This strand's tree moves between boot and ingest routinely; that guard is the only thing holding. MF-4 THE TRACER RAN TO PROCESS EXIT, AND THE COST WAS NOT ALLOWLIST-BOUNDED. The build's own docstring said 2.60x "because the allowlist is eleven files and not the tree". That is the instrument-text-lies class: the allowlist bounds what is RECORDED, not what is PAID -- the trace callback fires for every Python call in the process. Review measured NON-allowlisted code at 4.04x and full tracing at 9.89x, and `note_teardown` deliberately did not stop. So every ms/round, prefill, decode and flip figure of an armed boot was confounded, and the wall-clock ring deadlines (`ring_guard.py` 2.0 s / 20.0 s, the W51 trend test) were being eaten. The tracer now runs ONLY inside the leg bracket (`begin_leg` before `run_leg_hook`, stop in `note_leg_end`, stop at teardown); coverage.py accumulates across start/stop cycles (verified: leg 2 is a superset of leg 1). `traced_ms` reports the window, `timings=CONFOUNDED` is on every DUMP line and on a new launcher `WEG2-COVERAGE ARMED` line. W51 interaction is recorded in the acceptance line as PLAUSIBLE, not measured. ALSO TAKEN (review SHOULD/NOTE): artefact_n=/artefact_lines= per module, naming the 23.7 % of lines that ran before the tracer went in rather than mixing them into the wall list (S-1); allowlist split by process role, RANK_MODULES 10 / LAUNCHER_MODULES 1, removing ~16 meaningless W90 per boot (S-2); the collision guard made two-sided (`seam_coverage.lane_coverage_armed()`) plus a PRE-SPAWN launcher refusal -- the per-rank refusal cost the whole window (S-3); `dead`/`dead_where` in the blob and `_mark_dead` now flushes (S-4); `threads_at_arm` declared, since threads predating the arm are never traced (S-5); the docstring's "all three numbers are printed" corrected to two, and `save_per_leg_ms` computed (S-6); launcher arm moved behind `--teardown` (N-6); a missing EXPECTED rank now escalates the exit code without `--strict`, so a caller reading only `$?` cannot read green over a boot that observed nothing (N-1). TEST HONESTY. The three substring wiring tests are DELETED and replaced by AST and behaviour pins: a commented-out call contains the token, which is why mutant MR4 unwired the instrument with every test green (sgl-project#1341 class). `build_env` is now CALLED rather than grepped. TWO FINDINGS OF MY OWN, both recorded rather than smoothed over: 1. THE MUTANT HARNESS LIED, in the direction its own header warns about. The round-2 block was generated by a script that turned `\n` inside the replacement patterns into real newlines; every embedded snippet was a SyntaxError, every mutation a silent no-op, and the harness reported EIGHT survivors against code that kills all eight. Same defect class as the subject: it could not tell "the mutant survived" from "the mutation never applied". `patch()` now hashes the file before and after and prints `!! MUTATION-NOOP ... Any GREEN below is the HARNESS, not the code`. Two stale round-1 entries fell out of the same check: M5's pattern had gone stale against the MF-3 split, and M7 pointed at a class deleted in round 2 (a missing pytest node errors, i.e. reads RED for the wrong reason). 2. THE LEG BRACKET MADE `launcher.py` UNMEASURABLE, found by the execution smoke and not by a test: the launcher process never calls `begin_leg`, so the ingest reported `no-lines-recorded` about the file the process had just executed. `arm_launcher` now opens the bracket itself. This is the ONE place a process-lifetime tracer is right, because MF-4's hazard does not exist there: the launcher supervises, it does not serve. EVIDENCE Red-first round 2: 19 failed / 23 passed of 42, then 44/44 green. Mutants 16/16 dead, 0 survivors, 0 no-ops (M1-M7 + MR2-MR9). MR1 is recorded in the harness as a PROVEN EQUIVALENT mutant, not dropped: the reviewer's gap is closed, but not by the line MR1 deletes -- measured on an empty directory with `--expect P=2,D=1`, three `rank-wrote-no-dump` lines and a non-zero exit appear with or without it. MR9 attacks the guarantee MR1 was reaching for. Gate pair, both arms on this box, two worktrees. The xdist arm was NOT clean and is reported as such: run A ONLY-NEW=1/GONE=10, run B (identical file set via --ignore) ONLY-NEW=4/GONE=10 -- with DIFFERENT names, which is the tell. Three lines against "my change": the NEW set is unstable across two candidate runs; all 14 named tests pass SOLO on BOTH trees; and the deterministic arm -- `mem_cache` serial, no xdist, both trees, which is where all 14 names live -- is byte-identical: baseline 28 failures / 28 names, candidate 28 / 28, ONLY-NEW=0 GONE=0. Mechanism: `-n 6 --dist loadfile` assigns files to workers as they free up, so timing changes the packing; the candidate carries one extra subtest (test_weg2_s0_unweave_1233 counts modules under srt/weg2/), and mem_cache has order-dependent tests. That is a finding about the SUITE (a candidate for sgl-project#1343's partition table), not about this change. Execution smoke, real product path: `launcher --dry-run --xchg-coverage-diff` wrote the manifest and the L dump; the ingest printed six `rank-wrote-no-dump` lines (a dry run starts no ranks) and exited 1, verbatim: WEG2-COVERAGE NO-OBSERVATION module=<all> rank=0 group=D reason=rank-wrote-no-dump expected_by=boot-manifest modules=10 refusal=W90 Weg2CoverageNoObservation ruff clean, codespell clean.
…her than a second scanner Prior-art gate first (per order): sgl-project#1328's own file (test_weg2_xchg_refusal_reachability_1328.py) already answers "can production reach this raise/verdict at all" via a name-based AST reference graph (_Index/build_index/reachable), with an empty-allowlist ratchet plus a frozen, classified UNWIRED_DEBT for the exceptions, and a synthetic-tree plant-proof (TestTheRatchetCanFail) that RED/GREENs its own failure mode. sgl-project#1306 (test_weg2_wcode_uniqueness_1263.py) answers a different question (is one W-code used twice) and isn't the right host. Extended sgl-project#1328's file rather than building a second walker. THE NEW QUESTION sgl-project#1389 ASKS, different from sgl-project#1328's: does the code that READS a producer's log-line marker run under the SAME precondition the producer's own construction requires? Five real instances from one night (2026-09-13/14): 1-3. W7/W10 (P and D) and W9: count_marker() gates in launcher.py read markers ('sgl-project#706 canonical KV page active', 'canonical GDN blob active', 'sgl-project#1233 HICACHE BIGRAM KEYS FORCED') that only managers/cache_controller.py's HiCacheController ever prints, built only inside mem_cache/registry.py:192's `if ctx.enable_hierarchical_cache:` -- the gates ran unconditionally. ALREADY FIXED (sgl-project#1386 follow-ups 2/3, commits 683ccc5/2ef1a0979d). 4. W45: launcher.py's carrier census reads 'sgl-project#915 PREFETCH LIMIT', whose producer (mem_cache/prefetch_budget.py's log_prefetch_limit) is a no-op whenever its caller passes no cache_controller. ALREADY FIXED (sgl-project#1386 follow-up 4, d6c3d19). 5. The W100 guard bound to _weg2_xchg_inject_from_peer, which runs zero times on the metal (the real call site is _weg2_xchg_bounce_leg) -- DESK10's own test passed because it checks the same wrong function. UNFIXED, in files locked to DESK10 (weight_updater.py) -- reported as a finding, not fixed here. 6. A wait-loop entry-vs-condition race (P enters 03:19:28Z, the condition it waits for exists at 03:19:32Z) -- no expressible static form found. THE MECHANISM (ThePresenceRatchet): for each registered (gate anchor, guard names, producer anchor, producer guard names) tuple, _guard_chain_by_line walks the file's AST once and maps every line to the source text of every enclosing `if` test (presence, not polarity -- an `if X: skip / else: gate` shape records X for lines in EITHER branch, since both fix shapes in the corpus are exactly that). Two per-entry checks (gate side guarded, producer side guarded) plus a DEBT_SIZE_ON_THE_LINE-style pinned corpus size (4) so a removed entry cannot silently pass -- the corpus itself is the required "does the scan find the known corpus" probe (sgl-project#1341/sgl-project#1306's own lesson: a scan that finds nothing reads green). Instances 5 and 6 are DECLARED BOUNDARIES (PRESENCE_RATCHET_BOUNDARIES), not invented rules: sgl-project#1328's own RESOLUTION docstring already states the honest bound this ratchet shares (name-based resolution can call an unwired path wired, never the reverse; no ordering/timing semantics). Instance 5 gets one structural fact this file CAN verify without touching the locked source -- the exact AST call-site count and line of the wrapper _weg2_xchg_inject_from_peer (1, at weight_updater.py:1045) -- pinned so a future desk can diff DESK10's rewire against it. Tests: ThePresenceRatchet (4 corpus checks + shape/naming pins), TestThePresenceRatchetCanFail (synthetic plant-proof: unguarded shape RED, guarded shape GREEN, ambiguous/absent anchors reported not silently misread), TestTheBoundariesAreDeclaredNotInvented (boundary entries carry real reasons; the W100 wrapper's call-site count is pinned). 10 new tests, all green; full file 27/27 green (17 pre-existing + 10 new). Manually verified both required danger-direction mutants: (1) removed one entry from PRESENCE_GATES -- exactly test_the_corpus_cannot_shrink_or_grow_silently goes red, the two per-entry scans stay green over what remains (proving the corpus-size pin, not the per-entry logic, is what catches a silent removal); restored, diff empty. (2) reverted the REAL launcher.py's W7/W10 group P guard to its historical, unconditional pre-fix shape -- the ratchet goes red against the ACTUAL file, not just a synthetic one, naming the exact entry; restored, diff empty (git diff confirmed clean before re-committing).
Summary:
We want to hack before we work on a proper solution
proper solution will be rewrite llama model with tensor parallelism: https://pytorch.org/docs/stable/distributed.tensor.parallel.html
(using DTensor underneath), trying to do it here: pytorch/ao#785
Test Plan:
with compile
python3 -m sglang.bench_latency --model meta-llama/Meta-Llama-3-8B --batch-size 1 --input 128 --output 8 --enable-torch-compile
Reviewers:
Subscribers:
Tasks:
Tags: