Skip to content

perf(llama32-1b): default to compiled-in ngram-cache lookup decoding - #226

Open
noor-malaika wants to merge 5 commits into
aifoundry-org:mainfrom
noor-malaika:perf/llama32-1b-lookup-decode
Open

perf(llama32-1b): default to compiled-in ngram-cache lookup decoding#226
noor-malaika wants to merge 5 commits into
aifoundry-org:mainfrom
noor-malaika:perf/llama32-1b-lookup-decode

Conversation

@noor-malaika

@noor-malaika noor-malaika commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Repins llama.cpp-et on top of the existing fusion/launch-geometry stack to add a compiled-in runtime default that turns on n-gram lookup decoding for every llama-server caller on this runtime, rather than a per-benchmark CLI override.
  • Strategy: amortize this backend's fixed per-launch host-enqueue cost by verifying several drafted tokens per kernel launch instead of one. Benefit scales with how self-repetitive the generated continuation is; near-zero on high-entropy generation.
  • This is a decoding-strategy change, not just a scheduling/fusion change, so it's kept as its own PR separate from the pure kernel-fusion work, to be reviewed and merged independently.
  • submissions/llama32_1b.track.json updated to the exact shipped llama.cpp-et revision.

Test plan

  • ET WikiText-2 PPL matches the expected value (unaffected — llama-perplexity never reads the speculative-decode default).
  • Trusted Llama 3.2 1B decode gate passes on this revision.
  • Shared-runtime regression sweep across other leaderboard text models: passed.

🤖 Generated with Claude Code

Repins llama.cpp-et to noor-malaika/llama.cpp@5c2b11aae (branch
perf/launch-geometry).

Targets per-launch overhead rather than the mul_mat inner loop. Fitting
decode latency across the nine transformer models on the board
leaderboard to T_token = c*n_layers + d*weight_GB gives 2.80 ms/layer
and 22.7 ms/GB, reproducing all nine within 5.5%. For llama32_1b that
splits the 73.9 ms token into ~44.7 ms of fixed per-layer cost (~307
kernel launches at ~146 us) and ~30 ms of weight streaming. The earlier
C1 and E experiments both fought over the 30 ms half; this goes after
the 44.7 ms half, which nothing landed so far has touched.

See the submodule commit for the three changes and for
GGML_ET_LAUNCH_GEOMETRY=0, which restores the previous behaviour so a
single build can measure both settings.

Not yet run on hardware.
Repins llama.cpp-et to noor-malaika/llama.cpp@a835b8003 (branch
perf/launch-fusion), which stacks op fusion on top of the launch-geometry
commit.

Takes a decode layer from ~19 kernel launches to ~15 by folding both
residual adds into the projections that feed them and collapsing
ffn_gate + ffn_up + GLU into a single kernel. Unlike the launch-geometry
change, this does not depend on per-launch cost scaling with shire count
-- fewer launches is fewer launches either way.

Sweepable from one build via GGML_ET_LAUNCH_GEOMETRY, GGML_ET_FUSE_MM_ADD
and GGML_ET_FUSE_FFN (each =0 to disable), so all eight combinations can
be measured in one board session without rebuilding.

Not yet run on hardware.
…gative)

Repins llama.cpp-et to perf/launch-probes. Both knobs default off, so decode
behaviour is unchanged from the launch-fusion result (14.93 tok/s reproduced
on the probes build).

Board 2026-07-25, measured against 14.93 baseline:
  GGML_ET_MAX_SHIRES=16/8/4 -> 12.52 / 8.94 / 5.61 tok/s, and all three FAIL
    validation (no perplexity). Capping shires loses more to lost parallelism
    than it recovers from a cheaper barrier, and some kernel on the prefill
    path depends on the full 32-shire mask for correctness.
  GGML_ET_PREFETCH_ROWS=1/2 -> 13.57 / 13.53 tok/s. Row-ahead L2 prefetch is a
    ~9% regression; the dependent-load stall it targets is not what decode is
    waiting on.

Kept rather than reverted: they are the measurement that rules out barrier
count and per-hart memory latency as the missing ~45 ms of the token.
Repins llama.cpp-et to cafc4cd3a and claims the track.

Sibling of perf/llama32-1b-attention-fusion, both cut from the launch-probes
lineage rather than stacked, so each is measurable on its own (an unmeasured
change stacked under another can mask or cancel it).

Adds, both env-gated and default-safe:
- GGML_ET_FUSE_SET_ROWS (default on): the K-cache and V-cache SET_ROWS of a
  decode layer are independent, so they run in one launch instead of two.
- GGML_ET_PREFETCH_DEST (default 1 = L2, i.e. unchanged): the prefetch CSR
  destination was hardcoded to L2, and both measured prefetch regressions
  (ours -9%, DarthCeltic's -3.3% in aifoundry-org#170) were to L2. Each hart owns whole
  rows, so nothing shared justifies stopping short of L1.

Neither is measured on hardware yet.
Repins llama.cpp-et to a build with n-gram lookup decoding on by
default for every llama-server caller, not a per-benchmark override.

Strategy: amortize this backend's fixed per-launch overhead by
verifying several drafted tokens per kernel launch instead of one.
Helps most on repetitive completions, least on high-entropy output.

Still needs the shared-runtime regression sweep before it can claim
the track.
@noor-malaika
noor-malaika requested a review from AFOliveira as a code owner July 26, 2026 11:06
@github-actions github-actions Bot added track: week-2-challenge Week 2 focused hardware challenge track: llama-3.2-1b-performance Global Llama 3.2 1B performance prize labels Jul 26, 2026
@noor-malaika

Copy link
Copy Markdown
Contributor Author

Retriggering CI (unrelated sim-emulator link failure in shared infra).

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

Labels

track: llama-3.2-1b-performance Global Llama 3.2 1B performance prize track: week-2-challenge Week 2 focused hardware challenge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant