Skip to content

fix decoding stats - #974

Closed
min-xu-et wants to merge 1 commit into
sgl-project:mainfrom
etched-ai:benchy
Closed

min-xu-et wants to merge 1 commit into
sgl-project:mainfrom
etched-ai:benchy

Conversation

@min-xu-et

Copy link
Copy Markdown
Contributor

fixed the stats for decoding

Before:
image

After:
image

Modification

  • use a time counter in seconds that keep track of decoding timing
  • do not rely on when is the print function is called
  • also simplified the init of the max prefill arg since it is not computed
  • also fixed typo of "hit rate" to "hit ratio"

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.

# A default value "None" means a computed default value will be used.
mem_fraction_static: Optional[float] = None
max_prefill_tokens: Optional[int] = None
max_prefill_tokens: int = 16384

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merrymercy I can change this back to None and add some code to automatically compute this value to avoid the OOM. Can you let me know what the best way to compute this value? much thanks!

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.

this looks good. We will use chunked prefill to solve this ultimately

for _ in range(global_config.num_continue_decode_steps):
self.num_generated_tokens += len(self.running_batch.reqs)
self.total_decoded_tokens += len(self.running_batch.reqs)
# TODO (min): use cuda events for better timing measurements.

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.

do not use cuda events here as we want to measure something more end-to-end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. cpu time measurement isn't always accurate though. but it is like not a big deal here. I will remove this line.

return

# Update batch tensors
self.decode_forward_ct = (self.decode_forward_ct + 1) % (1 << 30)

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.

it is also used somewhere else

self.decode_forward_ct % self.stream_interval == 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did NOT remove this. I just moved it into the place where the decode is actually done. Also, I removed the overflow avoidance code since python int are big int and never overflows.

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.

sorry, I miseed that change. Please move the code back here as we want to keep def forward_step(self): as short as possible. It is the highest level of scheduling so we want to make it short and easy to understand.

# TODO (min): use cuda events for better timing measurements.
start_tic = time.time()
self.forward_decode_batch(self.running_batch)
self.total_decoding_seconds += time.time() - start_tic

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.

we want something more end-to-end, so we do not use this fine-grained measurement.

If you want more fine-grained measurements, you can implement other stats.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I am confused. This is not much more finegrained than before. The code before just include time from idle time because calls to the print stats function. This just calls the time a bit more frequently? At least from the screenshot I have added here, the before and after measurement are pretty much the same.

@Ying1123 Ying1123 Aug 8, 2024 •

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.

the old code also includes prefilling time and any possible overhead in the entire loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I guess I misunderstood the goals here. I think the old code included idle time between request and report low throughput for the first decode call. But I guess it is intended.

I prefer just close this PR since there isn't much left in the PR after this is undone. It is totally OK for me.

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.

@min-xu-et Thanks for your understanding.

@min-xu-et min-xu-et closed this Aug 8, 2024
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
…ny traffic

Root (R3a, measured boot 1 vs boot 2 of window-flip-0828):
_pp_wait_for_dict_readiness decided progress from the SHARED CHAN_DICT
posted/consumed counters. CHAN_DICT is one wire demultiplexed by
__msg_type__ (admission_decision / proxy / output). Boot 1's livelock
froze ALL traffic, the counters froze, the gate fired twice -- loud
death. Boot 2's sgl-project#971 fix (correctly) kept the upstream busy posting
admission_decision messages, so consumed < posted held at every poll,
the gate early-returned every time, and PP2 sailed into the unbounded
output receive -- silent wedge, zero firings. A compensator whose
trigger condition was supplied by a foreign defect, disarmed by the
foreign fix.

Fix: per-KIND accounting riding the EXISTING chan axis as a sub-channel
(dict|<kind>, KIND_SEP) -- same single writer, same atomic replace, same
sweep; no second mechanism. The drains keep the shared wire counter as
sole authority (counting kinds separately there would leave unmatched
messages behind -- the module docstring reconciles the two questions).
Only the readiness gate reads the kind axis, and only after
kind_axis_covers proves the sender labels everything it posts;
unlabelled traffic degrades the gate to byte-identical pre-sgl-project#974
behaviour. Helpers module-level, not methods: the method form broke the
one-name-at-a-time stand-in holders (797: 31 -> 24, measured), now
pinned by its own test arm.

Tests: test_pp_readiness_per_kind_974.py, 11 arms in-process with two
real PhaseFlipCounters (no gloo pair -- Corpse-F structurally
unreachable): boot 2's disarm shape red-first (8 failed / 2 passed
pre-fix, the 2 being the directions that must not move), healthy-kind
progress unchanged, no-upstream still raises, kind-axis mutant re-arms
the disarm, sweep covers sub-channel files. 13 baselined modules
byte-identical + 14 counter-importers green, count probes OK.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
 void-relay launched-verdict) into merge/flip-window-0828

Root fix for boot 2's ring wedge: pp_void_relay_launched_verdict stops a
retraction-less zero-offer void from travelling to a never-launched rank
(unmatched -> stash -> positional mis-consume by the next healthy
generation -> one rank's live batch emptied -> ring one message short).
Legacy byte-identical when the launched chain is absent. Terrain overlap
with sgl-project#973/sgl-project#974 in scheduler_pp_mixin.py reviewed at merge.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
…ed chain

The merge gate on b3a2a59 surfaced the same interface drift sgl-project#978's own
branch repaired once in test_pp_retracted_pass_void_797.py, in two more
modules its neighbour set did not include: the event loop now passes
launched_chain= to _pp_send_admission_decision (798's recorder stub:
TypeError unexpected keyword) and calls _pp_note_launched_chain (631's
_Rank: AttributeError -- it takes shipping methods unbound one name at a
time). Repairs follow the in-file conventions: 798's recorder accepts and
ignores the kwarg exactly as it ignores expects_output (the 797 repair
verbatim); 631's _Rank takes the SHIPPING _pp_note_launched_chain unbound
like its twelve neighbours -- its own docstring guarantees stand-in
tolerance (sgl-project#787). No assertion touched. Solo re-runs: 631 6 passed,
798 7 passed; merge-tip failure set now byte-identical to baseline
(the two known test_collective_family_siblings_610 assertions).

Named for the sgl-project#978 desk strand, not fixed here: _pp_note_launched_chain
as a self.-method repeats the one-name-at-a-time holder-binding class
that sgl-project#973 and sgl-project#974 each just converted to module-level functions after
measured breakage; third module falls to it here.
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