fix(vlm): guard validation forward against cuDNN fused-MHA SDPA backend#2659
Draft
akoumpa wants to merge 1 commit into
Draft
fix(vlm): guard validation forward against cuDNN fused-MHA SDPA backend#2659akoumpa wants to merge 1 commit into
akoumpa wants to merge 1 commit into
Conversation
NVBugs: 6293238 Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
Contributor
Author
|
/ok to test 2e7f40c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NVBug: 6293238
What
Constrain the VLM validation forward to non-cuDNN SDPA backends so it cannot dispatch to the cuDNN
fused-MHA kernel that can fail
mha_graph.execute(...).is_good() == false.eval_safe_sdpa_kernel()innemo_automodel/_transformers/kernel_patches.py—sdpa_kernel([FLASH_ATTENTION, EFFICIENT_ATTENTION, MATH])(cuDNN excluded), mirroring the cuDNNexclusion
resolve_sdpa_methodalready applies under activation checkpointing.FinetuneRecipeForVLM._run_validation_epochwraps the eval forward ineval_safe_sdpa_kernel()(skipped under context parallelism, where
train_ctxalready enters a cuDNN-free context).Why
Qwen3.6-27B dense VLM MTP finetune trains 10/10 steps cleanly, then crashes in the end-of-training
validation forward:
inside
F.scaled_dot_product_attention. Root cause is a cuDNN fused-MHA backend defect surfaced by thevalidation-forward shape (Qwen3.5 full-attention layers use head_dim=256 and the eval batch carries an
explicit attention mask). The Qwen3.5 VLM is a custom model, so it bypasses
_patch_attention(
auto_model.py:543) and never receives the cuDNN-excluding SDPA backend list that HF models get —leaving the eval forward free to select cuDNN. Training takes the maskless
is_causal=Truepath thatcuDNN handles, so only validation crashes. This keeps the published recipe's validation enabled
end-to-end (the POR test currently masks the bug by stripping validation), as recommended in the bug's
"Suggested next steps".
How tested
On cw-dfw (1× H100, container with torch 2.12 / cuDNN 9.21):
eval_safe_sdpa_kernel()disables cuDNN SDPA (flash/mem-efficient/math remain enabled) and restoresthe flag on exit.
Qwen3_5ForConditionalGenerationvalidation forward (eval/no_grad + activationcheckpointing + MTP + image, multiple seqlens) runs green under the guard with finite logits.
pytest tests/unit_tests/_transformers/test_eval_safe_sdpa_kernel.py+ existing kernel_patches tests:10 passed.
ruff check/ruff format --checkclean.Note: the kernel-level crash no longer reproduces on cuDNN 9.21 (the kernel defect was fixed in a newer
cuDNN than the bug's original
nemo-automodel:nightlyimage); this change removes the code-levelfragility so older-cuDNN users are protected and the backend choice is explicit.
Scope / risk
Eval-only; training behavior unchanged. CP path unchanged (guard skipped — CP's context already excludes
cuDNN). Low risk: flash/mem-efficient/math are already the AC-time default for HF models. +83/-1, 3 files.