MXFP8 quantize_ writes out of bounds of compact unswizzled scale buffers when rows are not a multiple of 64
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Start with the reproducer in the issue: it runs on a Blackwell GPU and should print 0 / 0 once fixed, not 256 / 256. Find where MXFP8Tensor.quantize_() checks scale_inv shapes against get_scale_shape(), and where the generic fp32 quantize kernel stores scales per 64-row chunk. Done means out-of-bounds scale writes stop for non-multiple-of-64 rows, either by bounds-checking the stores or by rejecting compact scales with an error. Confirm with the canary test and the existing MXFP8 tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
MXFP8Tensor.quantize_() with with_gemm_swizzled_scales=False accepts caller-provided compact scale_inv buffers ((rows, cols/32) and (rows/32, cols)), but the generic quantize kernel stores a scale for every row of its 64-row chunk. When rows is not a multiple of 64 it writes beyond the end of the compact buffers. #3518 reports the GEMM side of the same contract (GEMM rejects compact scales); its 64x64 example stays in bounds, which is why quantize_ appeared to accept compact scales there.
Environment. TE 2.20.2 (transformer-engine, -cu13, -torch), GB200 (sm_100), fp32 source. bf16 sources take the specialized kernels, which stay in bounds.
Observed. With a canary buffer after each compact scale view, a (32, 256) tensor writes 256 bytes beyond the rowwise view and 256 beyond the columnwise view (rows 32-63 of the 64-row chunk); (96, 128) writes rows 96-127; (64, 64) and other row counts that are multiples of 64 stay in bounds. When cols is not a multiple of 128 (e.g. (512, 96)) the columnwise view's contents are also wrong because the kernel assumes the padded column stride.
Impact. Megatron Core's MFSDP v2 keeps MXFP8 scales in compact per-rank planes; quantizing a 32-row shard zeroed the next rank's scales or raised an illegal memory access when the view ended the allocation. A Megatron-side fix (quantize into padded scales) is NVIDIA/Megatron-LM#8247.
Expected. One of:
- Honour the compact
scale_invshape: bounds-check the scale stores on rows as well as columns, so the kernel writes onlyrows x cols/32rowwise androws/32 x colscolumnwise scales. Compact unswizzled scales then become a supported input on the quantize side (the direction #3518 asks for on the GEMM side). - Validate the scale shapes before launching the kernel: if
scale_invorcolumnwise_scale_invdoes not match the padded shape fromget_scale_shape(), raise an error instead of quantizing, the same way GEMM already rejects compact scales.
Reproducer (single Blackwell GPU; prints 256 / 256 on TE 2.20.2, expected 0 / 0):
import torch
import transformer_engine.pytorch # noqa: F401
import transformer_engine_torch as tex
from transformer_engine.pytorch.tensor.mxfp8_tensor import MXFP8Quantizer, MXFP8Tensor
rows, cols, canary, pad = 32, 256, 0xAA, 1 << 16
quantizer = MXFP8Quantizer(tex.DType.kFloat8E4M3)
n_rs, n_cs = rows * (cols // 32), (rows // 32) * cols
rs_buf = torch.full((n_rs + pad,), canary, dtype=torch.uint8, device="cuda")
cs_buf = torch.full((n_cs + pad,), canary, dtype=torch.uint8, device="cuda")
tensor = MXFP8Tensor(
shape=(rows, cols), dtype=torch.bfloat16, device="cuda",
rowwise_data=torch.empty((rows, cols), dtype=torch.uint8, device="cuda"),
columnwise_data=torch.empty((rows, cols), dtype=torch.uint8, device="cuda"),
rowwise_scale_inv=rs_buf[:n_rs].view(rows, cols // 32),
columnwise_scale_inv=cs_buf[:n_cs].view(rows // 32, cols),
fp8_dtype=tex.DType.kFloat8E4M3, quantizer=quantizer, with_gemm_swizzled_scales=False,
)
tensor.quantize_(torch.randn(rows, cols, device="cuda")) # fp32 source -> generic kernel
torch.cuda.synchronize()
print(int((rs_buf[n_rs:] != canary).sum()), int((cs_buf[n_cs:] != canary).sum()))
- Ngôn ngữ chính
- Python
- Star
- 3.6k
- Fork
- 862
- Merge trung bình
- 4 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 62
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ể làm lại được @sanjana658 đã nhận 8 ngày trước và không có pull request nào đang mở. Đ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 42 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ự
-
Questions crashes on a real SQuAD2 no-answer predictionCó thể đã có người làm @HuaTNA đã nhận hôm nay. Đang mở
Độ 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
-
GST is read as Gulf Standard Time (UTC+4) instead of Guam Standard Time (UTC+10)Có thể đã có người làm @yang00333 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DOI-USGS/dataretrieval-python#454 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
area:core-platform effort:S priority:P3 status:in-review type:test
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 80/100
randomparity/kdive#3246 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Requantification library converts m/z to mass with the hydrogen-atom mass instead of the proton massĐang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
nf-core/metaboigniter#130 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
netbox status: needs owner type: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
netbox-community/netbox#23412 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày