[Bug] [LLVM] FP16 asin, acos, asinh and acosh fail code generation as unknown intrinsics
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
First run the supplied reproduction for each operator, then read src/target/intrin_rule.h, especially FloatSuffix and the DispatchPureExtern registrations. Trace how the LLVM pipeline lowers these FP16 calls, using the FP32 and explicit-promotion cases as controls. Done means direct FP16 calls to asin, acos, asinh, and acosh compile for LLVM and pass the supplied numerical checks.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
Accepted FP16 expressions for these floating-point operators should lower for LLVM, for example by promoting the calculation to FP32 and casting the result back to FP16. The explicit promotion in the script below compiles and produces the expected FP16 values.
Actual behavior
The default LLVM compilation pipeline leaves the FP16 call unlowered and fails in code generation:
unknown intrinsic ir.Op(... name="tirx.asinh" ...)
The same error occurs for tirx.asin, tirx.acos and tirx.acosh. Each direct FP16 case failed in three fresh Python processes. Both direct FP32 and explicit FP16-input/FP32-calculation/FP16-output controls compiled in three fresh processes per operator and checked three legal inputs per process against NumPy.
No custom schedule, disabled pass, or StmtSimplify ablation is required. Inputs for acosh are in [1.25, 4]; inputs for asin and acos are in [-0.75, 0.75], so these controls stay inside their mathematical domains.
The source registrations use DispatchPureExtern. FloatSuffix in src/target/intrin_rule.h selects function names for float32 and float64, and returns an empty name for float16. This appears to explain why the FP16 intrinsic reaches LLVM code generation without a supported lowering.
Environment
- Apache TVM 0.26.dev0+source.8f328e8 (source snapshot)
- Ubuntu 22.04.5, Linux 6.8.0-52-generic, x86-64
- Python 3.11.16, LLVM 15.0.7
- Target llvm; no GPU required
Steps to reproduce
Save as repro.py and run:
# Fails with an unknown tirx.asinh intrinsic:
python repro.py asinh
# Both compile and verify three inputs:
python repro.py asinh --promote
python repro.py asinh --dtype float32
# asin, acos and acosh reproduce with the same arguments.
import argparse
import numpy as np
import tvm
from tvm import te, tirx
p = argparse.ArgumentParser()
p.add_argument("op", choices=["asin", "acos", "asinh", "acosh"])
p.add_argument("--dtype", choices=["float16", "float32"], default="float16")
p.add_argument("--promote", action="store_true")
args = p.parse_args()
x = te.placeholder((8,), dtype=args.dtype, name="x")
op = getattr(tirx, args.op)
def compute(i):
value = x[i].astype("float32") if args.promote else x[i]
result = op(value)
return result.astype(args.dtype) if args.promote else result
y = te.compute((8,), compute, name="y")
mod = tvm.IRModule({"main": te.create_prim_func([x, y])})
executable = tvm.compile(mod, target="llvm")
for seed in [42, 9001, 20261103]:
rng = np.random.default_rng(seed)
lo, hi = (1.25, 4.0) if args.op == "acosh" else (-0.75, 0.75)
values = rng.uniform(lo, hi, (8,)).astype(args.dtype)
actual = tvm.runtime.empty((8,), args.dtype, tvm.cpu())
executable["main"](tvm.runtime.tensor(values, tvm.cpu()), actual)
expected = getattr(np, "arc" + args.op[1:])(
values.astype("float64")
).astype(args.dtype)
rtol, atol = (2e-3, 5e-4) if args.dtype == "float16" else (3e-6, 1e-7)
np.testing.assert_allclose(actual.numpy(), expected, rtol=rtol, atol=atol)
print("three legal inputs passed", flush=True)
Triage
- needs-triage
- type: bug
- Ngôn ngữ chính
- Python
- Star
- 13.9k
- Fork
- 4k
- Merge trung bình
- 8 giờ 2 phút
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 apache/tvm
-
needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64Có thể đã có người làm @tandede đã nhận 1 ngày trước. Đang mởneeds-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage type: bug
Độ 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
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot productsCó thể đã có người làm @hiyufan đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/tvm#20595 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/deep-rl-class#723 ·
-
[tool] bug: Qwen3 XML tool parser raises on `...` argument values (Ellipsis is not JSON serializable)Có thể đã có người làm @super-yuki đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
verl-project/verl#8559 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
TencentCloud/octop-harness#228 ·
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 78/100
google/osv-scalibr#2585 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
NousResearch/hermes-agent#149323 ·
Maintainer thường phản hồi trong vòng 1 ngày