← Back to Pull requests

[Fix] DeepSeek-V4.1: apply the per-shape BF16 GEMM rows only in CUDA graphs #302

Closed
unknown closed this pull request without merging on Oct 22, 2026 11:40 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 10:51 UTC
Author

Problem

1. #290's thresholds were applied to eager steps.
- #290 measured the per-shape rows in CUDA graphs, but fp8_block_bf16_supported and fp8_block_splitk_config applied them to eager steps as well.

2. 33 rows is too early for three shapes.
- For 1792x5120, 4096x1280 and 5120x1024, the 33-row start came from a graph-chain microbenchmark.
- In end-to-end decode, split-K and the block GEMM are faster through 55 rows. At DSpark-4 c8 (40-row verify batches), #290 made the decode step 2.2% slower than before.

Changes

| Commit | Change |
|---|---|
| 97fc37a9 fix: apply the measured DeepSeek-V4.1 BF16 GEMM rows only in CUDA graphs | The per-shape BF16 thresholds and the split-K ranges below them now apply only while a CUDA graph is being captured. Eager steps, prefill included, go back to the pre-#290 split-K ranges and to BF16 from 512 rows. |
| 17349956 perf: start the BF16 GEMM at 60 rows for DeepSeek-V4.1 attention and wo_b | In CUDA graphs, 1792x5120, 4096x1280 and 5120x1024 switch to the BF16 GEMM at 60 rows instead of 33. Split-K covers up to 59 rows; for 5120x1024 it stops at 48 and the block GEMM takes 49-59. |

Measured end to end, as the DSpark-4 decode step time (ITL p50) with one server per run. The table compares the split-K/block GEMMs with the BF16 GEMM for these three shapes (negative: split-K/block faster). Run-to-run noise is 0.3-0.7%.

| Verify rows (c x 5) | 40 | 45 | 50 | 55 | 60 | 80 | 120 | 160 |
|---|---|---|---|---|---|---|---|---|
| split-K/block vs BF16 | -2.5% | -2.2% | -0.6% | -0.9% | +0.3% | +2.3% | +3.9% | +7.9% |

Validation

  • pytest tests/test_fp8_block_gemv_native.py tests/test_paged_mqa_logits_metadata_warmup.py tests/test_custom_op_preload.py on S5000, on the rebased branch: 45 passed.

  • New test: test_measured_rows_apply_only_in_graph_capture checks both paths. Eager steps use the pre-#290 split-K ranges and BF16 from 512 rows; captured steps use the per-shape rows.
  • Diff: 250 lines (+187 / -63) across 3 files Reviewer: yeahdongcn Review duration: 48m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 250 lines diff across 3 files
    0.39
    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.331
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #302"
    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: 39.0% (MEDIUM) · Higher = larger blast radius
    39.0%
    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: 15.4% · Safe to merge
    15.4%