Skip to content

fix(bench): plain_baseline -n 1 no longer divides by zero - #104

Open
fengqiaoqu wants to merge 1 commit into
lithos-ai:mainfrom
fengqiaoqu:fix/63-plain-baseline-n1
Open

fengqiaoqu wants to merge 1 commit into
lithos-ai:mainfrom
fengqiaoqu:fix/63-plain-baseline-n1

Conversation

@fengqiaoqu

Copy link
Copy Markdown

Problem

tools/bench/plain_baseline.py -n 1 raises ZeroDivisionError on the first measured prompt.

With max_new_tokens = 1, Session.generate() returns the prefill-sampled token and skips the decode phase (if max_new_tokens > 1 ...), so decode_wall_ms stays 0.0 and decode_tokens is 0. The script then does:

tps = gen.decode_tokens / (gen.decode_wall_ms / 1e3)

Fix

Add decode_tps() that returns 0.0 when there was no decode phase, and use it for the ours path. Contract test covers the -n 1 zeros and a normal rate.

Verify

pytest tests/contract/test_plain_baseline_decode_tps.py -q
# .....

Full plain_baseline.py still needs a Mac + pack (same as before); this change only stops the crash when -n 1 leaves decode empty.

Fixes #63

With max_new_tokens=1, Session.generate skips the decode phase, so
decode_tokens and decode_wall_ms stay 0. Computing tok/s then raised
ZeroDivisionError. decode_tps returns 0.0 for that prefill-only case.

Fixes lithos-ai#63
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.

Bench: plain_baseline.py divides by zero with -n 1

1 participant