Quantized quantize/dequantize kernels abort the process on a bfloat16 input or output
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
研究方向
Start with kernels/quantized/cpu/op_quantize.cpp and op_dequantize.cpp, especially the four dispatches named in the issue. Compare their dtype handling for Half with the failing BFloat16 cases, then inspect the C++ tests for these quantized operators. Done means all five reproduced operations return successfully for bfloat16 and match eager PyTorch; a linked pull request is already open.
由索引模型根據 Issue 內容生成。
描述
🐛 Describe the bug
The quantized_decomposed kernels in kernels/quantized/cpu handle Half but not BFloat16. quantize_per_tensor_out and quantize_per_channel_out dispatch their input over ET_FORALL_FLOATH_TYPES, and dequantize_per_tensor_out and dequantize_per_channel_out dispatch their output over ET_FORALL_FLOATH_TYPES_WITH. A bfloat16 input or out_dtype falls through to ET_CHECK_MSG(false, "Unhandled ... dtype"), so the process aborts instead of execute() returning an error. Eager PyTorch runs the same program. I found this while comparing the runtime's outputs with eager on small exported programs.
import torch
import executorch.kernels.quantized # registers the out variants
from executorch.exir import to_edge
from executorch.runtime import Runtime
class M(torch.nn.Module):
def forward(self, t):
return torch.ops.quantized_decomposed.dequantize_per_tensor(
t, 0.25, -3, -128, 127, torch.int8, out_dtype=torch.bfloat16
)
x = torch.tensor([-128, 0, 5, 127], dtype=torch.int8)
prog = to_edge(torch.export.export(M(), (x,))).to_executorch()
Runtime.get().load_program(prog.buffer).load_method("forward").execute([x])
[op_dequantize.cpp:321] In function dequantize_per_tensor_out(), assert failed (false): Unhandled output dtype 15
The process is then killed by SIGABRT. The same happens for quantize_per_tensor with a bfloat16 input (op_quantize.cpp:346, Unhandled input dtype 15), quantize_per_channel with a bfloat16 input (op_quantize.cpp:630), and dequantize_per_channel and dequantize_per_token with a bfloat16 output (op_dequantize.cpp:517). The Half versions of all five calls run and match eager.
I would expect bfloat16 to be handled like Half. I have a small fix that adds BFloat16 to these four dispatches, with C++ tests, and will open a PR linked to this issue.
Versions
ExecuTorch built from main at 0e7e80e (Python bindings and quantized_ops_aot_lib built from source), PyTorch 2.15.0+cpu, Python 3.12.3, Ubuntu 24.04 on WSL2, x86_64.
This issue was written with the help of Claude Code (Anthropic); I verified the reproduction.
- 主要語言
- Python
- 星號
- 5.2k
- 分支
- 1.3k
- 平均合併
- 1 天 7 小時
- 30 天內合併 PR
- 644
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
pytorch/executorch 的其他 Issue
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decomposition可能已有人在做 @Eureka-Zhang 於 7 天前認領。 未關閉module: exir
難度 2/5 1-3 小時 新手友好度 66/100
pytorch/executorch#25620 ·
維護者通常 1 天內回覆
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_norm可能已有人在做 @psiddh 於 21 天前認領。 未關閉bug module: qnn partner: qualcomm
難度 2/5 1-3 小時 新手友好度 74/100
pytorch/executorch#24434 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
enhancement triaged
難度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
維護者通常 1 天內回覆
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scale可能已有人在做 @AxelNoun 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 35/100
pytorch/executorch#25873 ·
維護者通常 1 天內回覆
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 Max可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug module: quantization module: xnnpack
難度 4/5 3-5 天 新手友好度 43/100
pytorch/executorch#25854 ·
維護者通常 1 天內回覆
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"可能已有人在做 @cestercian 今天認領。 未關閉comp/cli P2 type/bug
難度 2/5 1-3 小時 新手友好度 75/100
NousResearch/hermes-agent#162259 · 1 則留言 ·
維護者通常 1 天內回覆
-
upstream update
難度 2/5 1-3 小時 新手友好度 72/100
conan-io/conan-center-index#31597 ·
維護者通常 1 天內回覆
-
bug enhancement
難度 1/5 1 小時以內 新手友好度 90/100
AOSSIE-Org/PictoPy#1802 · 2 則留言 ·
維護者通常 3 天內回覆
-
community-request
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA-NeMo/Run#727 ·
維護者通常 1 天內回覆