Skip to content

Support Mistral-Nemo - #691

Merged
zhyncs merged 1 commit into
sgl-project:mainfrom
ispobock:support_mistral_nemo
Jul 21, 2024
Merged

zhyncs merged 1 commit into
sgl-project:mainfrom
ispobock:support_mistral_nemo

Conversation

@ispobock

Copy link
Copy Markdown
Collaborator

Tested Mistral-Nemo-Instruct-2407

hf:

prefill logits tensor([-10.2812, -10.2812,   1.8486,  ..., -11.5391,  -9.4219,  -7.6758], device='cuda:0')
prefill logits tensor([-11.0547, -11.0547,   2.1035,  ..., -11.6797,  -9.8516,  -9.5234], device='cuda:0')
prefill logits tensor([-8.1562, -8.1562,  1.1504,  ..., -9.5078, -6.8477, -9.3906], device='cuda:0')

sglang:

tensor([[-10.3125, -10.3125,   1.7656,  ..., -11.6250,  -9.4375,  -7.7500],
        [-11.1250, -11.1250,   2.0469,  ..., -11.6875,  -9.9375,  -9.5625],
        [ -8.1250,  -8.1250,   1.0938,  ...,  -9.5000,  -6.8438,  -9.4375]],
       device='cuda:0', dtype=torch.bfloat16)

@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.

LGTM. nit: Maybe run it on the original llama as well.

@zhyncs

zhyncs commented Jul 21, 2024

Copy link
Copy Markdown
Contributor

@ispobock

Copy link
Copy Markdown
Collaborator Author

For Llama-2-13b-chat-hf:

hf:

prefill logits tensor([-6.5742, -6.1523,  5.3672,  ..., -2.6953, -1.6221, -2.8848], device='cuda:0')
prefill logits tensor([-6.7305, -6.1836,  5.7305,  ..., -1.7578, -2.8750, -2.7480], device='cuda:0')
prefill logits tensor([-6.0430, -5.4570,  4.8164,  ..., -1.2539, -0.9282, -1.3018], device='cuda:0')

sglang:

tensor([[-6.5742, -6.1484,  5.3633,  ..., -2.6973, -1.6250, -2.8848],
        [-6.7266, -6.1875,  5.7266,  ..., -1.7539, -2.8770, -2.7441],
        [-6.0391, -5.4570,  4.8125,  ..., -1.2539, -0.9272, -1.3008]],
       device='cuda:0', dtype=torch.float16)

@zhyncs
zhyncs merged commit 5303c1e into sgl-project:main Jul 21, 2024
@zhyncs

zhyncs commented Jul 21, 2024

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

@zhyncs zhyncs mentioned this pull request Jul 21, 2024
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
cen121212 pushed a commit to cen121212/sglang that referenced this pull request Nov 10, 2025
* Update test_utils.py

* Update test_utils.py

* Update test_utils.py

* Update run_suite.py

* Update run_suite.py

* Uncomment test_original_logprobs.py in test suite

* Update pr-test-npu-debug.yml
cherryblo added a commit to cherryblo/sglang-project that referenced this pull request Jul 2, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
…refuse to mispair

WHAT WAS REFUSED AND WHY. `_install_rank_prefill_timer` gated on
`pp_size == 1`, on the reading in its own docstring that "PP pipelines process
prefill results on the last stage only, which breaks the FIFO pairing". Under
PP the per-rank prefill line therefore carried no gpu-ms at all, so a PP boot
had no compute-vs-wait number and had to fall back on occupancy proxies.

THE READING DOES NOT MATCH THE RIG. On the reference PP=3 boot all three stages
emit the per-rank prefill line, in near-equal counts -- 1020 / 1020 / 1018
across one log rotation, and the same shape in every rotation checked. Every
stage runs its own scheduling pass and records its own prefill batches, so a
given stage's two queues are fed by that stage's own forwards, which is exactly
what the positional pairing needs. The gate was refusing a shape that pairs.

PER-STAGE LOCAL PAIRING, NOT LAST-STAGE-ONLY. The docstring offered
last-stage-only as the alternative; it measures one card. The question this
instrument exists for is the SPREAD of wait across stages -- who arrives at the
collective first and who is waited on -- and that needs a number per stage.

THE ASSUMPTION IS NOT TAKEN ON TRUST, which is the other half of this commit.
`flush()` pairs POSITIONALLY: `k = min(len(_pending), len(_durations))`, popped
from both. A stage that ever times a forward it does not record shifts the
correspondence, and every line after that attaches one forward's duration to
another forward's token counts -- a wrong number with the same authority as a
right one. So the pairing is now checked BEFORE any pop, and a stage whose
queues drift past MAX_PAIR_SKEW refuses: once, loudly, permanently for that
rank, and the line degrades to the untimed form. It never reports a mispaired
one. A rank that simply went quiet would be indistinguishable from a fast rank,
which is why the refusal is announced rather than silent.

WHAT THE GUARD IS, STATED HONESTLY RATHER THAN OVERSOLD. It is a DIVERGENCE
detector, not an identity check. Per-side sequence numbers were tried on paper
first and cannot catch an orphan: each side counts its own stream, so an extra
duration shifts the correspondence while leaving the counters equal. An exact
check needs a shared forward identity threaded from the scheduler through
ForwardBatch into the timer metadata -- that touches the hot path and is named
as the follow-up rather than smuggled in under a metrics change. What IS caught
is the shape that breaks pairing in practice: one stream persistently
outrunning the other, which is precisely the failure the old gate feared.

A LEAD IN EITHER DIRECTION STAYS LEGAL. Durations routinely complete before the
result that records them (the sibling file pins that), and several forwards can
be in flight before any events complete. MAX_PAIR_SKEW = 8 admits both; only a
persistent runaway trips it.

pp_size=1 IS UNCHANGED. Same install, same queues, same line. The existing
30-case suite passes untouched, which is the byte-neutrality evidence.

TESTS. Red-first: 8 of 10 fail before the change (the install gate refuses PP;
the guard does not exist). Green now. The planted mispairing is falsified
properly rather than by the API being absent: with the skew check deleted, 4
cases go red and `test_no_mispaired_line_is_emitted_at_the_moment_of_refusal`
shows an actual INFO line emitted from already-diverged queues -- the
mispairing is real, not hypothetical. Covered: PP=3 now installs; pp_size=1
unchanged; a non-CUDA device still refused; a persistent orphan stream refused
loudly; the line degrading to untimed afterwards; the refusal announced once
and not per flush; no timed line at the moment of refusal; matched pairing
still emitting the split; and transient leads in BOTH directions not tripping
the guard.

test/registered/unit/managers: 2039 passed (2029 before, +10), 4 failed -- all
four pre-existing on this base and unrelated (test_first_chunk_dynamic_chunking
x2, test_collective_family_siblings_610 PrefillAdmissionBudgetTest x2). Hermetic
(CUDA_VISIBLE_DEVICES=""), no boot.

FOR F4-r4: arming per-stage prefill compute-vs-wait in a PP=3 boot now needs no
flag -- the timer installs on every stage wherever the device is CUDA. Read the
SPREAD of `wait` across stages, not its absolute value; the docstring's existing
note on that (largest shard shows smallest wait) carries over unchanged.
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.

2 participants