Skip to content

[Triton/Gluon] [Bench] bench_mla: pass the output buffer to mla_prefill_fwd - #6251

Merged
azaidy merged 2 commits into
mainfrom
fix/bench-mla-prefill-output
Oct 12, 2026
Merged

azaidy merged 2 commits into
mainfrom
fix/bench-mla-prefill-output

Conversation

@zhanglx13

@zhanglx13 zhanglx13 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In bench_mla.py, both prefill calls pass out to mla_prefill_fwd before out is assigned (it is the call's own return value), so every prefill run (--decode_qlen 0) fails:

UnboundLocalError: cannot access local variable 'out' where it is not associated with a value

Fix

Pass the preallocated output buffer, as the decode branch does. Both prefill call sites, lines 219 and 281.

Inside the timed fn(), neither call's result is used (the kernels write into output), so both calls there no longer bind it to out. Ruff flagged the prefill one (F841) once it stopped reading out.

Testing

bench_mla --decode_qlen 0 now runs the prefill kernel instead of raising.

The prefill branch passed 'out', which is not assigned yet at that point, so
any prefill run (--decode_qlen 0) failed with:

    UnboundLocalError: cannot access local variable 'out'

Pass 'output', as the decode branch does.
@zhanglx13
zhanglx13 requested review from a team and a balanced review from Copilot October 8, 2026 07:06
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6251 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title [Triton] [Bench] bench_mla: pass the output buffer to mla_prefill_fwd [Triton/Gluon] [Bench] bench_mla: pass the output buffer to mla_prefill_fwd Oct 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The documented prefill command still passes a default shuffled-cache flag that the wrapper rejects.

1 open finding
What changed in this PR

Fixes output-buffer handling in the MLA prefill benchmark.

Changes:

  • Passes the preallocated output buffer to both the initial and timed prefill calls, eliminating the unbound out reference.
File Description
op_tests/​op_benchmarks/​triton/​bench_mla.py Corrects the output argument at both prefill call sites.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Both calls inside fn() bound their result to 'out' only for it to be
discarded; the kernels write into 'output'. Ruff flagged it (F841) once the
prefill call stopped reading 'out'.
Copilot AI balanced review requested due to automatic review settings October 8, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The documented prefill invocation still enables shuffled KV caching by default, which the prefill wrapper rejects.

1 open finding

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@zufayu
zufayu requested review from a team and Dewei-Wang-sh October 9, 2026 01:56
@azaidy
azaidy self-requested a review October 9, 2026 19:43
@azaidy azaidy self-assigned this Oct 9, 2026

@azaidy azaidy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@azaidy
azaidy merged commit 5d50873 into main Oct 12, 2026
@azaidy
azaidy deleted the fix/bench-mla-prefill-output branch October 12, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants