Skip to content

bench: the long-context score names and pins its own denominator (#1337) - #1338

Merged
bong-water-water-bong merged 3 commits into
mainfrom
1bit/hyperloom-unit-decode-tokens
Nov 7, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
1bit/hyperloom-unit-decode-tokens

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1337.

The long-context score is a decode rate, so the number it divides by is part of the measurement. Two things were wrong, and this PR fixes both in one place.

Root cause

  1. The unit named one dimension of two. throughput_unit was tok/s (decode at <ctx>-token ctx) — the context, not the decoded-token count. That count is the score's denominator, so two rows whose denominators differed by more than 2× carried byte-identical units. A scoreboard carries the unit and not bench_summary.longctx, so the two landed as the same measurement.
  2. max_tokens was only a ceiling. The long leg asked for 512 tokens; the model stopped at EOS after 278 (slot release: task 528 | stop processing: n_tokens = 19039, truncated = 0). So the denominator varied between runs of the same configuration, and nothing in the result distinguished that from a complete decode.

Measured on this box, 2026-11-07

Two arms, same model, ctx, levers and default draft cap, both drafting.serve.status: drafted, both gate PASS:

arm HL_LONGTOK decoded score unit recorded
arm_74_longctx_default_post1238.json 128 128 13.0592 tok/s (decode at 18762-token ctx)
arm_74_longctx_default_tok512.json 512 278 14.1784 tok/s (decode at 18762-token ctx)

Identical unit strings, denominators 2.17× apart. This lane nearly compared 14.18 against 13.40 as though the decode length were constant.

Fix

  • The score's denominator is pinned: the long leg sends ignore_eos, so the decode runs the requested HL_LONGTOK. Set for that leg only — the short legs' replies are the greedy-text gate's inputs, compared against a stored reference, so changing how long they may run would change the gate's own evidence. The long reply was already outside that gate (it depends on the context, not the lever), which is what makes pinning its length safe.
  • And it is still reported, because the flag is a request, not a guarantee: longctx gains decode_tokens_requested, decode_tokens (what actually came back) and decode_complete.
  • The unit says which case it is in: tok/s (decode at 18762-token ctx, 512 decoded) when complete, tok/s (decode at 18762-token ctx, 278 of 512 requested) when the decode stopped short.
  • One decode_unit() definition serves both the pre-measurement placeholder and the measured result, so they cannot drift apart the way the README and the gate did in hyperloom custom: document HL_CTX and the long-context leg in the README #769.

Verification

  • python3 tests/hyperloom_benchmark_test.py → hyperloom_benchmark_test: OK, rc=0.
  • Fails on the unfixed file — TypeError: decode_unit() takes from 1 to 2 positional arguments but 3 were given (line 66) — checked by stashing benchmark.py.
  • Tests assert: the two dimensions separately, the stopped-short form, the unknown-count fallback (no fabricated 0 decoded), that the short legs never carry ignore_eos, and that decode_complete treats a missing count as False, not True.
  • python3 tools/copyright.py --check → rc=0.
  • Backend honouring of ignore_eos on /v1/chat/completions is verified on the box by an arm with HL_LONGTOK=512 run from this branch (result recorded in the PR thread once it lands) — /v1/completions support is already documented in this repo (tools/e2e_bench.py, "ignore_eos (exactly N tokens)"), but the chat endpoint was not verifiable from source here, which is exactly why the completeness flag exists rather than being assumed.

Not in scope

The rate itself is not re-normalised: a decode rate is a decode rate. The fix is that its denominator is now pinned where the backend allows it, and always named where it is not.

…se that is the score's denominator

`throughput_unit` for a long-context result was `tok/s (decode at <ctx>-token ctx)` -- it named the
context the server prefilled and not the number of tokens the decode actually produced, which is the
score's own denominator and which is not the number the caller asked for (the model can stop at EOS
first).

Measured on this box 2026-11-07, two arms with the same model, ctx, levers and default draft cap:

  HL_LONGTOK=128 -> 128 decoded, 13.0592 tok/s, "tok/s (decode at 18762-token ctx)"
  HL_LONGTOK=512 -> 278 decoded, 14.1784 tok/s, "tok/s (decode at 18762-token ctx)"

HL_LONGTOK=512 produced 278 because the server stopped at EOS (`stop processing: n_tokens = 19039`,
`truncated = 0`), not because the harness cut it. So the artifact's `longctx.decode_tokens` and
`levers.HL_LONGTOK` both told the truth; the two rows carry a byte-identical UNIT while their
denominators differ by more than 2x, and the unit is the part that travels with the number. This lane
nearly compared 14.18 against 13.40 as if the decode length were constant.

Both places that build the unit now go through one `decode_unit()` (the pre-measurement placeholder that
uses the requested context, and the measured one that uses the context and count the server reported), so
they cannot drift apart the way the README and the gate did in #769.

After: `tok/s (decode at 18762-token ctx, 278 decoded)`.

The test asserts the two dimensions separately, that an unknown decode count falls back instead of
fabricating "0 decoded", and -- the regression -- that rows differing only in the decoded count do not
serialise to the same unit. It fails on the unfixed file (`AttributeError: decode_unit`) and passes here.

Device-free: no GPU claim, no measurement, no lever touched.

Closes #1337
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1338 ready for review at 5b6da27 — one helper, one test, one README clause. Reproducer is two real artifacts from this box (13.0592 over 128 decoded tokens and 14.1784 over 278, identical unit strings); the test fails on the unfixed file and passes here. Device-free, closes #1337.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at 5b6da279d46bfd9ee7ee3942b45584cf62725397. The unit now carries the score's denominator, from one definition used by both writers.

  • python3 tests/hyperloom_benchmark_test.py → hyperloom_benchmark_test: OK. copyright.py --check rc 0. 3 files, +38/−4.
  • decode_unit() (benchmark.py:242) is the only constructor. The placeholder (:844, requested ctx) and the measured result (:903, ctx_tokens_actual plus long_info.get("decode_tokens")) both call it.
  • Probed directly: decode_unit(18762, None) → tok/s (decode at 18762-token ctx) (no fabricated count); 278 and '278' → …, 278 decoded). So the body's two arms (128 and 278 decoded) can no longer serialise to the same unit, which is the regression the new test pins.

Nits: if decoded is truthiness, so a reported 0 decoded falls back to the count-less unit. That is harmless, because a 0-token decode has no rate, but is not None would say what is meant. And the comment at :900 cites engine#1268, while this PR closes #1337.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at 5b6da279d46bfd9ee7ee3942b45584cf62725397

The unit now names both dimensions that set the score, and I checked the function directly as well as through the suite:

decode_unit(18762)        -> 'tok/s (decode at 18762-token ctx)'
decode_unit(18762, 278)   -> 'tok/s (decode at 18762-token ctx, 278 decoded)'
decode_unit(18762, 0)     -> 'tok/s (decode at 18762-token ctx)'      # 0/None is "unknown", not "0 decoded"

python3 tests/hyperloom_benchmark_test.py → hyperloom_benchmark_test: OK, and the arms it grew are the right ones: the two spellings, the regression itself (decode_unit(18762, 128) != decode_unit(18762, 278), i.e. two rows whose denominators differ by >2x can no longer serialise to the same unit), and the unknown count not fabricating a 0 decoded.

The reason is stated with its measurement (13.3986 tok/s over 128 decoded vs 14.1784 over 278, identical unit strings before this), which is what makes the change reviewable rather than cosmetic: HL_LONGTOK is what the caller asks for, EOS decides what was actually decoded, and only the latter is the rate's denominator. Using the same helper for the pre-measurement placeholder and the measured result is the part that stops the two drifting apart later — the failure mode this project has hit before when a doc and a gate spelled the same thing twice.

One line of prose moved with it (tools/hyperloom/custom/README.md), so the flag table and the code agree. Nothing else in the diff; no device path, no gate logic.

… it did not get it

The score is a decode rate, so the number it divides by is part of the measurement. Two things were wrong:

1. `throughput_unit` named the context and not the decoded-token count, so two rows whose denominators
   differed by more than 2x carried byte-identical units (13.0592 over 128 tokens and 14.1784 over 278,
   measured here 2026-11-07). A scoreboard carries the unit and not `bench_summary.longctx`, so those two
   landed as the same measurement.
2. `max_tokens` was only a ceiling. The long leg asked for 512 tokens and the model stopped at EOS after
   278 (serve: `stop processing: n_tokens = 19039, truncated = 0`), so the denominator varied between runs
   of the *same* configuration -- and nothing in the result distinguished that from a complete decode.

Fix. The long leg now sends `ignore_eos`, so the decode runs the requested length and the denominator is
the one we asked for. `ignore_eos` is set for that leg only: the short legs' replies are the greedy-text
gate's inputs and are compared against a stored reference, so changing how long they may run would change
the gate's own evidence. The long reply was already outside that gate (it depends on the context, not on
the lever), which is what makes pinning its length safe.

Because the flag is a request to the backend and not a guarantee from it, the result records both sides:
`longctx.decode_tokens_requested`, `longctx.decode_tokens` (what actually came back) and
`longctx.decode_complete`. `decode_unit()` names the count the score was divided by and says which case it
is in:

  tok/s (decode at 18762-token ctx, 512 decoded)              -- complete
  tok/s (decode at 18762-token ctx, 278 of 512 requested)     -- stopped short

Tests assert the two dimensions separately, the stopped-short form, the unknown-count fallback (no
fabricated "0 decoded"), that the short legs never carry `ignore_eos`, and that completeness treats a
missing count as False rather than True. They fail on the unfixed file (`decode_unit() takes from 1 to 2
positional arguments but 3 were given`) and pass here.

Device-free in itself; the backend's honouring of `ignore_eos` is verified by an arm on the box.

Refs #1337
@bong-water-water-bong bong-water-water-bong changed the title bench: the long-context unit names the decoded-token count too, because that is the score's denominator (#1337) bench: the long-context score names and pins its own denominator (#1337) Nov 7, 2026
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1338 ready for review at 42278c9 (2 commits, same PR) — the unit now names the denominator and the score pins it with ignore_eos on the long leg only, recording decode_tokens_requested/decode_tokens/decode_complete so an incomplete decode is visible even if the backend ignores the flag. Fixes #1337. Tests fail on the unfixed file (TypeError: decode_unit() takes from 1 to 2 positional arguments but 3 were given) and pass here; a device arm with HL_LONGTOK=512 is queued to prove the chat endpoint actually honours ignore_eos — result posted here when it lands.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at 42278c91e6ec.

Re-verdicted at the new head (the READY it carried was at 5b6da279; this head adds +91/−23 of real content, not a merge), and
the three properties that make the fix safe all check out:

tests/hyperloom_benchmark_test.py     hyperloom_benchmark_test: OK                                    rc 0
ignore_eos call sites
  684  ask(port, "hi", 4, timeout)                        warm-up                            no ignore_eos
  688  ask(port, prompt, tokens, timeout)                 the short legs                     no ignore_eos
  699  ask(port, long_prompt(longctx), longtok, timeout, ignore_eos=True)   the long leg        pinned
decode_unit(ctx, decoded, requested)
  no decoded               -> base
  decoded < requested      -> "…, 278 of 512 requested)"
  otherwise                -> "…, 512 decoded)"

So the denominator is pinned only where it is safe to pin it: the long leg's reply is the score's numerator/denominator pair and
was already outside the greedy-text gate (it depends on the context, not the lever), while the short legs keep their natural EOS and
the gate's stored reference keeps meaning what it meant. And it is still reported rather than promised — decode_tokens_requested /
decode_tokens / decode_complete say whether the flag took effect, and the unit carries the two cases apart
(512 decoded versus 278 of 512 requested), which is exactly what was missing when two rows 2.17× apart in denominator carried
byte-identical units.

One decode_unit() serving both the placeholder and the measured result is the right shape for this class — the drift between the
README and the gate in #769 was two places computing the same string.

Fixes #1337, and the root cause it names is worth keeping visible: max_tokens is a ceiling, not a length, and a scoreboard that
records the unit without bench_summary.longctx cannot tell a complete decode from a truncated one.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Device proof: the chat endpoint does honour ignore_eos — and one caveat I am not going to hide

arm_74_longctx_ignoreeos_proof.json (HL_LONGTOK=512, this branch, granted 11:41 after 1082 s queued, 500 s on the die, gate PASS, kld_mean 0.0, texts identical):

longctx = {"ctx_tokens_requested": 18800, "ctx_tokens_actual": 18762,
           "decode_tokens_requested": 512, "decode_tokens": 512,
           "decode_complete": true, "prefill_tok_s": 186.49}
throughput_unit = "tok/s (decode at 18762-token ctx, 512 decoded)"

So /v1/chat/completions accepts the flag and the denominator is exactly the requested 512 — the previous behaviour was the 278–282 EOS stop (decode_complete would now be false and the unit would read 278 of 512 requested). The ignore_eos-on-the-long-leg-only decision is also confirmed in practice: the gate still passes with texts identical, i.e. the short legs' gated replies are untouched.

The caveat: that arm scored 6.358 tok/s, and I am not claiming that as a measurement of anything. Both of its halves were slow, uniformly, from the first timing line:

prefill tg at n_decoded≈102 final score
default_tok512 (natural stop, no flag) 294.55 (3.39 ms/tok) 23.06 t/s 14.1784
ignoreeos_proof (flag) 186.49 (5.36 ms/tok) 11.90 t/s 6.3580

ignore_eos cannot affect prefill — it is a sampling flag on the decode, and the prompt and its path are identical — yet prefill was 1.58× slower too, with draft acceptance unchanged (0.665 / mean len 2.99, i.e. the same as the 128-token rows). The parsimonious reading is that the window was slow (box contention: die 66.4–67.9 C, 51.6 GiB of GTT held by other lanes), and the decode was slowed by the same factor.

One sample cannot prove the flag is speed-neutral, though, so I am not asserting it. There is a clean way to settle it, and it is running now: HL_LONGTOK=128 from this branch. At 128 tokens the model's natural stop (~278) is never reached, so the flag cannot change how many tokens are decoded — if that row reproduces the 13.06–13.40 of the flag-less 128-token rows, the flag is speed-neutral and only the denominator changed; if it reads ~6, then ignore_eos itself slows this pin's decode and this PR must say so loudly, because every post-merge row would then be measured differently from the historical ladder.

Either result gets posted here. The plumbing claim (flag honoured, decode_complete correct, unit correct) stands regardless.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1337 - Partially compliant

Compliant requirements:

  • The long-context score's unit now names both the context and the decoded-token count
  • The unit distinguishes between runs with different decoded-token counts
  • The decode rate's denominator is accurately represented in the unit string
  • The long leg sends ignore_eos to pin the decode length
  • The artifact records both requested and actual decode token counts
  • The unit string indicates when a decode stopped short of the requested amount

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Unit String Clarity

The new decode_unit function improves clarity by including both context and decoded token count in the unit string. However, the implementation could be more robust in handling edge cases where decoded or requested might be None or non-numeric, potentially leading to unexpected behavior or errors during unit string generation.

def decode_unit(ctx_actual, decoded=None, requested=None):
    """The score's unit, naming **both** dimensions that change the number.

    A long-context result's score is a decode rate, so two things set its value: the context the server
    actually prefilled, and **the number of tokens the decode actually produced** -- that count is the
    score's own denominator, and it is not the number the caller asked for, because the model can stop at
    EOS first unless the request sets ``ignore_eos``. Measured on this box 2026-11-07: the same lever and the
    same configuration gave 13.3986 tok/s over 128 decoded tokens and 14.1784 over 278 (`HL_LONGTOK=512`
    requested, 278 produced), and both rows carried the **identical** unit string
    `tok/s (decode at 18762-token ctx)`. A reader -- or a scoreboard -- comparing those two numbers had
    nothing in the unit to say their denominators differed by more than 2x.

    When the decode stopped short the unit says the request it stopped short of (`278 of 512 requested`),
    so an incomplete row is visible in the one field that travels with the number.

    One definition, used both for the pre-measurement placeholder and for the measured result, so the two
    cannot drift apart the way the README and the gate did in engine#769.
    """
    base = f"tok/s (decode at {ctx_actual}-token ctx"
    if not decoded:
        return f"{base})"
    if requested and int(decoded) < int(requested):
        return f"{base}, {decoded} of {requested} requested)"
    return f"{base}, {decoded} decoded)"
Request Body Handling

The request_body function correctly adds the ignore_eos parameter only for the long-context leg, which is essential for ensuring consistent decode lengths. However, the function's documentation and implementation should be more explicit about when ignore_eos is used and why it's critical for the long leg's behavior.

def request_body(prompt, max_tokens, ignore_eos=False):
    """The chat request this workload sends.

    ``ignore_eos`` pins the decode length: without it ``max_tokens`` is only a ceiling, because the model can
    stop at EOS first, so the numbers a rate is divided by differ between two runs of the same configuration.
    Measured on this box 2026-11-07: the same arm with ``HL_LONGTOK=512`` decoded **278** tokens (serve:
    ``stop processing: n_tokens = 19039, truncated = 0``) while a sibling requested the same 512 and produced
    282 -- and the long score is a rate, so that difference is in the score.

    Requested only for the **long-context leg**, never for the short legs: those replies feed the greedy-text
    gate, which compares them against a stored reference, so changing how many tokens they may run would change
    the gate's own inputs. The long reply is deliberately outside that gate (it depends on the context, not on
    the lever), which is what makes pinning its length safe.
    """
    body = {
        "messages": [{"role": "user", "content": prompt}],
        "temperature": 0,
        "max_tokens": max_tokens,
        "cache_prompt": False,
        "chat_template_kwargs": {"enable_thinking": False},
    }
    if ignore_eos:
        body["ignore_eos"] = True
    return body
Decode Completeness Logic

The decode_completeness function provides a boolean check for whether a decode was complete. While this is useful, the logic could be made more robust to handle cases where actual or requested might be None or invalid, which could lead to incorrect assessments of completeness.

def decode_completeness(requested, actual):
    """True when the decode produced at least the requested number of tokens.

    The score is a rate, so its denominator is part of the measurement: a row that requested 512 tokens and
    produced 278 is not the same measurement as one that produced 512, and `throughput_unit` names the count so
    the two cannot read alike. This is the same fact as a boolean, for callers that want to filter rather than
    parse the unit string -- and a missing count is **not** complete, because "nobody knows" must never read as
    "it finished".
    """
    return bool(actual) and bool(requested) and int(actual) >= int(requested)

@bong-water-water-bong
bong-water-water-bong merged commit 71a4390 into main Nov 7, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hyperloom-unit-decode-tokens branch November 7, 2026 16:34
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Device answer, both questions — and one correction to what I posted 40 minutes ago

1. Does the chat endpoint honour ignore_eos? Yes. HL_LONGTOK=512 → decode_tokens_requested: 512, decode_tokens: 512, decode_complete: true, unit tok/s (decode at 18762-token ctx, 512 decoded). Previously the same request produced 278. The long-leg-only decision is confirmed in practice: gate PASS with texts identical, so the short legs' gated replies are untouched.

2. Does pinning cost speed? No — and my earlier "6.358 tok/s" scare was the box, not the flag. I nearly concluded the opposite, so here is the whole trail.

Sequential arms could not answer it. Across three arms on 2026-11-07 with identical config, prefill and decode moved together:

arm long-leg tg prefill score draft acceptance
no flag 13.93 251.03 13.8716 0.67460 (85/126), len 3.02
flag, same window 10.99 215.15 11.3783 identical
flag, slow window 8.21 137.88 8.8630 identical

ignore_eos is a decode-sampling field — it cannot touch prefill — so a 1.2–1.8× co-movement in both means the box was the variable. Drafting work was byte-identical (85 accepted / 126 generated, mean len 3.02) in all three.

So I ran the pair that does control for it — one claim, one 1bit serve, the same 18,762-token request issued twice, differing only in the request body:

order pinned natural
pinned → natural 9.95 13.29
natural → pinned 13.39 13.32

The first pair's 25 % gap was the window, not the body: inverting the order made it vanish (+0.5 %). A single-order probe would have produced a false "25 % cost", an unnecessary opt-in, and a wrong line in the docs. Both requests decoded exactly 128 tokens in each pair, so this was never about the count — only the rate.

Net: the pin ships as the default, and this measurement is recorded in request_body's docstring (9717b697) with the instruction that matters for anyone who touches the flag: re-run the pair in both orders before believing a difference.

Branch is at 9717b697 (3 commits: unit, score, measurement record). Tests green, copyright --check rc=0, device-free apart from the three probe arms whose artifacts are named above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant