Skip to content

Make public APIs more standard. - #416

Merged
hnyls2002 merged 1 commit into
mainfrom
api-expose
May 9, 2024
Merged

hnyls2002 merged 1 commit into
mainfrom
api-expose

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

This PR fixes #386, trying to avoid using import *, making all the public APIs more visible.

@hnyls2002
hnyls2002 merged commit 6ec65f4 into main May 9, 2024
@hnyls2002
hnyls2002 deleted the api-expose branch May 9, 2024 07:39
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
EdwardXuy pushed a commit to shun8686/sglang that referenced this pull request Apr 23, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
Section 7 could push a tag and had nothing that looked at the result. sgl-project#416 is
the precedent for why that is not enough: an image that built fine, pushed
fine, and was wrong for the person who pulled it. The only check that catches
that class is pulling the published artifact by tag with no local layers and no
build context, and inspecting what it actually contains.

7.1 adds three: the provenance guard, the sgl-project#416 empty-flag behaviour itself, and
the NCCL floor read from NCCL's own banner. Check (a) fails today on the
already-published htsglang:cu130-nccl2307, which predates the guard, so that is
written down as a precondition rather than left to be rediscovered -- whatever
goes out next has to pass it before anything is announced.

The apparmor requirement is recorded as covering every docker run in this LXC,
not only the serving one; a trivial probe hit it first. The orphan-container
VRAM trap is written down with the check that actually detects it, since
docker ps alone does not show the container still holding the reservation.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…es, and supersede the shadowed tag

Closes the draft's own blocking item 2b. Every feature in
FEATURES_VS_UPSTREAM.md now carries an evidence label with the figure quoted
verbatim: measured when a run produced it, estimate when the document itself
says it is not a measurement, absent when there is no defensible number. The
tally is 16 measured, 1 estimate, 17 absent -- half the fork has no number, and
those rows keep an empty number slot rather than an invented one.

Two things the table forces the README to say out loud. Four rows carry figures
that are not wins and would be overclaims if presented as gains: the
cross-algorithm bandit LOSES to the static winner at 75.52 against 89.22 tok/s,
session KV spill lands at 37.74 vs 37.92 ms per verify round which is inside
the boot-to-boot band, per-message-class link selection lands inside its own
control's spread and the document says it is not worth it on this rig, and both
cross-rig PP and the prefill satellite are costs bought deliberately for
capacity and for undisturbed decode. SWA-DCP's ~+6-10% is marked estimate and
must never be quoted as measured -- the document calls it ex-ante.

Every figure carries the lower-bound framing and the detection limit, because
without them a number from this rig reads as a benchmark: raw tok/s has a
2.6-4.2% boot-to-boot spread against 0.09-0.85% for ms per verify round, so
anything finer than ~3.5% belongs on the round-time axis and values inside the
spread are not gains.

The summary line above the table first said fourteen absent rows. It was
seventeen. The count is now taken mechanically and the error is recorded in
place, since a miscounted summary sitting above a correct table is exactly how
an invented number enters a document written to keep them out.

Checklist 7.0 makes superseding the published tag a mandatory pre-push step.
The characterisation matters and the loose version is already circulating: the
published cu130-nccl2307 is NOT armless. Two distributions provide sgl_kernel
and the fork's armed files currently win, so the arm is present today. The
defect is instability rather than absence -- pip reports no conflict, so the
next install of either one silently decides which files win, and one candidate
is armless. An image that is correct today and one pip install from being wrong
is not shippable, which is why the guard treats a shadow as an error even with
the arm present. The new build must take the tag, the new digest must be
recorded, and the sgl-project#416-style verify must re-run against that digest by
sha256 rather than by tag, since a tag can move between push and check.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
… methods (issue sgl-project#417)

sgl-project#416 plan PR-1: remove benchmark/bench_dt_{feature,cuda_ipc,candidate}_p2p.py
and benchmark/dt_sm_comm/ (zero references from ci/, analysis/, .github/,
dt-runtime), the self-referenced speculative/dt_completion_source.py, and
fork-added methods nothing calls: CandidateArena.has_active,
CudaIpcPrimitives.stream_synchronize/stream_wait_value32 (+ the
_stream_wait_value32 loader and CU_STREAM_WAIT_VALUE_* constants),
_RingMapping.entry_bytes, RingGpuPublisher.stage_request,
DraftRingWorker.consumed_seq (+ _consumed_words and the
dt_ring_worker_consumed_seq_address binding), FeaturePull/KV transports'
invalidate_peer (+ _invalidate_peer_if_healthy), dt_rdma._wait_one.
Delete-only; no behaviour change on the default path.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…oject#436, sgl-project#416 PR-5)

DT_RING_DEBUG=1 was the only way to reach _RingDebugLog: rate-limited
per-window counters for the candidate completion channel. Nothing in
sglang, dt-runtime, ci/ or the current analysis/ scripts ever sets it
(non-default), so the whole diagnostic path is dead code.

Deletes the env read, the class, both constructors (target arena and
draft push transport) and every bump/note_call/maybe_emit call site in
dt_candidate_p2p.py, plus the now-dead timed_out / socket_received
locals they were the only readers of. No behaviour change on the
default path: the switch was off, so no counter ever ran.

test/registered/cpu/test_dt_candidate_completion_channel.py: drop the
make_arena fixture's arena._ring_debug line, and restore a real
assertion to test_notice_drain_honors_time_cap (issue sgl-project#419 review p2).
The test lost its deadline assertion when it moved into the CI tier and
passed even if the wall-clock cap never fired. It now asserts the
observable consequence of the cap firing early: the poll returns with
the peer's backlog still queued, while still having consumed some
messages (so a cap that never fires drains all 1000 and fails, and one
that fires before any read fails the other way). Verified by mutating
the cap check to `if False`: the test fails.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…h (issue sgl-project#436, sgl-project#416 PR-6)

DT_FEATURE_PULL_INLINE=1 (the default) made DraftFeaturePullTransport.submit()
enqueue the copy on the calling scheduler thread and poll it by event query;
=0 dispatched the same pull to the ThreadPoolExecutor instead. Nothing in
sglang, dt-runtime, ci/ or the current analysis/ scripts ever sets it to 0,
so the executor branch of submit() is dead code.

Deletes the env read, the always-true guard around the inline stream setup,
submit()'s executor fallback, and DraftFeaturePullTransport._run_pull, which
only that fallback called. The `import os` read was the file's last use of
os, so the import goes with it.

Kept deliberately:
- submit_remote_batch()/_remote_worker_loop()/_submit_remote(): the cross-host
  pull worker, called unconditionally from dt_draft_engine.py:6634 — the live
  cross-host path, not a switch alternative.
- submit_batch() and its executor dispatch: this switch never gated it (it
  has always had a single path), so removing it would be an unrelated
  refactor outside sgl-project#416 PR-6. Note for the foreman: after issue sgl-project#417 deleted
  benchmark/bench_dt_feature_p2p.py, submit_batch() has no production caller
  left — only test/registered/cpu/test_dt_feature_peer_queues.py — so it is a
  candidate for a separate zero-caller-method slimming PR, not for this one.
- _run_batch(), _run_admitted(), _executor: still reached from submit_batch(),
  the quiescence probes and close().
- the admission accounting: _submit_inline() does its own
  _admitted_pulls +/- around the enqueue, so the fence/quiescence contract
  that close() waits on is unchanged on the default path.

No behaviour change on the default path: the switch was on, so submit()
already returned _submit_inline() and none of the deleted code ran.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…ssue sgl-project#436, sgl-project#416 PR-8)

DT_PUBLISH_WORKER=1 (the default, owner Q17 of issue sgl-project#244) makes every
candidate push's stream work — copies, publish words, the cross-host post,
the completion record — run on the native publish worker thread instead of
the Draft scheduler thread. =0 issued it inline on the scheduler thread.
Nothing in sglang, dt-runtime, ci/ or the current analysis/ scripts ever
sets it to 0 (the only reference was a launcher env-forwarding assertion),
so the inline path is dead code.

Deletes the env read and the constant, the None alternative in
DraftCandidatePushTransport.__init__, submit()'s inline else-branch,
_publish_batch_memops (its only caller), the worker-absent half of
publish_cancelled()'s via_worker condition, enable_send_loop()'s
None return, the DT_DRAFT_SEND_LOOP mutual-exclusion raise in
dt_draft_engine._ensure_ring_worker, and the now-unreachable
CandidatePost.launch() plus the Python-side cuLaunchHostFunc binding
(_host_post() now resolves only the CUhostFn the worker launches).

Kept deliberately:
- _PublishWorker, csrc/dt_publish_worker.cpp and every dt_publish_worker_*
  symbol: this is the live path, not the switch.
- publish_cancelled()'s via_worker=False branch (the inline stream writes):
  selected by worker.batches_enabled, so it still serves methods without a
  send loop (sgl-project#416 PR-8 note), not by the deleted switch.
- _RemotePushEvent: still constructed by publish_cancelled()'s
  cross-host tombstone path.
- CandidatePost.post()/host_call(): live for tombstones and worker jobs.

No behaviour change on the default path: the worker was always created, so
submit() always took the _submit_to_worker branch and every guard I removed
was already true.

Tests: TestPublishMemopSequence exercised the publish-edge word sequence
through the deleted _publish_batch_memops; it becomes
TestPublishWordSequence and pins the same (address, value) sequence through
_publication_words, the generator the worker job is built from (the native
worker issues those words with cuStreamWriteValue32,
csrc/dt_publish_worker.cpp:300). FakeRuntime existed only to capture those
memops and is deleted with it. test_dt_publish_worker_gate.py's docstring
mentioned the switch; the gate contract it pins is unchanged.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…t limit) (issue sgl-project#433)

Slimming wave 2, sgl-project#416 plan PR-10 + PR-11.  Since sgl-project#420 DFlash always uses
native ingress, both switches only ever produce a startup error in a
non-default value, so the env reads and the credit lifecycle go:

- DT_DRAFT_SLOT_DECOUPLE: `self._slot_decouple = self._is_dflash`.  The
  compute-busy staging code (_feature_staging_compute_busy, per-slot
  scratch) stays — it is the live path for eagle3/standalone, where
  _slot_decouple is False.
- DT_DRAFT_ADMISSION: the cuda-ipc proposal-credit lifecycle is deleted
  (_acquire/_release/_available_direct_proposal_admission,
  direct_proposal_admission_limit, _direct_proposal_admission_inflight,
  the admission_credit fields of PendingEagle3Completion and
  PendingCandidatePush, and DT_DIRECT_PROPOSAL_ADMISSION_LIMIT with its
  resolver).  Under the batch bound the cuda-ipc path has no admission
  resource, so _proposal_admission_blocked /
  _proposal_wave_buffer_exhausted / _take_batch's cuda-ipc arm and the
  free_result_rows cuda-ipc arm report "never blocked" / the registered
  constant, which is what the default already did.  _available_dflash_result_slots
  and its reservation accounting stay: non-cuda-ipc uses them.
- The require check keeps only the DT_RING_CONFIRMATION clause (deleted
  in the next issue).

No behaviour change on any default path.  The credit test file becomes the
smaller admission contract test (the cuda-ipc gates never block; the mmap
pool still gates on raw emptiness); the confirmation-free capacity fixture
drops its stub of the deleted method.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
 plan PR-13)

Guard-only switch (sgl-project#416 table row 11): the only read was the
DraftControlLoop/DraftWake setup guard, which is now unconditional for
DFlash.  The DT_DRAFT_SEND_LOOP require check drops its
DT_DRAFT_CONTROL_LOOP clause.  No behaviour change on any default path.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…ct#435, sgl-project#416 plan PR-14)

The send loop is the only DFlash mode, so self._send_loop = self._is_dflash
(the require check keeps its one structural clause: DFlash requires the
cuda-ipc candidate transport).  The legacy no-send-loop arms go:

- _drain_ready's fence-event poll (the fence is a release-only descriptor
  whose seq-0 DONE record retires it in ABSORB);
- _release_ready_rows's scheduler-pushed fence branch (DFlash-only method;
  the ring worker and the send-loop worker are created together);
- the shutdown drain's _poll_dflash_completions else arm;
- _launch_dflash_materialization's no-hand-off elif (the launch always
  hands the batch to the send loop).

_send_loop_worker is None branches that serve non-DFlash methods stay:
_close_direct_rings (eagle3/standalone have a ring worker and no send-loop
worker) and the run()/push-spin _push_done_worker is None polls (eagle3).

No behaviour change on any default path.
WhiteCmile added a commit to WhiteCmile/sglang that referenced this pull request Dec 1, 2026
…t#435, sgl-project#416 plan PR-15)

The v2 scheduler is the only DFlash mode, so self._scheduler_v2 =
self._is_dflash and run() serves only eagle3/standalone/flashmtp.  Its
DFlash-only arms go: the send-loop ABSORB block, the
_poll_dflash_completions poll and its idle-wait clause, and the
_run_scheduler_v2 require check (never reachable: DFlash always uses the
direct GPU source).  _poll_dflash_completions itself is callerless after
this and goes too, along with the CPU test whose entry point it was (the
fatal-quarantine cascade it asserted stays covered through the send loop's
failure record and the shutdown fence path).

run() itself stays for eagle3/standalone/flashmtp.  No behaviour change on
any default path.
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.

Use __all__ to explictly control the APIs.

1 participant