Skip to content

[FlyDSL] fp8_mqa_logits: drop the host row-pad copies - #6001

Merged
coderfeli merged 5 commits into
ROCm:mainfrom
frida-andersson:frida/fp8-mqa-logits-drop-row-pad
Oct 27, 2026
Merged

coderfeli merged 5 commits into
ROCm:mainfrom
frida-andersson:frida/fp8-mqa-logits-drop-row-pad

Conversation

@frida-andersson

@frida-andersson frida-andersson commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Remove the host-side row padding from flydsl_fp8_mqa_logits.

For an unaligned seq_len, the launcher used to zero-fill and concatenate Q, weights, cu_starts, and cu_ends. The kernel already uses a ceil-div row grid, so it can handle the short last tile directly.

Both kernel builders now clamp tail loads to the last valid row and give those slots an empty window. The launcher passes the real seq_len; _auto_variant is unchanged.

Trace

DeepSeek-V4.1-Flash, TP4, MI325X, rank 0. Two 262144 → 1024 requests, concurrency
4, DSpark-5, FlyDSL QuickReduce.

Before (M=16370, mfma_r4_w4):
Screenshot 2026-09-30 at 15 37 37

After:
Screenshot 2026-09-30 at 15 38 51
The rank-0 capture had 971 padded launches. This removes 3884 cats (25.4 ms) and 3884 fills (17.5 ms). There are no pad cats or fills in the new trace.

The kernel time is flat: mfma_r4_w4 averages 1.124 ms before and 1.129 ms after. The aligned M=16380 step did not pad and is also flat (478.1 ms before, 473.6 ms after, median of 16).

Testing

python op_tests/test_flydsl_fp8_mqa_logits.py --scenario verify
  • gfx942: 95/95 passed
  • Extra short-tail cases: 257×8192 and 16370×32768, including empty and past-end windows
  • DeepSeek-V4.1-Flash GSM8K 5-shot, spec decode off:
    • flexible-extract: 0.9234 ± 0.0073
    • strict-match: 0.9242 ± 0.0073

@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
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 6001 --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.

@frida-andersson
frida-andersson marked this pull request as ready for review September 30, 2026 13:43
@frida-andersson
frida-andersson requested a review from a team September 30, 2026 13:43
@samremes
samremes requested a balanced review from Copilot September 30, 2026 14:10

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

🔵 Needs a closer look

Tail masking changes GPU memory addressing in two optimized kernels and warrants final human and hardware-backed validation.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Removes host-side row padding by safely masking short tail tiles in both FlyDSL kernel variants.

Changes:

  • Clamps tail-row loads and suppresses invalid-row writes.
  • Allocates and launches using the real sequence length.
  • Updates short-tail test coverage and documentation.
File Description
fp8_mqa_logits.py Adds tail-row masking to both kernel builders.
fp8_mqa_logits_kernels.py Removes host padding and passes real dimensions.
test_flydsl_fp8_mqa_logits.py Updates short-tail test context.

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

Comment thread op_tests/test_flydsl_fp8_mqa_logits.py Resolved

@ChuanLi1101 ChuanLi1101 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.

Removing the host padding is safe. The kernel already launches one block for each partial tile of rows. For the extra slots in the last tile, the loads stay on the last real row and the KV window is empty, so nothing is stored. The -inf fill is turned off for those slots too, so it does not wipe the last real row. The trace matches this: the host copies and zero-fills disappear, and the kernel time stays the same.

I am not approving the PR yet. The tests had not started, so I am approving the Aiter Test, Checks, and OPUS workflow runs. Adding a CI label will not start them. Once #5921 merges, the split count still has to be computed from the real row count, rounded up, not from the old padded length.

vpietila-amd
vpietila-amd previously approved these changes Oct 7, 2026

@vpietila-amd vpietila-amd 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.

Looks good to me. Thanks for fixing this.

@zufayu
zufayu requested a review from yadaish October 8, 2026 02:09
vpietila-amd added a commit that referenced this pull request Oct 8, 2026
…950-epilogue

Brings in #6001: the launcher no longer zero-pads Q, weights,
cu_starts and cu_ends; both kernel builders mask the short last row tile.

Conflicts in fp8_mqa_logits_kernels.py: kept this branch's occupancy-aware /
aggressive split logic and passed it the unpadded seq_len.

Co-Authored-By: Claude <noreply@anthropic.com>
@zufayu
zufayu requested a review from coderfeli October 15, 2026 06:35
@zufayu zufayu assigned coderfeli and unassigned yadaish Oct 15, 2026
@zufayu
zufayu requested a review from zhiding512 October 15, 2026 07:54
zhiding512
zhiding512 previously approved these changes Oct 16, 2026

@zhiding512 zhiding512 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.

The kernel already launches ceil(seq_len / rows_per_block) blocks. Padding
Q, weights, and the window up to that multiple launched four zero-fills and
four cats on every unaligned call, and the extra rows were never read.
Mask the short last tile and pass the real seq_len.

Signed-off-by: Frida Andersson <fanderss@amd.com>
An empty window already keeps a past-the-end slot from being stored, so the extra writer predicate and the epilogue pointer clamp were not doing any work.

Signed-off-by: Frida Andersson <fanderss@amd.com>
Black 26.5.1 wants the short _make_out_row_t call on one line. That is the pre-check that blocked the test gate.

Signed-off-by: Frida Andersson <fanderss@amd.com>
The auto-variant pin still said (257, 8192) pads. The launcher no longer pads, so the note should say the case leaves a short tail tile.

Signed-off-by: Frida Andersson <fanderss@amd.com>
@frida-andersson
frida-andersson force-pushed the frida/fp8-mqa-logits-drop-row-pad branch from e6d4da4 to e7d0738 Compare October 25, 2026 19:57
The rebase event still had the old changed-file count, so the tag job compared 3 files with 744.

Signed-off-by: Frida Andersson <fanderss@amd.com>
@frida-andersson

Copy link
Copy Markdown
Contributor Author

Rebased onto main now that #5921 is merged. The split count uses the real seq_len, rounded up. gfx942 verify was 95/95.

Could you LGTM again? @ChuanLi1101 @vpietila-amd @zhiding512

@jamestangg
jamestangg requested a review from zhiding512 October 27, 2026 08:41

@coderfeli coderfeli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@coderfeli
coderfeli merged commit 699d750 into ROCm:main Oct 27, 2026
63 checks passed
akii96 added a commit to akii96/aiter that referenced this pull request Nov 11, 2026
…tical to main

The merge with main reintroduced host-side padding of Q/weights/cu_starts/
cu_ends to a multiple of the block's rows for every variant outside the gfx942
LDS set. main dropped that in ROCm#6001 (every builder masks a short last block
in-kernel), so on gfx950 an unaligned seq_len went from one launch to nine and
regressed (reported on MI355X). Pass the real seq_len to every variant again,
as main does; only the split policy stays variant-specific (_LDS942_SPLIT_POLICY
for the gfx942 LDS variants).

Also hard-gate the PR to gfx942: revert the shared direct-load builder
(_build_kernel_mfma_r_w, used by gfx950's direct-load variants) to main's
version. The empty-row union-window change only existed to absorb padded rows,
and the hoisted _fn_to_fnuz_i64 now lives in the gfx942 LDS module, which is
its only other user. fp8_mqa_logits.py is now byte-identical to main.

Add a launch-free launcher-contract check to the op test (real seq_len, no
host cat/new_zeros) that runs on every arch.

Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants