Skip to content

Add openai embedding API - #997

Merged
Ying1123 merged 1 commit into
mainfrom
openai-embedding
Aug 9, 2024
Merged

Ying1123 merged 1 commit into
mainfrom
openai-embedding

Conversation

@Ying1123

@Ying1123 Ying1123 commented Aug 9, 2024 •

Copy link
Copy Markdown
Contributor

@Ying1123
Ying1123 force-pushed the openai-embedding branch 2 times, most recently from 5cf0901 to c343e77 Compare August 9, 2024 08:45
@Ying1123
Ying1123 requested a review from yichuan-w August 9, 2024 08:46
@Ying1123
Ying1123 force-pushed the openai-embedding branch 2 times, most recently from 363da49 to 0807173 Compare August 9, 2024 08:56
@Ying1123 Ying1123 mentioned this pull request Aug 9, 2024
15 of 29 tasks
@yichuan-w

Copy link
Copy Markdown
Contributor

LGTM

@yichuan-w

Copy link
Copy Markdown
Contributor

btw, I have one small question, why switch the max_num_tokens from 1 to 0?

@Ying1123

Ying1123 commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

btw, I have one small question, why switch the max_num_tokens from 1 to 0?

Did you mean switch from 0 to 1? This is because our default logic for generation model suppose it will generate 1 token after prefill. Although embedding models do not generate tokens, I added one dummy token to cheat with the shared part of the code.

@Ying1123
Ying1123 merged commit b16e856 into main Aug 9, 2024
@Ying1123
Ying1123 deleted the openai-embedding branch August 9, 2024 18:19
@yichuan-w

Copy link
Copy Markdown
Contributor

btw, I have one small question, why switch the max_num_tokens from 1 to 0?

Did you mean switch from 0 to 1? This is because our default logic for generation model suppose it will generate 1 token after prefill. Although embedding models do not generate tokens, I added one dummy token to cheat with the shared part of the code.

I see, thanks for answering

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
… argument says it must not be

BOOT 16, ROOTED. A proxy stamped mb_id=1 killed PP1 sitting on mb_id=2, same
flip epoch 2. The refusal is correct and the guard must stay: without it the
hidden states of one microbatch pair with another's metadata, and chunked
prefill caps every chunk at the same width (rows=4096 here), so the width
check in model_runner.forward cannot see it. Loud beats silent.

THE ROOT IS `_pp_flip_hold_slot` (scheduler_pp_mixin.py:5241), and it is one
line: `if getattr(self, "chunked_req", None) is not None: return False`
(:5330-5331). AST-checked, the function reads `chunked_req` and `mbs` and
nothing else -- no counters, no collective, no barrier. Its own docstring
names the property that makes it correct: "WHY THE HOLD IS REACHED ON THE
SAME SLOT ON EVERY RANK, which is the only property that makes this correct"
(:5292-5302). That argument assumes every rank ENTERS the hold. A rank the
chunked_req exemption excuses never does, so the sole stated correctness
precondition is void exactly when the ranks disagree about holding a chunk --
and `scheduler.chunked_req` is a single rank-local field, so disagreement is
the normal case under load.

Boot 16 is the measurement. PP0 held no chunk and held its slot; PP1 and PP2
each held one and were excused (log :2090, :2094 "a chunked prefill is
incomplete"). group passes [0, 1, 1], group RESUME SLOTS [1, 2, 2] -- the
system's own PASS-CLOCK line (:2105) prints DIVERGED and names the
consequence, one second before the consequence arrives.

THE FLIP NEVER HAPPENED, which the briefing had backwards and which is half
the diagnosis: epoch 2 was ABANDONED at the 60s deadline (:2099, "NOTHING was
entered and no request was touched"). No cutover, no ring rebuild -- so the
same-epoch branch of the guard, and a ring that runs on rank-locally divergent
slots with no point at which the group ever agrees one.

THE GUARD'S OWN HINT IS WRONG, and this is the fourth such comment in this
campaign. It sends the reader to the drains. The message that lands is not a
leftover: it is a correctly stamped current-epoch proxy from a rank genuinely
on slot 1, created AFTER the disarm. Structurally neither drain can see it --
pp_flip_drain_tensor_dicts runs only while armed (:5832 under :4703) and
pp_flip_drain_leftover_dicts is one-shot at the falling edge (:5196, disarmed
by :5036). Fifth wrong comment, same neighbourhood: that drain's docstring
says it is "left here, uncalled" (:5521-5530) while :5832 calls it.

The backstop is rank-local too (`passes == 0`, :5121), and the group verdict
`agreed` is computed at :5215 and only logged. Instrument without actuator,
the same shape as the dead ratchet in sgl-project#996.

Also folds in two sgl-project#996 corrections from the arithmetic sweep, both verified
here: init_next_round_input refreshes the FILL half unconditionally (:1326)
and gates only the prefix half (:1355), so the object is half-refreshed and
the census now says so; and pp_carried_fill_* / mamba_slot_acquired_this_
admission ARE cleared by reset_for_retract (:1924-1925, :1937), so they belong
to RESET for residents, with the non-resident half named as still open.

DESK-PROVEN: log plus code plus AST. No metal, so nothing here is fixed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
The arithmetic axis proposes a competing root for the same specimen: a
mis-derived last_chunk minted a continuation the decision never named, and
that continuation's proxy is the leftover. Cut C (26ccc10) is committed
against it and is justified on its own terms.

Both mechanisms are present. The slot divergence is the EARLIER one and the
timeline decides it: the armed window ran 22:20:47-22:21:47 and the gauges
diverged inside it, published per armed tick (:5025); PASS-CLOCK printed
RESUME SLOTS [1,2,2] DIVERGED at 22:21:48 (:2105); the FILL-ADOPT and any
post-abandon mint can happen no earlier than 22:21:48 (:2120, :2126). An
event at 22:21:48 cannot have caused a state divergence that arose in the
preceding minute and was already printed.

And the observed stamp mb_id=1 is exactly PP0's published resume slot, so
ordinary operation over a divergent ring explains the message with no extra
mint at all.

Prediction recorded so it can be falsified by the next boot: the leftover
SURVIVES Cut C, because passes [0,1,1] hangs on the chunk ASYMMETRY at
:5330-5331 and not on the chunk LENGTH.

Also corrects an attribution: this analysis does not claim 'who holds the
slot across the reset'. There was no reset in this specimen -- the flip was
abandoned. The claim is narrower: the actuator meant to keep ranks
slot-uniform during an armed window is rank-locally conditioned, and thereby
voids the correctness precondition its own docstring writes out.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
The arithmetic axis withdrew its causal claim and supplied two facts with it.
Both re-run against the log here, because the rule that agent reports are not
evidence applies to a retraction as much as to a finding.

NK-1: grep -c AssertionError over the whole Boot 16 log is 0. The
`assert self.chunked_req is None` never fired. That assert is Boot 14's
death; Boot 16 is a different one, and one narrative was covering two.

NK-2, and it is stronger than the ordering argument it replaces: SECOND
CONTINUATION REFUSED appears exactly twice, :2034 (22:20:45 PP1) and :2045
(22:20:46 PP2) -- BEFORE the armed window opens at 22:20:47. The sgl-project#959/#995b
guard held and no second continuation was ever minted. A path that is guarded,
handled, and finished before the window cannot kill after it.

So the claimed producer did not exist and its characteristic death did not
occur. The ring divergence stands as Boot 16's root.

Two predictions now stand side by side for the next boot under Cut C, on
disjoint quantities so one boot answers both: this axis says the sgl-project#631 leftover
SURVIVES (slot index, hangs on the chunk asymmetry at :5330-5331); the
arithmetic axis says the two SECOND CONTINUATION REFUSED go to ZERO (mint
counter). Both landing means two defects were separated rather than one told
twice.

And the class is the same at both seams, which is their observation and a good
one: schedule_policy.py:1433 derives last_chunk from a rank-local fill length,
:5330-5331 exempts the hold on a rank-local chunked_req -- a rank-local
predicate deciding a quantity that must be group-uniform. That is Family B of
ANALYSE_996, found twice independently.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
…ter a boot

Commit 7398727 published two predictions. The second one was wrong, and it
was wrong at the time I published it -- its author withdrew it before the boot
ran and I re-checked the withdrawal against the log myself. It stands struck
through rather than deleted: a published prediction may not quietly vanish.

WHY (b) IS FALSE, three ways, all in the specimen:
 * The refusals' actual cause is printed one line ABOVE each of them: :2033
   (PP1) and :2044 (PP2), 'sgl-project#992 CHUNKED CONTINUATION NOT NAMED rid=da614e20
   executed=7939 decision_names=5689567b'. That is the sgl-project#992 asymmetry -- the
   followers hold a resident the decision does not name -- and no false
   last_chunk is involved.
 * :2028 'sgl-project#968 MINT none rank=0 rid=5689567b end=4096 prefix=0'. It was a
   genuine MIDDLE chunk, so last_chunk=False was correct. Cut C carries the
   same verdict and the refusal fires unchanged. Two stays two.
 * :2120 'local=8446 -> upstream=8447 appended=1'. The follower is SHORTER and
   the adopt raised it, which is the covered direction. Site #0 needs the
   executing rank LONGER. That never happened in this boot.

So Site #0 is desk-proven as a defect, has ZERO boot-observed instances, and
contributed nothing to Boot 16. Cut C fixes a LATENT defect and the next boot
can neither confirm nor refute it -- which matters operationally, because
anyone watching for an indicator there is watching for one that cannot come.

Exactly one prediction now rides on the boot: the sgl-project#631 leftover SURVIVES.

And the class section is corrected rather than left flattering: the two seams
do NOT carry the same evidence tier. D1 (:5330-5331) is boot-proven at the
symptom; Site #0 (:1433) is desk-proven with no instances. Two independent
finds still argue the class better than one, but the class is carried by the
metal-backed half, and writing it otherwise would inherit exactly the
overclaim the indicator law exists to forbid.

The error form is recorded too, because it is not a foreign one: an event that
FITS a mechanism was read as BEING that mechanism, without reading the line
above naming the alternative. Twice, and both times the refutation was one line
higher in the same log. Same shape as the dead ratchet in sgl-project#996 and the false
guard hint in sgl-project#997. The cheap counter-check is the same in all three and costs
seconds: read the line above.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
… does

Filed by the arithmetic axis, verified here against the tree. Not a defect in
behaviour -- a defect in the REPORT, which is the form this campaign has now
paid for four times.

note_second_continuation_refused (schedule_policy.py:59-75) writes into every
line it emits: 'Nothing of it has run, so no progress is lost'. For two of its
three callers that is true -- add_one_req (:2192-2194) reports and RETURNS,
with set_extend_range only afterwards at :2197. For _add_scheduled_req
(:1611-1614) there is no return: the method continues through
_req_inc_lock_ref (:1616), taking a tree lock ref, and _update_prefill_budget
(:1617), charging the budget. The request RUNS; it is merely not announced as
a continuation. The behaviour is intended and #995b argues it soundly at
:1599-1610. Only the sentence is wrong.

This belongs in THIS analysis and not only next door, because Boot 16's two
refusals are both site=_add_scheduled_req (:2034, :2045). Anyone reading those
two lines in the specimen takes from them that nothing ran and nothing was
spent, while both requests took a lock ref and charged budget. The misdirection
is not hypothetical; it is waiting in the exact log this analysis reads.

Four in one campaign now: the dead ratchet (sgl-project#996), the guard hint pointing at
the drains (sgl-project#997 section 3), the 'left here, uncalled' docstring of a drain
that is called at :5832, and this report. Filed, not built -- the fix is one
sentence of log text and does not belong in a boot cycle.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
…ed are not six of anything

Two corrections, both from the arithmetic axis, both re-checked here.

A4 IS STRONGER THAN FILED. The lock ref does not merely happen at
_add_scheduled_req; it is unavoidable. The decline block sits inside
schedule_policy.py:1554 'if not last_chunk and not carried_chunk:' -- measured
by indentation, :1611 sits at 12 and :1615 at 8, and the nearest enclosing if
at column 8 is :1554. So carried_chunk is constructively False there, 'if not
carried_chunk:' (:1615) is unconditionally true on this path, _req_inc_lock_ref
(:1616) ALWAYS fires, and _update_prefill_budget (:1617) is charged prefix_len
rather than 0 (:1618).

AND THE COUNT WAS CONFLATING TWO THINGS. Form A is an instrument whose TEXT
does not describe what it does: the tautological discovery diff, the guard hint
pointing at drains that are structurally off at the moment of impact, the
docstring calling a called drain 'uncalled', and this report. Four. Form B is a
READER error at an instrument: an event that fits a hypothesis read as
confirming it without checking the line beside it that names the alternative.
Two, both on the arithmetic axis, both withdrawn by their own author before any
metal was spent on them.

They share the indicator law's root -- an indicator treated as a finding before
anyone checked THAT it measures what it claims -- but A is a defect in an
artefact and editing fixes it, while B is a defect in method and the
counter-check fixes it: read the line above. Four A and two B, not six of
something.

A4 IS NOT BUILT BEFORE THE BOOT, and the reasoning is recorded rather than
assumed: the next boot tests this analysis's prediction, and an unrelated code
change blurs attribution without the boot needing it. Speed mode wants a reason
for a single deliberate piece in the critical path, and 'a log line reads
crooked' is not one. Take it the next time this file is opened.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 29, 2026
…ery rank

extend = min(fill - prefix, cap). Three of the four quantities are now
settled by measurement:

  cap    -- group-uniform. sgl-project#610 subtracts each rank's surplus over the group
            minimum, and all three ranks read 12977. It also never bound:
            the binding term was chunk(4096) against extends of 253/254/
            277/278.
  prefix -- equalised by the sgl-project#791 truncation, both branches, code-read.
  extend -- differs. That is the observed 254 against 301.

So the fill differs, and `_refresh_fill_ids` defines it as
`origin_input_ids + output_ids` with a rank-identical prompt. `output_ids`
is the single rank-local component of the whole equation.

And `req.output_ids.append` lives in the RESULT path
(batch_result_processor.py:276), which a VOIDED pass never reaches. These
boots are void-dominated. That is a complete chain -- void pass, output
falls behind, fill falls behind, extend differs, the sgl-project#631 guard fires -- and
every link of it is code-read rather than argued. It is not yet MEASURED.

This prints `fill_lens` and `out_lens` per rid on the existing
`sgl-project#788 PP-ADMISSION verdict` line, which already carries `rids` and
`prefix_lens` and already fires on every rank. It is the only carrier that
allows a cross-rank comparison FOR THE SAME REQUEST. No new emission: the
same `logger.info`, more fields -- the event perturbs this path (measured
four times), the bytes do not (measured twice, and this is the third test).

THE PREDICTION IS DIRECTIONAL, not just "a difference": the rank with the
smaller `out_lens` must also show the smaller `fill_lens` and the smaller
extend. A difference in the wrong direction refutes the chain rather than
confirming it. If `out_lens` agrees across ranks the chain is sound but not
what happened here, and the remaining writer is `pp_carried_fill_tail`
(schedule_batch.py:1300-1305), which is also rank-local.

I will not compute 301-254=47 into anything, whichever way the numbers land.
Name the carrier, then measure the difference -- this window produced four
numbers-fit traps and I walked into one.

Evidence: desk. py_compile; the format verified by rendering it through
logging rather than by counting placeholders. Belegstufe: DESK-BEWIESEN.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 29, 2026
The flip-hosted trace is the structural half of sgl-project#997 and stays off the
critical path. This measurement does not need it -- it needs two integers.

WHERE. `req.output_ids.extend(next_token_id)` in
`process_batch_result_decode` (batch_result_processor.py:873) -- the DECODE
append, which is the one that feeds the divergent term. #997b instrumented
the PREFILL append instead and could not have seen it: the dying batch was
EXTEND, but its fill carries the output_ids from the preceding DECODE steps.

WHY THIS IS THE LAST TERM. extend = min(fill - prefix, cap). prefix is
equalised by the sgl-project#791 truncation (both branches, code-read); cap is
group-uniform (sgl-project#610 pins each rank to the group minimum, measured identical
at 12977) and never bound (4096 against extends of 253-278); fill is
`origin_input_ids + output_ids` with a rank-identical prompt. `output_ids`
is what is left, and this append is where it grows -- inside the RESULT
path, which a voided pass never reaches.

FOUR CONSTRAINTS, each paid for in this window:

  COUNT AT THE EVENT, EMIT ELSEWHERE. #997b put its denominator inside the
  line it gated, so zero lines meant zero information. A denominator that
  lives in the same call as the event shares the event's fate.

  THE EMISSION SITE IS VERIFIED TO RUN FIRST. `pp_ring_note` printed 241
  lines across all three ranks in boot 36. Boot 40 cost a cycle to the
  opposite mistake: I fixed a gate on an object that was never constructed,
  because I checked the arming and not the host.

  NO HIT FILTER, DENOMINATOR ALWAYS. `seen` and `tracked_rids` ride on every
  line, and the message states that an empty sample with seen=0 means the
  append never ran rather than that nothing diverged.

  SENTINEL -1. `len(output_ids)` can legitimately be 0.

The per-rid map is last-writer-wins and bounded at 32 entries: the reader
compares one rid across ranks, so one live value per rid is enough.

Cumulative, carried in every report: WIDTH=12, IDENTITY=5 over 17 no-flip
boots. At a one-in-three base rate the death form is not a signal in either
direction, and this is a state reading regardless.

Evidence: desk. py_compile on both files; smoke asserting the counter sits
at the decode append with a working scheduler path, and that the emission
sits in `pp_ring_note`. Belegstufe: DESK-BEWIESEN.
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