Skip to content

update(perf): bound DRY and sparse penalty step costs - #2272

Merged
inureyes merged 4 commits into
mainfrom
update/issue-2259-bound-dry-cost
Oct 11, 2026
Merged

inureyes merged 4 commits into
mainfrom
update/issue-2259-bound-dry-cost

Conversation

@inureyes

Copy link
Copy Markdown
Member

A full-history DRY step previously rescanned repeated suffixes quadratically, and checking every position against request-supplied breaker lists could multiply window length by breaker configuration size. This change computes suffix matches with reverse Z and breaker starts with a reversed-token Aho-Corasick matcher, bounding expected host work to O(N + P) for history length N and configured breaker-pattern tokens P.

DRY and rebuilt frequency/presence penalties now scatter only touched token IDs instead of constructing vocabulary-sized host buffers. The sparse paths preserve the pinned MLX backend semantics: CUDA bf16 mixed arithmetic remains bf16 on rebuild paths, while the pre-existing incremental frequency/presence path still explicitly promotes to f32.

Quiet GB10 host matching and lazy MLX graph-construction timing used vocabulary 4, a period-3 history, and no breakers. Reference iterations were 3/3/1 and new-path iterations were 20/20/20. Returned arrays were not evaluated, so these figures are not GPU end-to-end latency:

Window Reference µs/step New µs/step Speedup
1,024 619.751 23.607 26.25×
4,096 4889.370 29.997 163.00×
16,384 77199.293 111.433 692.79×

Validation on CUDA GB10:

  • Core build and clippy passed; cargo fmt --check passed.
  • Sampling suite: 210 passed, 1 ignored timing test.
  • Engine suite: 63 passed.
  • 512 deterministic DRY parity cases, direct breaker-position parity, f32/f16/bf16 penalty parity, and adversarial linear-work bounds passed.
  • Independent implementation and security reviews reported no findings.

Timing evidence: docs/benchmark_results/dry-penalty-step-cost-gb10-2026-10-11.md and its linked raw package.

Closes #2259

Refs #2229, #2256

Replace quadratic backward matching with a linear reverse-Z pass and scatter DRY and rebuild frequency/presence updates only across touched token IDs. Preserve backend-specific dense dtype behavior and the existing incremental f32 path.

Add dense-reference parity matrices, breaker-boundary and linear comparison-count checks, bf16 incremental regression coverage, and an ignored timing report. Build and tests have not run yet because the orchestrated CUDA profiling window is still active.

Refs #2259
Build a reversed-token matcher once per DRY step so exact IDs and multi-token breakers cost expected O(P + N) instead of multiplying breaker configuration size by the history window.

Preserve scalar breaker semantics in direct per-position parity tests and cover large exact sets plus shared-tail failure chains with separate build and scan counters.

Validation: cargo fmt --all. Build and tests are pending the root validation gate.

Refs #2259
Publish the quiet GB10 host matching and lazy graph-construction timings for issue #2259 with byte-preserved logs, validation output, checksums, and source, artifact, driver, and host-gate provenance. The record distinguishes these measurements from GPU end-to-end latency.

Validation: sha256sum --check SHA256SUMS and git diff --cached --check.

Refs #2259
@inureyes inureyes added status:review Under review type:performance Performance improvements priority:low Low priority area:inference Generation, sampling, decoding (incl. speculative, DRY) labels Oct 11, 2026
Add bilingual technical reports and preserve the original two-commit implementation patch used for GB10 timing. Record the measured and rebased source identities, prove the scoped core, native, and lockfile diff is empty, and document replay from the public measurement base.

Validation:
- `sha256sum --check SHA256SUMS`
- Replayed the archived patch from `73700aaf` and matched tree `58b9a04161eaf88048699d0930a69dd59ccdd7b3`
- `git diff --cached --check`

Refs #2259, #2272
@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 11, 2026
@inureyes
inureyes merged commit e24fb7b into main Oct 11, 2026
27 checks passed
@inureyes
inureyes deleted the update/issue-2259-bound-dry-cost branch October 11, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: bound DRY and penalty per-step cost on long histories

1 participant