Request for batched general_gemm() (or FP8-aware torch.bmm) for non-Linear GEMM workloads
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- machine-learning, performance
Hướng nghiên cứu
Bắt đầu với general_gemm trong transformer_engine.pytorch.cpp_extensions và so sánh contract 2D của nó với các đầu vào 3D của torch.bmm. Xem xét các path hiện có của Float8Tensor và MXFP8Tensor, bao gồm việc sử dụng use_split_accumulator và hỗ trợ backward. Công việc được xem là hoàn tất khi có các FP8 GEMM theo batch với tích lũy FP32 cho workload huấn luyện được mô tả mà không lặp qua các batch slice.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
We’re accelerating triangular multiplication in a protein structure prediction model (AlphaFold-style tri-mul). The core operation is two large einsums over 4D pair representations that we’ve reshaped into batched matmuls:
# Input: (B, N, N, D) where N = 2048 (sequence length), D = 128
# After chunk, permute, reshape: (B*32, 2048, 2048)
x1 = torch.bmm(a, b.transpose(1, 2)) # B*32 independent N×N GEMMs
At N = 2048, this accounts for roughly 40% of the tri-mul compute and is heavily memory-bandwidth-bound. Currently we run in FP32 (4 bytes/element) or BF16 (2 bytes/element). MXFP8 inputs (1 byte/element) with FP32 accumulation would provide up to a 4× reduction in HBM reads, which is the dominant cost at these sizes.
However, there is currently no way to run FP8 batched matrix multiplication through TE:
te.autocast()only intercepts TE modules, nottorch.bmmFloat8Tensor/MXFP8Tensorpassed totorch.bmmsilently dequantize to full precisiongeneral_gemm()supports FP8 × FP8 withuse_split_accumulator=True, but only accepts 2D inputs — looping overB*32slices would likely negate the bandwidth savings
Related: #1910 describes the same gap for FP8 GEMM beyond te.Linear.
Describe the solution you’d like
A batched variant of general_gemm() that accepts 3D inputs and runs FP8 GEMMs across the batch dimension with FP32 accumulation:
from transformer_engine.pytorch.cpp_extensions import batched_general_gemm
# Quantize inputs to FP8
a_fp8 = mxfp8_quantizer.quantize(a_3d) # (B*32, N, N)
b_fp8 = mxfp8_quantizer.quantize(b_3d) # (B*32, N, N)
# Batched FP8 GEMM with FP32 accumulation
output = batched_general_gemm(
a_fp8,
b_fp8,
out_dtype=torch.bfloat16,
layout="NN",
use_split_accumulator=True, # FP8×FP8 multiply, FP32 accumulate
)
# output: (B*32, N, N) in BF16
Alternatively, making Float8Tensor / MXFP8Tensor dispatch torch.bmm to real FP8 tensor core GEMMs, instead of dequantizing, would also solve this.
Describe alternatives you’ve considered
- GroupedLinear: Suggested in
#1910, but it is designed for MoE-style use cases with different weights per group. Our use case is two arbitrary input tensors, not input × stored weight. It was also noted there may be significant overhead. - Looping
general_gemm()over batch slices: Functionally possible, but Python loop overhead and the lack of kernel batching would likely wipe out the memory-bandwidth gains from FP8. - Skipping
.float()and runningtorch.bmmin BF16: This is our current workaround. It gives a 2× memory reduction versus FP32, but still leaves another 2× on the table compared with FP8.
Additional context
- Targeting Blackwell (
MXFP8BlockScaling) and Hopper (DelayedScaling/CurrentScaling) - Training workload, so backward-pass support is needed
- This batched FP8 GEMM pattern would also help other workloads with non-
Linearmatmuls, including attention (unfused path), structure prediction, graph neural networks, and any model with einsum contractions reshaped tobmm - TE v1.12+
Happy to provide a minimal repro or benchmark if helpful.
- Ngôn ngữ chính
- Python
- Star
- 3.6k
- Fork
- 862
- Merge trung bình
- 4 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 64
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/TransformerEngine
-
[Bug] group_quantize_fp8_blockwise: mbarrier invalidated before other threads finish waiting on itĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/TransformerEngine#3647 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[PyTorch] fp8_cs_quantize fake implementation returns a vector inverse scale instead of a scalarCó thể đã có người làm @sanjana658 đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/TransformerEngine#3636 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] Backend selection picks FA3 for training with head_dim_qk=192 / v_head_dim=128, but FA3 backward cannot run itCó thể làm lại được @modelpath-dev đã nhận 41 ngày trước và không có pull request nào đang mở. Đang mởattention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
NVIDIA/TransformerEngine#3481 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Increase MAX_TENSOR_NUMĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NVIDIA/TransformerEngine#2189 · 7 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NVIDIA/TransformerEngine#3668 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của NVIDIA/TransformerEngine
Issue tương tự
-
`LazyFrameRemote` and `ExecuteRemote` sinks do not accept `Path`, like `LazyFrame` sinks do.Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
WingedGuardian/GENesis-AGI#3375 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
curriculum documentation quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
githubnext/gh-aw-workshop#4601 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
approved Good First Issue scope: docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày