Skip to content

[None][chore] Reconcile K3 KDA/attn-res kernel files with main (PR #17225) - #17230

Open
brnguyen2 wants to merge 2 commits into
NVIDIA:feat/kimi_k3from
brnguyen2:k3/feat-kernel-reconcile
Open

[None][chore] Reconcile K3 KDA/attn-res kernel files with main (PR #17225)#17230
brnguyen2 wants to merge 2 commits into
NVIDIA:feat/kimi_k3from
brnguyen2:k3/feat-kernel-reconcile

Conversation

@brnguyen2

Copy link
Copy Markdown
Collaborator

Description

#17225 carries the KDA prefill/MTP decode CuTe DSL kernels and the fused attention-residual kernel to main, with review fixes and repo-standard clang-format/ruff formatting that this branch predates. This PR syncs the file contents on feat/kimi_k3 to match, so that:

  • the eventual mergeback of this branch into main does not conflict on these files, and
  • this branch picks up the two functional fixes from that review:
    • fused_k123: zero-initialize all 64 SMEM rows — rows 62–63 previously read stale shared memory through the sAkk transposed store in the non-pure varlen path;
    • attnResFwd.cu: add the missing __syncwarp before the tail cross-lane logits reads.

Everything else is formatting and comment updates. Feat-side changes made after the kernels were exported were preserved via per-file three-way merges against the export base; no feat-only functionality is reverted. CMakeLists and custom_ops/__init__.py are untouched (they already agree or carry feat-only registrations).

Test Coverage

The kernel content matches #17225's tip, which passed a per-architecture compile check (sm_80/90/100f build; sm_120f rejected as designed by the arch pin). The KDA kernel parity unit suites on this branch cover the merged files; a parity rerun over the review's device-code changes is queued and should gate the merge of this PR.

PR Checklist

  • PR title and description above
  • Test coverage stated above

…IDIA#17225)

PR NVIDIA#17225 carries these kernels to main with review fixes and repo-wide
clang-format/ruff formatting that this branch predates. Sync the file
contents so the eventual mergeback of feat/kimi_k3 into main does not
conflict on them, and so this branch picks up the two functional fixes
from that review:

- fused_k123: zero-initialize all 64 SMEM rows (rows 62-63 previously
  read stale SMEM through the sAkk transposed store in the non-pure
  varlen path)
- attnResFwd.cu: add the missing __syncwarp before the tail cross-lane
  logits reads

Everything else is formatting and comment updates. Feat-side changes
made after the kernels were exported (per-file 3-way merge against the
export base) are preserved; no feat-only functionality is reverted.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
@brnguyen2
brnguyen2 requested review from a team as code owners August 3, 2026 23:31
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63578 [ run ] triggered by Bot. Commit: 710b0a4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63578 [ run ] completed with state FAILURE. Commit: 710b0a4
/LLM/main/L0_MergeRequest_PR pipeline #51542 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

The review-round change narrowing the k4_persistent monkey-patch handler
to `except (AttributeError, ImportError)` breaks every cute.compile of
the module: the nvidia-cutlass-dsl 4.5.0 AST preprocessor cannot parse
tuple except handlers ("'Tuple' object has no attribute 'id'"). Revert
to a single bare Exception with a comment explaining the constraint.

Also gate the new A_log validation on a non-empty token batch: zero-token
calls take the early return in _chunk_kda_fwd and never touch A_log, and
the runtime emits such batches under the overlap scheduler + logprobs
flows.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63751 [ run ] triggered by Bot. Commit: 42f4f06 Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

Pre-merge validation results for this PR at the current tip (42f4f06), run on a self-built checkout of this branch on a Blackwell (sm_100 family) node:

Kernel-vs-reference parity unit suites — all green:

  • Fused-verify, KDA-verify, KDA MTP decode, and attn-res op parity suites: 24 passed.
  • Full tests/unittest/_torch/modules/kimi_kda/ directory: 55 passed / 2 skipped (the pre-existing test_selector_preserves_legacy_compact_heads_off_sm103 exclusion, and test_recycled_id_varlen_pure_cache, an allocator-dependent dynamic-precondition skip). The varlen configurations covering the fused_k123 SMEM zero-init fix all passed (state-parity aligned/non-aligned/single-sequence, packed-varlen eval-scale parity, small-varlen batch, non-default-stream varlen).

Logits-parity integration run — 4-GPU TP4 generation on a layer-truncated checkpoint: the baseline leg and the spec-dec logits-parity leg both pass (52 prompts, parity verified, zero drift).

Two findings on the target branch itself, orthogonal to this PR's content:

  1. tests/unittest/_torch/modules/kimi_kda/test_attn_res_op.py on feat/kimi_k3 builds its inputs in a stale layout — 9/10 cases fail with or without this PR. The suite is green with the corrected test-side layout (the version that accompanies these kernels on the main-bound integration work); worth picking up on this branch separately.
  2. feat/kimi_k3's requirements-dev.txt doesn't pin flash-linear-attention (0.5.2 elsewhere); without it the kimi_kda suites silently skip via importorskip. The runs above installed it explicitly.

Validation history: an earlier run at 710b0a4 caught that narrowing a module-level handler in k4_persistent.py to except (AttributeError, ImportError) breaks every cute.compile of the module — the nvidia-cutlass-dsl 4.5.0 AST preprocessor cannot parse tuple except handlers. Fixed at the current tip (and mirrored in #17225).

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63751 [ run ] completed with state SUCCESS. Commit: 42f4f06
/LLM/main/L0_MergeRequest_PR pipeline #51701 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63765 [ run ] triggered by Bot. Commit: 42f4f06 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63765 [ run ] completed with state SUCCESS. Commit: 42f4f06
/LLM/main/L0_MergeRequest_PR pipeline #51716 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63779 [ run ] triggered by Bot. Commit: 42f4f06 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63779 [ run ] completed with state SUCCESS. Commit: 42f4f06
/LLM/main/L0_MergeRequest_PR pipeline #51728 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

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