← Back to Pull requests

[TE] CK fused attention: return max_logit #755

Open
unknown opened this pull request with 353 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 07, 2026 15:54 UTC
Author

Description

Adds return_max_logit=True (MuonClip/QK-clip) on ROCm through CK fused attention, for PyTorch and JAX. Before, PyTorch asserted and no backend supported it.

The CK forward writes the exact per-row max next to the LSE; TE reduces it to [h], as for cuDNN.

Dependencies:

  • ROCm/QoLA#13 carries the CK/AITER patches (upstream CK PR: ROCm/rocm-libraries#13395). This PR re-pins QoLA to its merged commit before landing.

  • #765 must merge first. Otherwise incremental CK-JIT builds keep the old CK headers.
  • Fixes https://github.com/AMD-ROCm-Internal/frameworks-internal/issues/381

    Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Infra/Build change

  • Code refactoring
  • Changes

    Please list the changes introduced in this PR:

  • Backend selection: CK takes max-logit on gfx942/gfx950 without bias, dropout or the opt-in small-seq kernels; AOTriton never does. If CK can't, backend selection warns once with the reason.

  • CK glue:

  • - passes max_ptr and turns asm v3 off when the max is on;
    - Max scratch and pad_remap_lse on group-mode paths; -inf prefill for rows CK doesn't write;
    - aux pack [S, Max, rng_state, bias?, softmax_offset?], as upstream.
  • PyTorch: ROCm asserts removed; THD Max masking skipped for CK.

  • JAX: Max aux tensor enabled on ROCm; THD Max is token-major, as with cuDNN 9.6+.

  • Build/CI:

  • - QoLA bump (ROCm/QoLA#13): patches 0012 and 0013, plus a checkout fix for patches that add files.
    - ci/ck_jit_prebuild.txt: +70 gfx950 blobs used by these tests (gfx942 ones to follow from MI300 CI).
  • Tests:

  • - Exact max-logit: bshd/sbhd/thd, all masks, GQA, MLA 192/128, custom softmax_scale, fp16, sinks, SWA, fully masked rows; CK selection and fallback.
    - CP: cp_1_0/cp_1_1 as upstream (max on); ROCm-only cp_1_6/cp_1_7 (max off) cover the asm forward;
    cp_3_5 (MLA) and cp_4_4 (sink) with max on.
    - JAX CP max-logit: THD + all-gather skipped on ROCm, like the striped CP test.

    Checklist:

  • I have read and followed the contributing guidelines

  • The functionality is complete

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes
  • Diff: 353 lines (+264 / -89) across 4 files Reviewer: Micky774 Review duration: 56724m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 353 lines diff across 4 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #755"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.5% (MEDIUM) · Higher = larger blast radius
    49.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.4% · Safe to merge
    27.4%