← Back to Pull requests

Dynamic WS sizing #770

Open
unknown opened this pull request with 378 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 20, 2026 15:31 UTC
Author

Description

Based on an idea by @zstreet87.

With the current 128 MByte WS in TE, we can still exceed that size:

<details><summary>Reproducer</summary>

"""HipKittens grouped MXFP8 GEMM falls back when its scale buffers exceed the static workspace.

DSV3 GateUP (hidden 7168 -> 2 x moe_inter 2048) with 32 local experts (EP8), forward only.
Run on gfx950 with:
  NVTE_ROCM_ENABLE_MXFP8=1 NVTE_USE_CUTLASS_GROUPED_GEMM=1 NVTE_USE_HIPKITTENS_GROUPED_GEMM=1 \
  NVTE_CUTLASS_GROUPED_GEMM_WARN_FALLBACK=1 python hk_ws_repro.py [tokens_per_expert ...]
"""
import sys

import torch
import transformer_engine.pytorch as te
from transformer_engine.common.recipe import MXFP8BlockScaling
from transformer_engine.pytorch.cpp_extensions.gemm import get_cublas_workspace_size_bytes

E, K, N = 32, 7168, 2 * 2048
layer = te.GroupedLinear(E, K, N, bias=False, params_dtype=torch.bfloat16, device="cuda")
ws = get_cublas_workspace_size_bytes()
for m in [int(a) for a in sys.argv[1:]] or [7168, 8192]:
    # HK grouped scratch (mxfp8_gemm.cpp): weight scales E*N*K/32 + activation scales tokens*K/16.
    need = E * N * K // 32 + E * m * K // 16
    print(f"--- {E} experts x {m} tokens: needs {need / 2**20:.1f} MiB, workspace "
          f"{ws / 2**20:.0f} MiB", flush=True)
    x = torch.randn(E * m, K, dtype=torch.bfloat16, device="cuda")
    with torch.no_grad(), te.autocast(enabled=True, recipe=MXFP8BlockScaling()):
        layer(x, [m] * E)
    torch.cuda.synchronize()
    del x

</details>

$ NVTE_ROCM_ENABLE_MXFP8=1 NVTE_USE_CUTLASS_GROUPED_GEMM=1 NVTE_USE_HIPKITTENS_GROUPED_GEMM=1 \
NVTE_CUTLASS_GROUPED_GEMM_WARN_FALLBACK=1 python hk_ws_repro.py

--- 32 experts x 7168 tokens: needs 126.0 MiB, workspace 128 MiB
--- 32 experts x 8192 tokens: needs 140.0 MiB, workspace 128 MiB
[HK-grouped] falling back: workspace too small
...ck_tile_mx_grouped_gemm: only supported on gfx1250. Falling back.
...nvte_multi_tensor_gemm: Fallback to cuBLAS grouped GEMM.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Infra/Build change

  • Code refactoring
  • Changes

    Please list the changes introduced in this PR:

  • Change A

  • Change B
  • Checklist:

  • I have read and followed the contributing guidelines

  • The functionality is complete

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes
  • Diff: 378 lines (+283 / -95) across 4 files Reviewer: aris134 Review duration: 61339m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 378 lines diff across 4 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    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.355
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #770"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 49.9% (MEDIUM) · Higher = larger blast radius
    49.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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 27.6% · Safe to merge
    27.6%