Skip to content

hyperloom custom: a long-context decode leg, so the tuner can score engine#679 - #761

Merged
bong-water-water-bong merged 6 commits into
mainfrom
1bit/hyperloom-longctx
Nov 1, 2026
Merged

bong-water-water-bong merged 6 commits into
mainfrom
1bit/hyperloom-longctx

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Why

engine#679 is a long-context decode finding: on Qwen3.8-Flash-Next UD-IQ3_XXS, HRX decodes 9.70 tok/s at an 18,782-token prompt against 31.15 for a gfx1151 fork — while short-prompt decode is at parity (28.6 vs 28.9). The Hyperloom custom workload (--framework custom) can search configuration space, but until now it only measured short prompts (pp512/tg128 + three short chats), so it had no way to optimise the number #679 is about.

What

  • tools/hyperloom/custom/benchmark.py
    • HL_LONGCTX=<tokens> adds one long request to the serve leg: a fixed filler prompt repeated to roughly that many tokens (deterministic, so every candidate sees the same prompt), HL_LONGTOK decoded tokens (default 128).
    • With the leg on, the score becomes that decode rate (score_of()), because that is what hrx: long-context decode 9.70 tok/s at 18.8k ctx (prefill 74-93) vs 31.15 / 459 on a gfx1151 fork — same GGUF, same hour, short-prompt parity 28.6 vs 28.9 #679 compares. The short legs are still measured and still reported; bench_summary.longctx carries the requested context, the server's own prompt token count, the decode count and the prefill rate.
    • The long reply is deliberately not in the greedy-text gate: it is a property of the context, not of the lever under test, and a legitimately faster path must not fail on it. The KLD and short-text halves of the gate are unchanged.
    • HL_LONGCTX/HL_LONGTOK are echoed into the report with the other levers, and the measurement budget widens to 1200 s when the leg is on (a full 18.8k prefill is ~50 s on this box).
  • tests/hyperloom_benchmark_test.py: the three pieces that can be checked without a GPU — the filler is long enough and byte-identical between calls, the score switches to the long rate only when the leg ran, an unmeasured long leg scores 0 instead of silently falling back to the short geomean, and the no-leg metric is unchanged.

Verification

  • python3 tests/hyperloom_benchmark_test.py → hyperloom_benchmark_test: OK
  • python3 -c "import ast; ast.parse(open('tools/hyperloom/custom/benchmark.py').read())" → clean
  • End-to-end: a hyperloom optimize --framework custom run on this box with HL_LONGCTX=18800 HL_CTX=20480 — numbers go into the run report on the issue, not this PR.

Nothing else changes: the grid (levers.json), the gate tolerant threshold and the short-prompt contract are untouched, so results stay comparable with the 2026-10-30/31 runs.

…ngine#679

#679 is a decode rate at 18.8k context (9.70 tok/s vs 31.15 for a gfx1151 fork). The
custom workload only measured short prompts, so nothing here could optimise that number.
HL_LONGCTX=<tokens> adds one long request to the serve leg and makes the score its decode
rate; the short legs and the gate are untouched, and the long reply is reported but kept out
of the greedy-text gate (it depends on the context, not on the lever). The prompt is a fixed
filler repeated to length, so every candidate sees the same one and the server's own prompt
count is reported as what it actually saw.
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 994e233)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

679 - Partially compliant

Compliant requirements:

  • Added long-context leg that measures decode rate at 18.8k context
  • Made the long prompt deterministic and byte-identical
  • Implemented score switching to long-context rate only when leg runs
  • Ensured unmeasured long leg scores zero
  • Updated benchmark.py and test to support new functionality

Non-compliant requirements:

  • Documentation updates (docs/, README, wiki) not included in this diff

Requires further human verification:

  • Verification that the new functionality correctly reproduces the performance issue described in the ticket
  • Confirmation that the new long-context measurement accurately reflects the 9.70 tok/s vs 31.15 tok/s difference
  • Validation that the deterministic prompt generation works correctly across different runs
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Long Context Prompt Determinism

The long context prompt generation relies on a fixed ratio (4.85 chars per token) to estimate the required prompt length. This approach may not be accurate for all models or tokenization schemes, potentially leading to prompts that are either too short or too long compared to the requested token count. The accuracy of this estimation should be verified with the actual tokenization behavior of the target model.

def long_prompt(n_tokens):
    """A deterministic filler prompt of roughly ``n_tokens`` tokens at this filler's own ratio."""
    return LONG_PROMPT_UNIT * max(1, int(n_tokens * LONG_CHARS_PER_TOKEN / len(LONG_PROMPT_UNIT)) + 1)
Timeout Handling for Long Context

The timeout handling for long context measurements uses a fixed 1200s budget when longctx is enabled, but this may not be sufficient for all long context scenarios. The timeout logic should be reviewed to ensure it's appropriate for the expected duration of long context prefill operations.

deadline = time.time() + env_int("HL_BUDGET_SEC", 780 if not longctx else 1200)

@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 9e00baf7 — first review, build green. tools/hyperloom/custom/benchmark.py + tests/hyperloom_benchmark_test.py.

Ran the test:

$ python3 tests/hyperloom_benchmark_test.py
hyperloom_benchmark_test: OK        (exit 0)

The design choice that matters is the prompt. The long-context leg (HL_LONGCTX) builds its prompt from a fixed filler sentence repeated to length, so every candidate is measured against the identical prompt — and the real token count comes back from the server and is reported rather than assumed. That is the difference between a comparable long-ctx number and one that drifts with tokenizer behaviour, and it is the right way to answer what #679 is actually about (decode rate at long context, where the KV cache is the cost).

It also fixes the shape of the measurement rather than bolting on a fourth prompt: serve_measure now returns (tps, text, timings) so the long-ctx leg can report the server's own figures, and the score becomes the long-ctx decode rate instead of the short-prompt geometric mean when HL_LONGCTX is set. Both HL_LONGCTX and HL_LONGTOK are added to levers(), so a run that changes them records it.

Not verified: the long-ctx numbers themselves — that needs a build, a model and the GPU, and the point of the PR is the harness rather than a result.

tprs-ready applied.

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 00f0203

bong-water-water-bong added 2 commits November 1, 2026 11:00
…actually does

Measured on the box: the filler tokenises at ~4.85 characters per token, so the 4-char/token
estimate produced a 15,492-token prompt when 18,800 was asked for. Scale by the measured ratio
and label the throughput unit with the token count the server reported, not the one the caller
requested, so the #679 row cannot quote the wrong context.
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit e1a3e71

@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 e1a3e714 — re-confirmed after the waiter moved the head: build green, and I re-ran the gate at this content rather than assuming the rebase was inert.

python3 tests/hyperloom_benchmark_test.py → OK. The long-ctx leg still builds its prompt from a fixed filler sentence so every candidate sees the identical prompt, and reads the real token count back from the server; HL_LONGCTX/HL_LONGTOK remain in levers().

tprs-ready stands.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 994e233

@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 994e233a — build green, and I re-ran python3 tests/hyperloom_benchmark_test.py at this content: OK.

The long-ctx leg builds its prompt from a fixed filler sentence so every candidate is measured against the identical prompt, and reads the real token count back from the server rather than assuming it — which is what makes the number comparable across candidates. HL_LONGCTX/HL_LONGTOK stay in levers(), so a run that changes them records it.

tprs-ready stands.

@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 e6006d30 — build green, and I re-ran the gate at this content rather than assuming the rebase was inert.

python3 tests/hyperloom_benchmark_test.py → OK. The long-ctx leg still builds its prompt from a fixed filler sentence (every candidate measured against the identical prompt) and reads the real token count back from the server; HL_LONGCTX/HL_LONGTOK remain in levers().

tprs-ready stands.

@bong-water-water-bong
bong-water-water-bong merged commit 5f8045e into main Nov 1, 2026
7 of 8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hyperloom-longctx branch November 1, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant