Skip to content

Fix bench latency benchmark - #1225

Merged
merrymercy merged 3 commits into
mainfrom
fix-latency-bench
Aug 28, 2024
Merged

merrymercy merged 3 commits into
mainfrom
fix-latency-bench

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

Motivation

Modifications

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

@merrymercy

merrymercy commented Aug 27, 2024 •

Copy link
Copy Markdown
Collaborator

Add this to CI? It breaks very frequently

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

@merrymercy Sure. Is the torch-compiled latency test needed or not?

@merrymercy

merrymercy commented Aug 27, 2024 •

Copy link
Copy Markdown
Collaborator

@hnyls2002 This is a critical fix. Please revert your CI change and merge it soon.

Comment thread .github/workflows/unit-test.yml Resolved
Comment thread python/sglang/bench_latency.py Resolved
Comment thread python/sglang/srt/models/llama2.py Resolved
@zhyncs

zhyncs commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

I encountered an error when using this branch of the code (bench_latency.py only).

python3 bench_latency.py --model google/gemma-2-2b --correct --output-len 16 --trust-remote-code
Init nccl begin.
Load weight begin. avail mem=78.74 GB
WARNING 08-27 13:09:48 interfaces.py:132] The model (<class 'sglang.srt.models.gemma2.Gemma2ForCausalLM'>) contains all LoRA-specific attributes, but does not set `supports_lora=True`.
INFO 08-27 13:09:49 weight_utils.py:236] Using model weights format ['*.safetensors']
Loading safetensors checkpoint shards:   0% Completed | 0/3 [00:00<?, ?it/s]
Loading safetensors checkpoint shards:  33% Completed | 1/3 [00:00<00:01,  1.73it/s]
Loading safetensors checkpoint shards:  67% Completed | 2/3 [00:01<00:00,  1.44it/s]
Loading safetensors checkpoint shards: 100% Completed | 3/3 [00:01<00:00,  2.10it/s]
Loading safetensors checkpoint shards: 100% Completed | 3/3 [00:01<00:00,  1.91it/s]

Load weight end. type=Gemma2ForCausalLM, dtype=torch.bfloat16, avail mem=73.54 GB
Memory pool end. avail mem=9.20 GB
Capture cuda graph begin. This can take up to several minutes.
max_total_num_tokens=646246
input_ids=[[2, 651, 6037, 576, 6081, 603], [2, 651, 6037, 576, 573, 3520, 11392, 537, 603], [2, 15528, 603, 476, 30619, 1744, 578, 590, 1154]]
[rank0]: Traceback (most recent call last):
[rank0]:   File "/data/zhyncs/back/sglang/bench_latency.py", line 493, in <module>
[rank0]:     main(server_args, bench_args)
[rank0]:   File "/data/zhyncs/back/sglang/bench_latency.py", line 453, in main
[rank0]:     work_func(server_args, bench_args, 0)
[rank0]:   File "/data/zhyncs/venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
[rank0]:     return func(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/data/zhyncs/back/sglang/bench_latency.py", line 235, in correctness_test
[rank0]:     next_token_ids, next_token_logits, batch = extend(reqs, model_runner)
[rank0]:                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/data/zhyncs/back/sglang/bench_latency.py", line 207, in extend
[rank0]:     sample_output = sampler.forward_cuda(logits_output, batch.sampling_info)
[rank0]:                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/data/zhyncs/back/sglang/python/sglang/srt/layers/sampler.py", line 80, in forward_cuda
[rank0]:     probs = self._get_probs(logits, sampling_info)
[rank0]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/data/zhyncs/back/sglang/python/sglang/srt/layers/sampler.py", line 56, in _get_probs
[rank0]:     logits = logits.contiguous()
[rank0]:              ^^^^^^^^^^^^^^^^^
[rank0]: AttributeError: 'tuple' object has no attribute 'contiguous'

@merrymercy
merrymercy merged commit 1ece2cd into main Aug 28, 2024
@merrymercy
merrymercy deleted the fix-latency-bench branch August 28, 2024 07:37
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Hide-on-bushsh pushed a commit to Hide-on-bushsh/sgl-project that referenced this pull request Sep 7, 2026
…5-models

test(npu): remove 86 legacy model test cases
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 16, 2026
…ads only frames in flight (_pp_launched_batches + chunked_req), a busy-PP0 vote keeps the hold, a second abort joins an open hold

A1: pp0_inflight_reqs read mbs / last_batch / running_*, which keep a COMPLETED batch
until the slot is planned again. A rid that ran on every rank and was requeued on every
rank (#968b requeue, void park, retreat) then stamped True; PP0 popped it at receipt and
the followers held an abort no frame ever ends (reviewer probe P2: still held after 50
frameless passes, released only by the next idle-PP0 lap). Now: _pp_launched_batches
(set at the launch on every rank, popped when the slot's result is consumed, sgl-project#1225) plus
chunked_req.
A2: negative test for weg2_791c_release_on_idle_vote -- a vote with PP0 busy keeps the
hold, the frame stays executable, the admitting plan applies PP0's abort (kills R2).
Defence: a second abort of a rid whose hold is open joins the hold instead of popping at
receipt on a later stamp (reviewer P1, unreachable under the ring invariant).

Tests: test_weg2_pp_waiting_abort_k14_1015.py 30/30 (6 new: A1 completed-slot + requeued
rid -> stamp False, no zombie; A1 mutant (old inflight form) -> zombie after 50 passes;
A2 busy vote keeps the hold; A2 mutant R2 -> sgl-project#1180; second abort joins; mutant
no-join -> sgl-project#1180). Specimen tests stay green.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 16, 2026
…like the live loop; S10b puts a COMPLETED slot-2 batch of the requeued rid in mbs/last_batch (nf-review-k14-1016 A1)

S10/S10c: PP0's launched slot-2 batch is also registered in _pp_launched_batches (sgl-project#1225,
set at the launch on every rank). S10b: the rid ran everywhere, slot 2 delivered (mbs and
last_batch still hold the completed batch, _pp_launched_batches does not), requeued
everywhere, then the abort -- G10 is red if a follower is left holding it (the zombie).

Matrix: fa7d8e1 (K14 + Nachbesserung) 35/35 GRUEN; 6d2ca68 S10b ROT 'G10
ABORT-UNIFORM' (the A1 zombie), rest GRUEN; 1cfbf32 S10 and S10c ROT GRUPPENSTOPP
sgl-project#1180, rest GRUEN.
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.

3 participants