[Bug] [TIRx] VectorizeLoop loses a let binding when scalarizing a conditional
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ó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
The failure is an assertion in src/tirx/transform/make_packed_api.cc at line 279, reached after tirx.transform.VectorizeLoop() runs. Start by running the standalone script with T.serial(4) and with T.vectorized(4), then apply only VectorizeLoop to see the lost let binding. Done means the vectorized loop compiles and the three input checks pass, with a regression test for the scalarized conditional.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
The vectorized loop below should compile and produce the same result as its serial equivalent. The first two elements should become A[i] + 3, and the last two should become A[i] + 4.
The input passes both tvm.tirx.analysis.verify_ssa and verify_well_formed.
Actual behavior
Compiling the vectorized version with the default LLVM pipeline fails in MakePackedAPI:
src/tirx/transform/make_packed_api.cc:279
TVM_FFI_ICHECK_EQ(undefined.size(), 0)
tvm.error.InternalError: Check failed: undefined.size() == 0 (1 vs. 0) :
In PrimFunc main variables (v,) are used, but are not passed in as API arguments
Applying tirx.transform.VectorizeLoop() in isolation shows the lost binding. The vector value remains bound outside the scalar fallback loop, but the conditional stores refer to a different, unbound scalar variable:
v: T.let[T.float32x4] = A[T.Ramp(0, 1, 4)] + T.Broadcast(T.float32(1.0), 4)
for i_s in range(4):
v_1 = T.float32() # Declaration only; no lane value is assigned.
if i_s < 2:
A[i_s] = v_1 + T.float32(2.0)
else:
A[i_s] = v_1 + T.float32(3.0)
The standalone script below failed with the same undefined-variable assertion in three fresh processes. Replacing only T.vectorized(4) with T.serial(4) compiled successfully in three fresh processes; each serial process checked three input arrays against the expected result.
No custom pipeline or disabled passes are needed.
Environment
- Apache TVM
0.26.dev0+source.8f328e8(source snapshot; no.gitdirectory) - Ubuntu 22.04.5, Linux
6.8.0-52-generic, x86-64 - Python
3.11.16 - LLVM
15.0.7 - Target
llvm,opt_level=2 - CPU-only reproducer; no GPU is required
Steps to reproduce
Save the following script as repro_vectorize_let.py and run:
python repro_vectorize_let.py
For the passing control, change T.vectorized(4) to T.serial(4) and run the script again.
import numpy as np
import tvm
from tvm.script import ir as I, tirx as T
@I.ir_module
class Module:
@T.prim_func(s_tir=True)
def main(A: T.Buffer((4,), "float32")):
for i in T.vectorized(4):
v: T.let[T.float32] = A[i] + T.float32(1)
if i < 2:
A[i] = v + T.float32(2)
else:
A[i] = v + T.float32(3)
assert tvm.tirx.analysis.verify_ssa(Module["main"])
assert tvm.tirx.analysis.verify_well_formed(Module["main"])
print("input validation passed", flush=True)
with tvm.transform.PassContext(opt_level=2):
executable = tvm.compile(Module, target="llvm")
print("compiled", flush=True)
for seed in [42, 9001, 20261101]:
rng = np.random.default_rng(seed)
x = rng.integers(-16, 17, size=4).astype("float32") / 64
a = tvm.runtime.tensor(x.copy(), tvm.cpu(0))
executable["main"](a)
expected = x + np.array([3, 3, 4, 4], dtype="float32")
np.testing.assert_array_equal(a.numpy(), expected)
print("three 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ờ 5 phút
- Pull request đã merge (30 ngày)
- 170
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 2 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 12 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ó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
aws-samples/sample-per-model-bedrock#782 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Google text documents are base64-encoded twiceCó thể đã có người làm @feiiiiii5 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/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 75/100
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 76/100
coveragepy/coveragepy#2364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Plugin] astrbot_plugin_sd_drawĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100