Skip to content

[Triton/Gluon] [FlyDSL] Read (B, next_n) context lengths in the paged MQA logits kernels - #6153

Closed
amd-sriram wants to merge 5 commits into
ROCm:mainfrom
amd-sriram:rocm/paged-mqa-logits-2d-context-lens
Closed

amd-sriram wants to merge 5 commits into
ROCm:mainfrom
amd-sriram:rocm/paged-mqa-logits-2d-context-lens

Conversation

@amd-sriram

@amd-sriram amd-sriram commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Currently, vLLM passes context_lens to the paged MQA logits kernels as a 2D (B, next_n) table, the same layout DeepGEMM uses. The AITER kernels for paged_mqa_logits only read a 1D [B] vector. With MTP on, the 2D table gives them the wrong lengths: silently for Gluon and Triton, and as a reshape error for FlyDSL.

This PR lets the paged_mqa_logits kernels accept the 2D context_lens that vLLM sends with MTP, while staying backward compatible with the 1D context_lens that SGLang and ATOM send with MTP, and with the 1D format used without MTP.

Example: 4 requests, next_n=3, context lengths 8192 / 1500 / 3000 / 700, vLLM sends the following 2D array:

b j=0 j=1 j=2
0 8190 8191 8192
1 1498 1499 1500
2 2998 2999 3000
3 698 699 700

The paged_mqa_logits kernels read the above 2D array as 1D and read the context_lens as [8190, 8191, 8192, 1498]. The fix uses the row length (next_n) as the stride and reads the last entry of each row, which gives [8192, 1500, 3000, 700].

What changes

  • Each kernel reads sequence b's length at b * stride + stride - 1.
    • 1D [B]: stride is 1, so this is context_lens[b], the same load as today.
    • 2D (B, n): stride is n, so this is the last entry of row b, which is the full sequence length.
  • The per-row causal mask is still built from that one length, as before.
  • Gluon and Triton: new ContextLenStride constexpr, default 1. The 1D path compiles to the same code as before.
  • FlyDSL: new runtime ctx_stride argument.
  • The wrappers pick the stride from the tensor's rank.
    • A strided [B] (for example table[:, -1]) is made contiguous. Before, every backend read it as if it were dense and got the wrong lengths.
    • A 2D table must be contiguous with at least B rows (FlyDSL: exactly B). Anything else raises ValueError.
  • AOT Gluon (Triton < 3.4): a stride other than 1 gets a different kernel name, so a missing prebuilt binary fails loudly instead of running the 1D kernel.
  • The ragged-K variants use prefix_sum_context_lens and are not touched.

Backward compatibility

Callers that pass 1D context_lens today, including ATOM and SGLang with MTP, are not affected.

  • [B] with Q [B, next_n, ...]: unchanged. ATOM's sparse indexer uses this.
  • [num_tokens] with Q [num_tokens, 1, ...]: unchanged. ATOM's DeepSeek-V4 indexer and SGLang's AITER wrapper use this.
  • (B, 1) behaves exactly like [B].
  • A contiguous (B, next_n) table is the only new input.

Tests

  • New test_paged_mqa_logits_2d_context_lens in op_tests/test_pa_mqa_logits_offset.py. For Gluon plain, Gluon preshuffle and FlyDSL (gfx950), a (B, next_n) table must give exactly the same logits as the 1D lengths. Mixed lengths (3000, 257, 64, 3), next_n=3.
  • The same test also checks that (B, 1) and a strided [B] give the same logits, and that a non-contiguous table or one with too few rows raises ValueError.
  • The existing tests in that file already cover 1D lengths with next_n > 1.
  • op_tests/test_flydsl_fp8_paged_mqa_logits.py (FlyDSL and Gluon, next_n 1 to 8, 1D lengths).

Results

MI355X, Triton 3.8, FlyDSL 0.3.4.1, AITER with the touched files at the PR base 7bfe279de plus this change:

  • test_pa_mqa_logits_offset.py: 108/108 passed, 10 runs in a row. The new test fails without this change.
  • test_flydsl_fp8_paged_mqa_logits.py: all tables pass, max error 5e-4.
  • 2D and 1D give bit-identical logits for Gluon and FlyDSL. Stage1 and the varctx schedule are identical over 100 calls.
  • A strided [B] now matches a contiguous one on every backend.
  • Kernel time, 1D vs 2D, at the GLM-5 indexer shape with 8k context. The difference stays within ±1.5%. Measured before the last commit, which only adds Python-side checks:
path B next_n 1D µs 2D µs
Gluon preshuffle 16 3 10.02 10.01
Gluon preshuffle 128 5 70.50 70.00
FlyDSL 16 5 19.22 19.50
FlyDSL 128 5 60.06 60.52
  • Not tested: AOT Gluon (needs Triton < 3.4).

Found while testing (not fixed here)

These two paths give different results from run to run even with 1D lengths, so the new test skips them:

  • deepgemm_fp8_paged_mqa_logits_stage1: the -inf mask changes between identical calls.
  • Gluon preshuffle with VarCtxSchedule: up to 5 of 200 repeated calls differ.

Neither is on the vLLM decode path. Worth a separate issue.

Gluon, Triton stage1/schedule and FlyDSL wrappers take the last column of a 2D table, the layout DeepGEMM takes and vLLM passes.

Signed-off-by: Sriram Kumar <[email protected]>
…copy

Replaces the wrapper-side slice with a ContextLenStride the Gluon, Triton and FlyDSL kernels index with.

Signed-off-by: Sriram Kumar <[email protected]>
@github-actions

github-actions Bot commented Oct 5, 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
multigpu 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 6153 --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.

Make a strided [B] contiguous, reject a 2D table that is not contiguous or has fewer than B rows.

Signed-off-by: Sriram Kumar <[email protected]>
@amd-sriram
amd-sriram marked this pull request as ready for review October 5, 2026 17:07
@amd-sriram
amd-sriram requested review from a team and a balanced review from Copilot October 5, 2026 17:07

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.

Copilot review overview

🟡 Changes recommended

Zero-column context tables can pass validation and reach out-of-bounds kernel reads.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds support for vLLM’s 2D context-length tables in paged MQA logits while preserving existing 1D inputs.

Changes:

  • Threads context-length strides through Triton, Gluon, and FlyDSL kernels.
  • Adds input normalization, validation, and stride-specific AOT naming.
  • Adds regression checks for supported layouts and invalid tables.
File Description
op_tests/​test_pa_mqa_logits_offset.py Adds context-length layout regression tests.
aiter/​ops/​triton/​gluon/​pa_mqa_logits.py Updates Gluon length indexing.
aiter/​ops/​triton/​attention/​pa_mqa_logits.py Validates inputs and forwards strides through dispatch.
aiter/​ops/​triton/​_triton_kernels/​attention/​pa_mqa_logits.py Updates Triton kernel and scheduler indexing.
aiter/​ops/​flydsl/​kernels/​mqa_logits/​fp8_paged_mqa_logits_gfx950.py Adds runtime stride handling for FlyDSL.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +88 to +95
if (
context_lens.dim() != 2
or not context_lens.is_contiguous()
or context_lens.shape[0] < batch_size
):
raise ValueError(
"context_lens must be [B] or a contiguous [B, n] with at least B rows"
)
Comment on lines +395 to +407
@pytest.mark.skipif(
get_gfx() not in ("gfx942", "gfx950") or not enable_jit_gluon_pa_mqa_logits_kernel,
reason="Requires the CDNA Gluon JIT paged MQA kernel",
)
# stage1 and the varctx schedule are left out: two identical calls of either do
# not always give the same logits today.
@pytest.mark.parametrize("entry", ["plain", "preshuffle", "flydsl"])
@torch.inference_mode()
def test_paged_mqa_logits_2d_context_lens(entry: str) -> None:
"""A (B, next_n) per-row table, the layout DeepGEMM takes and vLLM passes,
gives the same logits as the per-sequence lengths it ends with."""
if entry == "flydsl" and get_gfx() != "gfx950":
pytest.skip("FlyDSL paged MQA logits is gfx950-only")
@azaidy
azaidy requested a review from vgokhale October 5, 2026 22:11
@azaidy azaidy assigned vgokhale and unassigned amd-sriram Oct 5, 2026
amd-sriram added a commit to amd-sriram/aiter that referenced this pull request Oct 6, 2026
…rnels

Drop the 2D context_lens shim; ROCm#6153 adds 2D support in the kernels.
context_lens = context_lens.reshape(batch_size)
ctx_stride = context_lens.shape[1] if context_lens.dim() == 2 else 1
if ctx_stride == 1:
context_lens = context_lens.reshape(batch_size).contiguous()

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.

could be better to assert contiguousness, or give a warning that this possibly makes a copy unexpectedly.

@vgokhale

Copy link
Copy Markdown
Contributor

Please split into two different PRs for two different backends.

@vgokhale vgokhale closed this Oct 12, 2026
@amd-sriram amd-sriram changed the title [Triton/Gluon] [FlyDSL] Read (B, next_n) context lengths in the paged MQA logits kernels [Triton/Gluon] Read (B, next_n) context lengths in the paged MQA logits kernels Oct 12, 2026
@amd-sriram amd-sriram reopened this Oct 12, 2026
@github-actions

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:windows Windows JIT op smoke test on the gfx1201 ROCm runner
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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 6153 --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.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:00
@amd-sriram
amd-sriram force-pushed the rocm/paged-mqa-logits-2d-context-lens branch from e41e07c to 03e7f86 Compare October 12, 2026 21:00
@github-actions github-actions Bot removed the FlyDSL label Oct 12, 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

Undersized 1D inputs can still cause out-of-bounds reads, and kernel representations omit the new specialization key.

4 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment on lines +93 to +94
if context_lens.dim() == 1:
return context_lens, 1
HiddenDim: tl.constexpr,
KVBlockSize: tl.constexpr,
SplitKV: tl.constexpr = 1,
ContextLenStride: tl.constexpr = 1,
Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:27
@amd-sriram amd-sriram changed the title [Triton/Gluon] Read (B, next_n) context lengths in the paged MQA logits kernels [Triton/Gluon] [FlyDSL] Read (B, next_n) context lengths in the paged MQA logits kernels Oct 12, 2026
@amd-sriram
amd-sriram force-pushed the rocm/paged-mqa-logits-2d-context-lens branch from 2cb05fa to e41e07c Compare October 12, 2026 21:29
@amd-sriram

Copy link
Copy Markdown
Contributor Author

Split into one PR per backend as requested: #6451 (Triton/Gluon) and #6450 (FlyDSL). Both address the review comments here.

@amd-sriram amd-sriram closed this Oct 12, 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

Validation accepts incompatible int64 inputs, and several modified kernel paths remain untested.

7 open findings
Previously missed (2)

In code that hasn't changed since last review

Medium severity Remove hard-coded Triton tuning overrides

op_tests/​test_pa_mqa_logits_offset.py:478

The new test pins ChunkK and WavePerEU even though these are the wrapper's current defaults. Triton/Gluon unit tests must exercise the wrapper-selected configuration rather than hard-code tuning values; otherwise a future default/config change can leave this regression test exercising a stale specialization. Remove these overrides.

Low severity Move attention test to Triton test directory

op_tests/​test_pa_mqa_logits_offset.py:404

This new attention-op test is being added to the legacy op_tests/ root. The Triton test layout mirrors the wrapper path, so a test of aiter/ops/triton/attention/pa_mqa_logits.py belongs under op_tests/triton_tests/attention/ (which already exists). Move this case there so it follows the repository's test discovery and ownership convention.

🧠 Review effort: Balanced

Comment on lines +88 to +92
if context_lens.dim() not in (1, 2) or not context_lens.is_contiguous():
raise ValueError(
"context_lens must be a contiguous [B] or [B, n], got shape "
f"{tuple(context_lens.shape)} with strides {context_lens.stride()}"
)
Comment on lines +396 to +399
@pytest.mark.skipif(
get_gfx() not in ("gfx942", "gfx950"),
reason="Requires a CDNA paged MQA kernel",
)
Comment thread op_tests/test_pa_mqa_logits_offset.py Outdated
Comment on lines +400 to +402
# stage1 and the varctx schedule are left out: two identical calls of either do
# not always give the same logits today.
@pytest.mark.parametrize("entry", ["plain", "preshuffle", "triton"])
Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:31

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.

Comment on lines +86 to +95
if context_lens.dim() == 1:
return context_lens.contiguous(), 1
if (
context_lens.dim() != 2
or not context_lens.is_contiguous()
or context_lens.shape[0] < batch_size
):
raise ValueError(
"context_lens must be [B] or a contiguous [B, n] with at least B rows"
)
stride_q_batch: fx.Int32,
max_block_len: fx.Int32,
stride_out: fx.Int32,
ctx_stride: fx.Int32,
amd-sriram added a commit to amd-sriram/aiter that referenced this pull request Oct 22, 2026
…rnels

Drop the 2D context_lens shim; ROCm#6153 adds 2D support in the kernels.
samremes pushed a commit that referenced this pull request Nov 3, 2026
…DSL table (#6140)

* [Triton][FlyDSL] Add aiter.paged_mqa_logits with a tuned Gluon/FlyDSL table

Picks the paged MQA logits backend and its launch knobs per shape from paged_mqa_logits_tuned.csv. Adds the tuner and op test, and gfx950 rows for the GLM-5 indexer.

Signed-off-by: Sriram Kumar <[email protected]>

* [Triton][FlyDSL] Move paged_mqa_logits next to fused_moe, GLM-5 rows to model_configs

Signed-off-by: Sriram Kumar <[email protected]>

* [Triton][FlyDSL] Look up paged_mqa_logits on the live GPU

get_gfx() follows GPU_ARCHS and skipped the tuned row.

* [Triton][FlyDSL] Drop context_len from the paged_mqa_logits merge key

The generic untuned header is the dedup key. Two rows that differ only
in context length now collide.

* fix: keep paged_mqa_logits run_config off the merge-key header

The generic untuned file no longer has context_len. pre_process still
runs on --run_config and needs that column.

* [FlyDSL] Check the live GPU in the gfx950 paged MQA logits kernel

get_gfx() follows GPU_ARCHS, so the kernel raised on gfx950 with
GPU_ARCHS=gfx942 once the dispatcher picked FlyDSL.

* test: run the shipped-row check with GPU_ARCHS set at process start

Setting GPU_ARCHS mid-process did not reach get_gfx(); the child process
also launches the real kernel.

* [FlyDSL] Fall back to the tuned Gluon knobs when FlyDSL cannot run

FlyDSL rows now store the winning Gluon ChunkK and WavePerEU.
GLM-5 gfx950 table retuned.

* test: check the dispatched paged_mqa_logits config without compiling

The shipped-row check records the config and no longer launches a kernel.

* ci: add paged_mqa_logits to the manual tuning recipes

* [Triton][FlyDSL] Pass context_lens through to the paged MQA logits kernels

Drop the 2D context_lens shim; #6153 adds 2D support in the kernels.

* [Triton][FlyDSL] Tune the GLM-5 paged_mqa_logits rows at 8k and 60k context

Matches the benchmark input lengths (8192 and 60000).

* Document the paged_mqa_logits contract and the context_len column

State the tensors the front-end takes instead of pointing at the Gluon
wrapper, and say that context_len is tuning metadata dispatch does not
read.

* Default the paged_mqa_logits tuner context lengths to 8192;60000

A row with no context_len (a generic-schema untuned CSV, or an empty cell) got an empty context list, so the tuner timed nothing and reported the shape as failed. Such rows now use --context_len, which defaults to the lengths the shipped table was tuned over; context_len stays out of the collision-key header.

* Exit nonzero when paged_mqa_logits tuning errors or is interrupted

TunerCommon.run() catches the exception and calls tune_summary with status Error or Interrupted. With no failed row recorded, the script exited 0 and op_tune.sh reported a pass.

* Reject a strided context_lens in paged_mqa_logits for both backends

Gluon already rejects a non-contiguous context_lens, but the FlyDSL wrapper reshapes it without removing the stride and the kernel reads it as dense, so a table[:, -1] view gave wrong causal bounds on the shipped B=64, next_n=8 FlyDSL row. run_paged_mqa_logits, which the op and the tuner share, now raises ValueError for it; the test covers that view.

* Document context_len as provenance and accept (B, next_n) context_lens

Dispatch deliberately does not key on context length; say so up front and at the loader, where the context_len column is free text that is never parsed (only the tuner reads it). Both kernels read the (B, next_n) table vLLM builds since #6451 and #6450, so the contract now lists it.

* Test (B, next_n) context_lens through paged_mqa_logits and each backend

Uses the shipped B=64, next_n=8 row, which dispatches to FlyDSL, and checks the op, Gluon and FlyDSL against the reference.

* Log each context's gap to its own best in the paged_mqa_logits tuner

The pick minimises the geomean over the row's contexts, which can hide a context where it is well off that context's best. Print the pick's time, the per-context best and the loss for every context.

* ci: upload model_configs tuned CSVs in the tuning artifact

The paged_mqa_logits job writes aiter/configs/model_configs/paged_mqa_logits_tuned_glm5.csv, which aiter/configs/*.csv does not match.

* Test CUDA graph replay and elementwise accuracy in paged_mqa_logits

Capture the op, Gluon and FlyDSL in a CUDA graph at 1024 tokens, change context_lens to 512 in place and replay: the output must match the reference at 512 and leave columns past it untouched, which fails if a launch reads the lengths on the host. The 2D context_lens check now also runs checkAllclose with the main test's tolerances.

---------

Signed-off-by: Sriram Kumar <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…DSL table (ROCm#6140)

* [Triton][FlyDSL] Add aiter.paged_mqa_logits with a tuned Gluon/FlyDSL table

Picks the paged MQA logits backend and its launch knobs per shape from paged_mqa_logits_tuned.csv. Adds the tuner and op test, and gfx950 rows for the GLM-5 indexer.

Signed-off-by: Sriram Kumar <[email protected]>

* [Triton][FlyDSL] Move paged_mqa_logits next to fused_moe, GLM-5 rows to model_configs

Signed-off-by: Sriram Kumar <[email protected]>

* [Triton][FlyDSL] Look up paged_mqa_logits on the live GPU

get_gfx() follows GPU_ARCHS and skipped the tuned row.

* [Triton][FlyDSL] Drop context_len from the paged_mqa_logits merge key

The generic untuned header is the dedup key. Two rows that differ only
in context length now collide.

* fix: keep paged_mqa_logits run_config off the merge-key header

The generic untuned file no longer has context_len. pre_process still
runs on --run_config and needs that column.

* [FlyDSL] Check the live GPU in the gfx950 paged MQA logits kernel

get_gfx() follows GPU_ARCHS, so the kernel raised on gfx950 with
GPU_ARCHS=gfx942 once the dispatcher picked FlyDSL.

* test: run the shipped-row check with GPU_ARCHS set at process start

Setting GPU_ARCHS mid-process did not reach get_gfx(); the child process
also launches the real kernel.

* [FlyDSL] Fall back to the tuned Gluon knobs when FlyDSL cannot run

FlyDSL rows now store the winning Gluon ChunkK and WavePerEU.
GLM-5 gfx950 table retuned.

* test: check the dispatched paged_mqa_logits config without compiling

The shipped-row check records the config and no longer launches a kernel.

* ci: add paged_mqa_logits to the manual tuning recipes

* [Triton][FlyDSL] Pass context_lens through to the paged MQA logits kernels

Drop the 2D context_lens shim; ROCm#6153 adds 2D support in the kernels.

* [Triton][FlyDSL] Tune the GLM-5 paged_mqa_logits rows at 8k and 60k context

Matches the benchmark input lengths (8192 and 60000).

* Document the paged_mqa_logits contract and the context_len column

State the tensors the front-end takes instead of pointing at the Gluon
wrapper, and say that context_len is tuning metadata dispatch does not
read.

* Default the paged_mqa_logits tuner context lengths to 8192;60000

A row with no context_len (a generic-schema untuned CSV, or an empty cell) got an empty context list, so the tuner timed nothing and reported the shape as failed. Such rows now use --context_len, which defaults to the lengths the shipped table was tuned over; context_len stays out of the collision-key header.

* Exit nonzero when paged_mqa_logits tuning errors or is interrupted

TunerCommon.run() catches the exception and calls tune_summary with status Error or Interrupted. With no failed row recorded, the script exited 0 and op_tune.sh reported a pass.

* Reject a strided context_lens in paged_mqa_logits for both backends

Gluon already rejects a non-contiguous context_lens, but the FlyDSL wrapper reshapes it without removing the stride and the kernel reads it as dense, so a table[:, -1] view gave wrong causal bounds on the shipped B=64, next_n=8 FlyDSL row. run_paged_mqa_logits, which the op and the tuner share, now raises ValueError for it; the test covers that view.

* Document context_len as provenance and accept (B, next_n) context_lens

Dispatch deliberately does not key on context length; say so up front and at the loader, where the context_len column is free text that is never parsed (only the tuner reads it). Both kernels read the (B, next_n) table vLLM builds since ROCm#6451 and ROCm#6450, so the contract now lists it.

* Test (B, next_n) context_lens through paged_mqa_logits and each backend

Uses the shipped B=64, next_n=8 row, which dispatches to FlyDSL, and checks the op, Gluon and FlyDSL against the reference.

* Log each context's gap to its own best in the paged_mqa_logits tuner

The pick minimises the geomean over the row's contexts, which can hide a context where it is well off that context's best. Print the pick's time, the per-context best and the loss for every context.

* ci: upload model_configs tuned CSVs in the tuning artifact

The paged_mqa_logits job writes aiter/configs/model_configs/paged_mqa_logits_tuned_glm5.csv, which aiter/configs/*.csv does not match.

* Test CUDA graph replay and elementwise accuracy in paged_mqa_logits

Capture the op, Gluon and FlyDSL in a CUDA graph at 1024 tokens, change context_lens to 512 in place and replay: the output must match the reference at 512 and leave columns past it untouched, which fails if a launch reads the lengths on the host. The 2D context_lens check now also runs checkAllclose with the main test's tolerances.

---------

Signed-off-by: Sriram Kumar <[email protected]>
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