Skip to content

model_runner simplify - #329

Merged
hnyls2002 merged 1 commit into
mainfrom
model-runner
Mar 24, 2024
Merged

hnyls2002 merged 1 commit into
mainfrom
model-runner

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

dispatch different forward modes' argument only inside the function, remove the **kwargs for better simplicity.

def forward(self, batch: Batch, forward_mode: ForwardMode):
if self.is_multimodal_model and forward_mode == ForwardMode.EXTEND:
return self.forward_extend_multi_modal(batch)
elif forward_mode == ForwardMode.DECODE:
return self.forward_decode(batch)
elif forward_mode == ForwardMode.EXTEND:
return self.forward_extend(batch)
elif forward_mode == ForwardMode.PREFILL:
return self.forward_prefill(batch)
else:
raise ValueError(f"Invaid forward mode: {forward_mode}")

@hnyls2002
hnyls2002 merged commit 24e59f5 into main Mar 24, 2024
@hnyls2002
hnyls2002 deleted the model-runner branch March 24, 2024 11:48
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu added a commit to efschu/htsglang that referenced this pull request Aug 1, 2026
…ce/snapshot/re-form/restore/resume with rollback only before re-form, 12-20 s budget from the measured record, ONE unmeasured step (live NCCL teardown/rebuild = cut 1 with named fallback), admission is a planner decision, never a transient-failure reflex (sgl-project#329 design)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…sgl-project#568 correction

Same-step rule was missed on 7d70249: the mechanism shipped without its
FEATURE_CATALOG line. Added beside session_handover, which is the same
five-phase vocabulary one tier down.

The entry carries three things a future lane would otherwise re-derive:

* the four GATES with line anchors -- completeness, membership (a differing
  member set is refused, naming both; RE-FORM is absent by construction, not
  disabled by flag), phase order, and the trigger TYPE (DESIGN_329 §9's
  no-transient-reflex rule is enforced by making the reflex inexpressible);
* the DETERMINATION that RESTORE is the only phase with no in-process
  implementation, with loader.py:2468's skeleton rebuild and its parse-time
  selection at server_args.py:16097 named, so nobody re-opens that question;
* the sgl-project#568 CORRECTION on record, marked do-not-re-litigate: the
  non-persistent-buffer fix DOES generalize (a rule over the persistence
  property at translator/ledger.py:436, plus weight_updater.py:361 which never
  had the bug), and NON_CHECKPOINT_NAME_PATTERNS at phase_flip_boot.py:67 is
  the weights-arena exclusion, NOT that fix -- citing it as evidence of
  non-generality is the specific error I made and retracted.

Also records that ASSET_CLASSES is not the sgl-project#286 offload register, since §17
already warns that "sgl-project#286 offload register" names two modules.

Line anchors verified against the source rather than quoted from memory; two
of them (phase-order and trigger gates) were wrong on first write and
corrected to :272 and :255. codespell clean.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…-- do not build, do not fork a third lineage

No code, by design. The slice was to build per-session KV export/import; the
prior-art gate says it is already built, so the deliverable is the
determination plus the catalog line.

WHAT EXISTS. session_handover.export_session_snapshot (:415 on
train/0818-desk-410-reconcile) -- "flush one session's KV pages AND its GDN
blob to the store, then emit the manifest that names every blob ... the whole
of sgl-project#261's SNAPSHOT phase, callable by anything that needs a session on stable
storage" -- with verify_import (:253) as its other half. session_checkpoint.py
states the rule that settles it: "There is exactly ONE session serialization
in this fork ... a second one would be a second thing to keep byte-correct."
Two consumers already ride it: sgl-project#410 checkpoints (tier, branch/rewind) and sgl-project#411
portable sessions (the same manifest as a manifest-first tar).

IT ALREADY ANSWERS THE CONCERNS RAISED AGAINST THE SLICE, none of which would
have needed adding:
  * owner rules / uneven-DCP -- GEOMETRY_FIELDS = ("tp_size", "page_size",
    "dcp_owner_mode"), page_size == 1 inherited FROM dcp_owner_mode, mismatch
    refused by name in verify_geometry, REFUSED_HOST_LAYOUTS = ("page_head",);
  * sgl-project#212 -- the GDN blob is named in the manifest and a hybrid-GDN export
    without it is refused;
  * it is not a duplicate of kv_session_offload, which is
    spill-to-keep-computing (resume flag default OFF) rather than the at-rest
    counterpart.

WHY THIS BRANCH STOPS. export_session_snapshot exists ONLY on the sgl-project#410/sgl-project#411
lineage; none of 682578f, 22ef67c, 35a68b2, 03adbf8 is in this
branch's ancestry. This branch has only the private method it was lifted from
(SessionHandoverRuntime._export, :446). Building here would create the second
serialization that module forbids, on top of a reconciliation another lane
owns and is mid-flight. Stopping and reporting, as instructed.

A CORRECTION OF MY OWN PHASE MAP, made in both places that carried it.
ANALYSE_329_cut2_phase_map.md listed per-session KV export AND import as
MISSING. Wrong the same way twice: I searched this branch's tree and read
absence-from-my-lineage as absence-from-the-fork -- the precise error the
prior-art gate's "grep the module name across git log --all + tree" clause
exists to catch, which I ran for session_checkpoint.py and then under-weighted
when it came back on other branches. Both rows now read EXISTS-other-lineage
with the file:line.

The correction SHRINKS what sgl-project#329 cut 2 still needs: not a mover, only the
per-session orchestration across the session table. world_roundtrip._Seams'
write_snapshot / read_snapshot are already exactly that seam, so no code in
world_roundtrip.py changes -- which is the cheapest possible confirmation that
the seam was cut in the right place.

LEFT, with its blocker named: wiring those two seams to
export_session_snapshot / verify_import per session, AFTER the A+B
reconciliation lands. The byte movement itself is a window item, under the
standing limit that GDN prefill is non-reproducible above ~109 tokens, so
identity is asserted on the STATE BLOB and never on generated output.

Also closes the catalog debt from 7d70249 (previous commit e962812) by
recording the determination where a future lane will hit it first.

Suite unchanged: test_world_roundtrip_329.py 29 passed, 8 subtests.
codespell clean on all three documents.
1195343015 pushed a commit to 1195343015/sglang that referenced this pull request Dec 2, 2026
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.

1 participant