Skip to content

perf: accelerate GPT-OSS prefill and decode with measured controls - #840

Merged
Gajesh2007 merged 10 commits into
masterfrom
research/gptoss20b-profile
Sep 5, 2026
Merged

Gajesh2007 merged 10 commits into
masterfrom
research/gptoss20b-profile

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Speed up fresh GPT-OSS 20B prefill and decode with pinned, tested library changes, and make the benchmark report the actual shared decode interval at B=2/B=4. Add a reviewable implementation plan, portable measured evidence, paired ABBA controls, raw timing/output accounting, full-geometry warmups and load/runtime memory observations.

The integration enables final-position prefill output, exact constant conversion reuse, compatible expert fusion with bounded load materialization, and the measured M4 Max MXFP4 decode tail. Prefix reuse and MTP are excluded from all benchmarks. Optional candidates and rejected experiments are distinguished in the report; the recovered diagnostic tracer is not shipped.

flowchart LR
  subgraph Before
    A[Fresh GPT-OSS request] --> B[Full prompt vocabulary projections]
    B --> C[First token]
    C --> D[Split expert projections and repeated constant casts]
    D --> E[Decode output]
    F[ThroughputSweep] --> G[Whole-row aggregate mixes prefill stalls]
  end
  subgraph After
    H[Fresh GPT-OSS request] --> I[cbv2Prefill final-position output]
    I --> J[First token sooner]
    J --> K[Fused experts + constant reuse + guarded MXFP4 kernel]
    K --> L[Decode output]
    M[ThroughputSweepDecodeTiming] --> N[Raw token timestamps and common-overlap aggregate]
    N --> O[ABBA controls and portable evidence]
  end
Loading

Validation: final pinned release suite passed 70 Swift Testing cases and 8 XCTest cases, plus 25 Python tooling tests. Separate real-checkpoint tests cover 42 arms and exact generated continuations/KV receipts. Matching source metallib was rebuilt. See docs/reports/2026-09-05-gptoss20b-optimization-results.md for paired final measurements, numeric tolerances, load peak and workstation variance. Documentation lint passes. Large raw traces and executable/model banks remain local; portable summaries and hashes are committed.

All dependency commits are pushed to the Layr-Labs forks. This is a development/PR deliverable; no production deployment, release, merge, or remote-machine benchmark was performed.

The schema-7 harness submits rows deterministically. Both corrected 8K B=2/B=4 controls preserve generated sequences; long-context timing remains variable, including unfavorable cycles. Short-context screening found roughly 12–14% lower prefill latency and 6–13% more aggregate decode throughput depending on B. Historical schema-6 B>1 screenings do not satisfy the new mandatory submission-order gate; the report preserves those measurements with that limitation. The 32K B=1 smoke matched 129 baseline tokens; 8K B=8 completed 513 tokens per row at 15.70 GiB peak MLX memory.

Dependency PRs: MLX core #14, MLX C #7, MLX-Swift #20, and MLX-Swift-LM #139. All four dependency PRs are merged. Core, C bridge, Swift and LM pins reference merged main revisions, including MLX-Swift-LM d4335f02d9c466a9d02e4bd576354b6b10ac7674, whose source tree matches the tested feature branch.

Implementation and measured results.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review corrections make benchmark acceptance match the evidence contract: Gemma accepts current sweep schema 7; GPT-OSS B>1 performance comparisons require ordered schema-7 submissions; matrix provenance pins iterations, output-token budget and KV backend; binary/metallib/config/receipt/model contents are rechecked before and after each cell, including supplied artifact symlink resolution. Legacy scaling groups also require compatible workload settings. Failed decode warmups abort before measurements. Empty or failed trace reductions remove only their six owned CSV outputs.

flowchart LR
  subgraph Before
    A1[Warmup row failure] --> B1[measureDecode continues to timed samples]
    A2[Changed artifact or mixed workload] --> B2[Runner may accept incomparable rates]
    A3[Empty trace reduction] --> B3[Old CSV tables remain]
  end
  subgraph After
    C1[Warmup row failure] --> D1[warmDecodeShapes throws before measurements]
    C2[Each matrix cell] --> D2[Artifact and workload checks plus ordered batched validation]
    D2 --> E2[Accept compatible data or reject cell]
    C3[Trace write_results] --> D3[Clear owned tables then write current results]
  end
Loading

Review-fix validation: release integration passed 61 Swift Testing tests and 10 XCTest cases; profiling tooling passed 33 tests; Gemma wrapper passed 65 tests; docs lint passed for 132 files.

@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Sep 5, 2026 7:25pm UTC
d-inference-console-ui-dev Ready Ready Preview Sep 5, 2026 7:25pm UTC
d-inference-landing Ready Ready Preview Sep 5, 2026 7:25pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-05T19:32:34.567824Z a8058d9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ed40493e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/gemma_contbatch/validation.py Resolved
Comment thread scripts/gptoss_profile/validation.py Resolved
Comment thread scripts/gptoss_profile/runner.py Resolved
Comment thread scripts/gptoss_profile/trace_reduce.py Resolved
Comment thread scripts/gptoss_profile/runner.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8058d9a2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/gptoss_profile/runner.py Resolved
Comment thread scripts/gptoss_profile/controls.py Resolved
Comment thread scripts/gptoss_profile/trace_reduce.py Resolved

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference-console-ui-dev — a8058d9a Deployed Sep 5, 2026 by vercel[bot]
Preview – d-inference — a8058d9a Deployed Sep 5, 2026 by vercel[bot]
Preview – d-inference-landing — a8058d9a Deployed Sep 5, 2026 by vercel[bot]
benchmarks — a8058d9a Deployed Sep 5, 2026 by Gajesh2007 via E2E Benchmarks #751
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.

2 participants