Skip to content

hotfix: workaround for rmsnorm input dim restriction - #1061

Closed
zhyncs wants to merge 1 commit into
sgl-project:mainfrom
zhyncs:mla
Closed

zhyncs wants to merge 1 commit into
sgl-project:mainfrom
zhyncs:mla

Conversation

@zhyncs

@zhyncs zhyncs commented Aug 12, 2024 •

Copy link
Copy Markdown
Contributor

https://github.com/flashinfer-ai/flashinfer/blob/c93f647a0dd6b58c9ac20b39438316202358463c/python/csrc/norm.cu#L28

Thank you for your contribution, we really appreciate it. The following instructions will help improve your pull request and make it easier to receive feedback. If there are any items you don't understand, don't worry. Just submit the pull request and ask the maintainers for help.

Motivation

Please explain the motivation behind this PR and the goal you aim to achieve with it.

Modification

Briefly describe the changes made in this PR.

Checklist

  1. Ensure pre-commit pre-commit run --all-files or other linting tools are used to fix potential lint issues.
  2. Confirm that modifications are covered by complete unit tests. If not, please add more unit tests for correctness.
  3. Modify documentation as needed, such as docstrings or example tutorials.

@zhyncs

zhyncs commented Aug 12, 2024

Copy link
Copy Markdown
Contributor Author

This issue has only been found on DeepSeek V2 MLA TP 8 so far.

@ispobock

Copy link
Copy Markdown
Collaborator

Fixed in #1066

@zhyncs

zhyncs commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

Fixed in #1066

Thanks!

@zhyncs zhyncs closed this Aug 13, 2024
@zhyncs
zhyncs deleted the mla branch August 13, 2024 04:42
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 31, 2026
… the epoch, not to a rank's span

Boot 30 died 1 minute into load. `#1059c` gave the row a sender for the first
time, a told prefix of 12288 arrived, and it was applied to a request the cutover
had just re-admitted -- whose pinned span was legitimately 0, because that same
cutover dropped the tree one line earlier (`RESIDENTS RELEASED ... the prefix
tree dropped returning 15943 row(s)`). `uniform_pass_geometry` raised
`UniformWidthPromiseBroken` and crashed the group.

The told value was not wrong. It was STALE ACROSS A CUTOVER, and the guard's
premise -- "told <= pinned holds by construction" -- is true only WITHIN one
cutover epoch, which nothing enforced.

THE TRIGGER IS THE EPOCH AND NOT THE LOCAL SPAN, and that is the whole design.
The obvious formulation -- "void when told exceeds MY pinned span" -- reads a
RANK-LOCAL quantity and is therefore the 26th divergent input into the one
replicated decision. The guard's own message already forbids exactly that:
"compensating locally here would move the batch and reappear as sgl-project#631 on a peer."
`PhaseFlipRuntime._epoch` advances once per COMPLETED cutover on every rank and
the runtime's consensus reduction raises DESYNC if two ranks disagree, so
`row.decided_epoch != current epoch` yields the SAME verdict everywhere without
any rank consulting its own state.

  * PP0 stamps `decided_epoch` at PUBLICATION (the instant the row becomes a
    promise to the group). A relaying rank re-sends the raw row verbatim, so the
    epoch that travels the chain is PP0's.
  * The column rides at the END of the wire row under the same index-and-width
    discipline as sgl-project#987's pair and sgl-project#968's `load_back_len`. Per ENTRY, not per
    decision, because the outer payload is unpacked as a FIXED 2-arity tuple --
    growing THAT is the fixed-arity crash the row's width tolerance exists to
    avoid.
  * The apply compares against the LIVE epoch through a registered read-through
    accessor, not a cached int: boot 30's apply ran INSIDE
    `_release_residents_for_cutover`, so a value refreshed per pass would have
    been one generation stale precisely where the staleness had to be seen.
  * A mismatch (or an unverifiable half-absent pair) routes into the contract's
    OWN already-proven no-adopt path -- boot 29 ran it for its whole life without
    a divergence. That is a way ONWARD, never the boot-15 per-rank refusal that
    re-fired 1448 times and wedged the ring.
  * `UniformWidthPromiseBroken` is NOT softened. It stays as the in-epoch
    invariant's backstop and is now unreachable: if it ever fires again the pin
    itself has failed, which is a group crash by `raenge-nie-uneins`, as written.

SECOND HALF -- #1060b: THE TOLD COUNTER MOVES TO THE APPLY SITE. Boot 30 proved
the row arrives by DYING on it, while `sgl-project#1058 TOLD-VS-LOCAL CENSUS` read
`evaluated=13 absent=13` on PP0 and `evaluated=0` on the two ranks that crashed.
The census sat at the CONSULT -- and PP0 makes the offer and never receives one.
A fact's arrival must be counted where it takes EFFECT. `apply_reached` is the
denominator; `adopted>0` is the only positive proof that a row travelled AND was
applied. Emitted unconditionally at teardown and on the death path, like #1058b.

MATCHED CHECK -- red-first at the boot-30 specimen plus the mandatory
danger-direction mutant. The replay reproduces the raise with the log's own
numbers (told=12288, pin=0), so the gate is proven to be what prevents it; the
mutant asserts that the LOCAL-SPAN rule produces a SPLIT verdict across three
ranks differing only in their span while the epoch rule produces one identical
verdict -- if a future edit swaps the trigger, it goes red. Plus a wiring proof
that drives `apply_uniform_pass_geometry_1059` itself with a live epoch source,
because the pure-function tests prove the RULE and not that the apply consults
it, which is the present-wired-never-populated shape that cost boot 29 a window.
11/11 green, plus 47/47 on the existing sgl-project#1059/sgl-project#791 suites (no regression) and
6/6 on sgl-project#1060. ruff clean on the added lines, py_compile green.

Evidence: /spinning/evidence-665-f1/specimen_1060cens_boot30_uniformwidth_crash/
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 31, 2026
…SIDE one epoch

Boot 31 ran sgl-project#1061's epoch gate and died anyway, at the same site with the same
numbers (`told prefix 12288 exceeds this rank's pinned span 0`). The census I
added in the same commit is what named the reason instead of leaving it to a
guess: `refused_epoch=0`, `epoch_ok=1` on the raising rank. The gate WAS
consulted, it AGREED, and the raise came after it.

ROOT: `PhaseFlipRuntime._epoch` advances at cutover COMPLETION, while the
destructive act -- `_release_residents_for_cutover` dropping the tree and
re-admitting the residents -- runs BEFORE completion, inside the SAME epoch. So
a row decided at epoch N is applied at epoch N during the cutover from N to N+1:
same generation, gate vacuously passes, pin legitimately 0. The staleness window
is not BETWEEN epochs, it is INSIDE one, and an epoch test cannot see it by
construction. The epoch-keying design was answerable at the desk and I did not
ask when the counter moves relative to the act it is meant to fence.

THE RETRACT IS THE EVENT. `_969ad_note_retract` is the chokepoint every
retraction passes and is called immediately before `_add_request_to_queue`, i.e.
before the apply that raised. A told row describes a prefix the request HELD; a
retraction is precisely the statement that it no longer holds it, so the row is
not stale-by-suspicion there, it is stale by definition.

STILL GROUP-UNIFORM, and measured rather than assumed: boot 31 logs
`#969AD RETRACT site=readmit_seam_residents` exactly ONCE on each of PP0, PP1 and
PP2 -- one per rank, same cutover, same rid. No rank consults its own span. Same
shape as sgl-project#946's mark, which "invalidates ITSELF on a retract or cutover".

The epoch gate STAYS. It is not wrong, it is not sufficient: it fences the
cross-cutover case that outlives a completed flip, and the retract clear fences
the in-cutover case. Both refuse into the contract's own no-adopt path, which
boot 29 ran for its whole life without a divergence.

INSTRUMENTED SO THE NEXT BOOT CANNOT REPEAT THE GUESS: the TOLD-APPLY census
gains `retract_seen` and `told_cleared_at_retract`, so "the clear fired" is a
printed number rather than an inference from an absent crash.

MATCHED CHECK, red-first at boot 31: the test drives `_969ad_note_retract`
itself, asserts the told row is gone and the counters moved, and asserts the
apply that raised on boot 31 is now a no-fact pass. 12/12 on this file, 65/65
across sgl-project#1059/sgl-project#1060/sgl-project#1061/sgl-project#791. ruff clean on added lines, py_compile green.

Evidence: /spinning/evidence-665-f1/boot_855_1061epoch_0840f82601_0831_182301.log
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 31, 2026
…ompensation layer, and its bugs were not the finding

Coordinator order (2), after boots 30 and 31 killed the same mechanism twice at
the same site with the same numbers (`told prefix 12288 exceeds this rank's
pinned span 0`). Upstream-minimal law: a defect found in a compensation layer is
a DELETION candidate, never a repair order for that layer. Two repairs were
already spent on it -- sgl-project#1061's epoch gate and #1061b's retract clear -- and the
second only existed because the first was built on a clock whose tick was never
checked against the act it fenced.

DELETED: `pp_uniform_width.py` whole (`uniform_pass_geometry`,
`UniformWidthPromiseBroken`, `report_local_coverage`, `min_told`, `PassGeometry`,
`epoch_admits_row`, `set_epoch_source`, `current_epoch`);
`Req.apply_uniform_pass_geometry_1059` and its call site; the
`_1059_told_prefix/_extend/_epoch` stamps; `PPAdmissionEntry.decided_epoch` and
its wire column; the publication-time epoch stamp; the epoch-source
registration; the told clearing at the retract chokepoint; the
`SGLANG_PP_UNIFORM_WIDTH` gate; three test files.

WHAT DELIBERATELY STAYED, and each for a named reason:

* THE EVICTION FLOOR in `pp_stamp_observed_coverage`. `report_local_coverage`
  was `max(0, int(x))`, but the same line ALSO raises `cache_protected_len`,
  which `mem_cache/common.py:82` honours as an eviction floor. Deleting a
  promise must not silently lower a protection, so the arithmetic is inlined and
  the floor is byte-identical. Only the promise semantics die.
* THE CARRIER COUNTER, renamed to what survives. The #1060b ledger counted the
  told row at the apply site; that apply is gone, but the question underneath it
  is not. Boot 29 shipped a carrier whose send gate had been dead since sgl-project#1046
  and reported `sgl-project#631=0` while nothing executed -- it cost a window and a census
  to notice. `sgl-project#1064 CARRIER CENSUS` counts `rows_received` on every rank, so
  that regression can never be silent again. PP0 never receives, so only a
  downstream zero is a finding, and the line says so.
* `sgl-project#1060`/`sgl-project#1063` untouched: they measure, they never gated anything.

WHAT THIS RETURNS TO: the pre-sgl-project#1059 behaviour, in which every rank derives its
geometry from its own match. That is not a guess about safety -- boot 29 ran it
for its ENTIRE life (`evaluated=87 absent=87`, the row never arrived) across 51
flips with no `sgl-project#631`, no divergence death and no crash. The two boots that DID
die at this seam are the two that ran the promise layer.

c1 (downstream takes the geometry as a VERDICT) is NOT in this commit, and the
reason is a desk finding that inverts its safety argument: `truncate_prefix_to`
is MIN, NEVER ASSIGN (schedule_batch.py, sgl-project#930/sgl-project#958) -- so "verbatim" cannot be
expressed through the one helper both admission sites use, and a rank holding
less than it was told silently keeps its own value, which is the divergence the
verbatim form exists to remove. Reported to the coordinator with the file:line
rather than worked around.

38/38 green across sgl-project#791/sgl-project#1060/sgl-project#1063/sgl-project#677, codec round-trip verified after the
column removal, import smoke of every touched module, ruff clean, py_compile
green.

Order: coordinator (2). Evidence: boots 30/31, specimens
specimen_1060cens_boot30_uniformwidth_crash/ and
specimen_1061b_boot32_int8_triton_wedge/
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