Skip to content

fix: add missing NVTE_BHSD labels to fused_attn to_string - #3538

Merged
cyanguwa merged 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/fused-attn-tostring-missing-enum-labels
Sep 21, 2026
Merged

cyanguwa merged 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/fused-attn-tostring-missing-enum-labels

Conversation

@andrewwhitecdw

Copy link
Copy Markdown
Contributor

Adds the two missing NVTE_BHSD entries to the fused_attn enum-to-string helpers, consolidating the two one-liner PRs (#3361, #3362) as requested in review.

Changes

  • transformer_engine/common/fused_attn/fused_attn.cpp — add case labels for NVTE_BHSD_BHSD_BHSD in to_string(NVTE_QKV_Layout) and NVTE_BHSD in to_string(NVTE_QKV_Format).

Details

NVTE_BHSD_BHSD_BHSD (= 25) and NVTE_BHSD (= 7) exist in the NVTE_QKV_Layout / NVTE_QKV_Format enums in transformer_engine/common/include/transformer_engine/fused_attn.h, and other helpers in the same file already special-case them, but the two to_string switches never got case labels. Code logging those layouts/formats currently falls through to the UNKNOWN_QKV_LAYOUT(...) / UNKNOWN_QKV_FORMAT(...) fallback. Each switch gets one new case returning its own enum name, placed in the same order as the enum declarations and mirroring the formatting of the neighboring cases. No behavior change for any other value.

Tests

Not run — a full compile requires the CUDA/cuDNN toolchain, which is not available in the contributor's environment. Lightweight verification only: grep confirmed both labels match the enum declarations and the surrounding switch style, and no duplicate case label was introduced.

Per the maintainer's feedback on #3362, no test file is included — the addition of BHSD to these enums is a straightforward label addition, and the removed test in #3362 was not appropriate here.

Summary: add the two missing NVTE_BHSD entries to the fused_attn
enum-to-string helpers so those values stop rendering as UNKNOWN_*.

Root cause: NVTE_BHSD_BHSD_BHSD (= 25) and NVTE_BHSD (= 7) exist in
the NVTE_QKV_Layout / NVTE_QKV_Format enums declared in
transformer_engine/common/include/transformer_engine/fused_attn.h,
and other helpers in the same file already special-case them, but the
to_string(NVTE_QKV_Layout) and to_string(NVTE_QKV_Format) switches in
transformer_engine/common/fused_attn/fused_attn.cpp never got case
labels for them. Code logging those layouts/formats falls through to
the UNKNOWN_QKV_LAYOUT(...) / UNKNOWN_QKV_FORMAT(...) fallback.

Fix: append two case labels, each returning its own enum name, in the
same order as the enum declarations and mirroring the formatting of
the neighboring cases. No behavior change for any other value; the
default fallback still handles future additions.

Testing: a full compile was not run locally because this file requires
the CUDA/cuDNN toolchain (cuda_runtime_api.h, cudnn headers) that is
not available here. Lightweight verification performed instead:
grep -n confirmed both inserted case labels exactly match the enum
declarations in fused_attn.h (values 25 and 7) and the surrounding
switch cases, and no duplicate case label was introduced in either
switch.

Consolidates andrewwhitecdw/TransformerEngine#3361 and
andrewwhitecdw/TransformerEngine#3362 per maintainer review.

Signed-off-by: Andrew White <andrewwhitecdw@users.noreply.github.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Sep 17, 2026
@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because both added switch cases correctly map existing enum values without affecting other behavior.

Summary

Adds the missing string conversions for the existing BHSD fused-attention enum values.

  • Maps NVTE_BHSD_BHSD_BHSD to its enum name in to_string(NVTE_QKV_Layout).
  • Maps NVTE_BHSD to its enum name in to_string(NVTE_QKV_Format).
  • Preserves the existing unknown-value fallbacks and behavior for all other enum values.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into bugfix/fused-at..."

@cyanguwa
cyanguwa merged commit 2b20496 into NVIDIA:main Sep 21, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attention community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants