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 天内回复