Skip to content

Add attn_logit_softcapping config, plumbed to TE and local attention - #6590

Open
nvegesna-netizen wants to merge 1 commit into
NVIDIA:mainfrom
nvegesna-netizen:nvegesna/gemma2-attn-softcap
Open

Add attn_logit_softcapping config, plumbed to TE and local attention#6590
nvegesna-netizen wants to merge 1 commit into
NVIDIA:mainfrom
nvegesna-netizen:nvegesna/gemma2-attn-softcap

Conversation

@nvegesna-netizen

Copy link
Copy Markdown
Contributor

Exposes tanh logit soft-capping as a first-class config field so models with this attention variant (e.g. Gemma2) can run on the fused TransformerEngine flash-attention path instead of an unfused fallback.

Companion PRs:

What changed

  • TransformerConfig.attn_logit_softcapping: Optional[float] = NoneNone disables softcapping, default behavior unchanged.
  • TEDotProductAttention maps this to TE's softcap kwarg via a signature capability probe on the installed TE build, rather than a version gate — this lets it work against TE builds that add softcap support ahead of a version bump, and asserts clearly if the field is set but the installed TE build doesn't support it.
  • Local (no-TE) DotProductAttention applies the equivalent cap pre-softmax, for parity with the fused path when TE isn't in use.

Validation

Exercised end-to-end via the companion TransformerEngine and Megatron-Bridge changes above — multi-step training runs confirmed numerically consistent with the prior unfused path.

Expose tanh logit softcapping so models like Gemma2 can run on the fused
TransformerEngine flash path.

- Add TransformerConfig.attn_logit_softcapping (Optional[float], None disables).
- TEDotProductAttention: map it to TE's flash `softcap` kwarg via a signature
  capability probe (inspect.signature on te.pytorch.DotProductAttention) rather
  than a version gate, since patched TE builds may add softcap without a version
  bump; assert clearly when the field is set but the TE build lacks support.
- Local DotProductAttention: apply cap*tanh(logits/cap) pre-softmax for
  CPU/no-TE parity with the fused path.

When attn_logit_softcapping is None, behavior is unchanged.

Signed-off-by: Nitin Vegesna <nvegesna@nvidia.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nvegesna-netizen
nvegesna-netizen requested review from a team as code owners August 17, 2026 21:07
@copy-pr-bot

copy-pr-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically converted to draft because all PRs must start as drafts.

When you are ready for review, click Ready for Review to begin the review process. This will:

  1. Add the oncall reviewer (optional reviewer)
  2. Add required review teams based on your changes

See the contribution guide for more details.

@nvegesna-netizen
nvegesna-netizen marked this pull request as ready for review August 17, 2026 21:31
@nvegesna-netizen

Copy link
Copy Markdown
Contributor Author

@NVIDIA/mcore-oncall can you review?

@nvegesna-netizen nvegesna-netizen self-assigned this Aug 22, 2026
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.

1 participant