← Back to Pull requests

Pad to a multiple of 128 by default with SDPA on H100 and B200 GPUs #8554

Closed
unknown closed this pull request without merging on Nov 27, 2026 09:49 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 07:07 UTC
Author

This PR makes pad_to_multiple_of="auto" pad to a multiple of 128 with SDPA attention on NVIDIA GPUs of compute capability 9.x and 10.x (H100, H200, B200, B300), as it already does on Neuron, in SFT, DPO, KTO, Reward, GRPO, RLOO and Distillation.

Tracking issue:

  • #8439
  • Motivation

    On these GPUs, PyTorch runs SDPA with cuDNN, which keeps a graph in host memory for every new sequence length and never frees it (pytorch/pytorch#202607). With the script of #8439 on an H100 (torch 2.14.1), host memory ends at 3.54 GB with today's default and at 2.13 GB with this PR, flat from step 100. Padding to 128 also keeps clear of the cuDNN NaN at seq_len % 128 == 64 on torch < 2.15 (pytorch/pytorch#196678), and #7724 measured +3% to +57% throughput with SDPA on H100/H200.

    Solution

    The configs still resolve "auto" in __post_init__, except on CUDA (not ROCm) GPUs of compute capability 9.x/10.x, where the trainers resolve it once the model is loaded: to 128 if the model uses SDPA, and to None otherwise, e.g. with FA2/FA3, which #7724 measured 2 to 6% slower when padded. Resolving it from the loaded model also covers the CLI, where --attn_implementation reaches model_init_kwargs only after the config is built, and models passed as objects. Generation with transformers still hits the cache; the docs cover that case (#8440).

    On an H100, the test files of the seven trainers pass with this PR and #8553 (without #8553, the vision-language tests of SFT, DPO and KTO hit #8551).

    Changes

  • Leave pad_to_multiple_of="auto" for the trainer to resolve on compute capability 9.x/10.x in the seven configs, and update their docstrings and help texts.

  • Resolve it in the seven trainers from the model's attention implementation (identical blocks).

  • Add the require_cudnn_sdpa and require_no_cudnn_sdpa test markers, skip the CLI "auto" case on these GPUs, and add a test of the new default to each trainer.
  • This PR depends on:

  • #8553
  • <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Changes default padding for all seven trainers on H100/B200 when using SDPA, which affects batch shapes, memory, and throughput; scope is broad but behavior is gated on GPU capability and attention backend.

    > Overview

    Extends pad_to_multiple_of="auto" so it pads sequences to a multiple of 128 on NVIDIA compute capability 9.x/10.x GPUs when the loaded model uses SDPA—same motivation as on Neuron: bound cuDNN’s per-sequence-length graph cache (#8439).

    > Configs (SFT, DPO, KTO, Reward, GRPO, RLOO, Distillation) no longer collapse "auto" to None on those CUDA GPUs in __post_init__; docstrings and CLI help describe the new behavior. Trainers resolve "auto" after the model is loaded: 128 if _attn_implementation == "sdpa", otherwise None (e.g. eager or FlashAttention).

    > Tests add require_cudnn_sdpa / require_no_cudnn_sdpa, gate the CLI "auto" expectation on non–cuDNN-SDPA hardware, and add parametrized trainer tests for SDPA vs eager.

    > <sup>Reviewed by Cursor Bugbot for commit 58bf9ecad3c22d4a194e9d98bd474e054ac219c2. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 414 lines (+310 / -104) across 5 files Reviewer: qgallouedec Review duration: 4481m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 414 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.361
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8554"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 17.7% · Safe to merge
    17.7%