You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "XYZboom (via GitHub)" <gi...@apache.org> on 2026/07/25 00:59:36 UTC
[I] [Bug] `relax.build` crashes with an `AttributeError` during the dlight GPU scheduling pass [tvm]
XYZboom opened a new issue, #20047:
URL: https://github.com/apache/tvm/issues/20047
### Expected behavior
`relax.build(mod, target="cuda")` should compile successfully for any valid Relax IR module containing `relax.op.nn.conv2d`. The compiled module should execute and produce correct convolution results.
### Actual behavior
`relax.build` crashes with an `AttributeError` during the dlight GPU scheduling pass:
```
AttributeError: 'FloorDiv' object has no attribute 'value'
### Environment
- **OS**: Linux (x86_64, conda environment)
- **GPU**: NVIDIA GeForce RTX 3080 Ti (12GB VRAM)
- **CUDA driver**: 580.76.05
- **TVM version**: 0.25.0.post1 (installed via pip)
- **Target**: `cuda` (GPU compilation)
- **Python**: 3.12
### Steps to reproduce
```python
from tvm import relax
bb = relax.BlockBuilder()
v = relax.Var("v", relax.TensorStructInfo(
shape=relax.ShapeExpr([1, 1, 3, 10]), dtype="float32"))
w = relax.Var("w", relax.TensorStructInfo(
shape=relax.ShapeExpr([1, 1, 1, 2]), dtype="float32"))
with bb.function("f", [v, w]):
c = bb.emit(relax.op.nn.conv2d(v, w,
strides=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1))
bb.emit_func_output(c)
mod = bb.get()
ex = relax.build(mod, target="cuda")
```
### Triage
* bug
* CUDA
* dlight
* gemv
* conv2d
* needs-triage
* needs-triage
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [I] [Bug] `relax.build` crashes with an `AttributeError` during the dlight GPU scheduling pass [tvm]
Posted by "XYZboom (via GitHub)" <gi...@apache.org>.
XYZboom commented on issue #20047:
URL: https://github.com/apache/tvm/issues/20047#issuecomment-5078360636
A variant:
```python
import tvm
from tvm import relax
import numpy as np
bb = relax.BlockBuilder()
# Minimal trigger: single conv2d, N=1, C_in=1, C_out=1, output spatial dims > 1
v_input = relax.Var("input", relax.TensorStructInfo(shape=relax.ShapeExpr([1, 1, 6, 8]), dtype="float32"))
v_weight = relax.Var("weight", relax.TensorStructInfo(shape=relax.ShapeExpr([1, 1, 1, 3]), dtype="float32"))
with bb.function("main", [v_input, v_weight]):
v_out = bb.emit(relax.op.nn.conv2d(v_input, v_weight, strides=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1))
bb.emit_func_output(v_out)
mod = bb.get()
ex = relax.build(mod, target="cuda")
vm = relax.VirtualMachine(ex, tvm.cuda())
np_input = np.random.uniform(0.0, 1.0, size=(1, 1, 6, 8)).astype(np.float32)
np_weight = np.random.uniform(-0.1, 0.1, size=(1, 1, 1, 3)).astype(np.float32)
result = vm["main"](tvm.runtime.tensor(np_input, device=tvm.cuda()), tvm.runtime.tensor(np_weight, device=tvm.cuda()))
print("Execution: OK")
```
Error log that has the same stack but different exception:
```txt
Target cuda missing 'max_shared_memory_per_block'; using 49152 bytes.
Traceback (most recent call last):
File "/root/autodl-tmp/data/maybeBug/tvm_gemv_assert_value/main.py", line 17, in <module>
ex = relax.build(mod, target="cuda")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/lib/python3.12/site-packages/tvm/relax/vm_build.py", line 270, in build
mod = relax_pipeline(mod)
^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 171, in __call__
return _ffi_transform_api.RunPass(self, mod)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python/tvm_ffi/cython/function.pxi", line 968, in tvm_ffi.core.Function.__call__
File "<unknown>", line 0, in TVMFFIPyCallback(void*, TVMFFIAny const*, int, TVMFFIAny*)
File "<unknown>", line 0, in TVMFFIPyCallManager::ForwardPyErrorToFFI()
File "<unknown>", line 0, in TVMFFICyErrorSetRaisedFromPyError(_object*)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/relax/backend/cuda/pipeline.py", line 87, in _pipeline
mod = seq(mod)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 171, in __call__
return _ffi_transform_api.RunPass(self, mod)
File "python/tvm_ffi/cython/function.pxi", line 968, in tvm_ffi.core.Function.__call__
File "<unknown>", line 0, in TVMFFIPyCallback(void*, TVMFFIAny const*, int, TVMFFIAny*)
File "<unknown>", line 0, in TVMFFIPyCallManager::ForwardPyErrorToFFI()
File "<unknown>", line 0, in TVMFFICyErrorSetRaisedFromPyError(_object*)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 238, in _pass_func
return inst.transform_module(mod, ctx)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/base/transform.py", line 70, in transform_module
sch = _apply_rules(func, target, self.rules, tunable=False)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/base/transform.py", line 88, in _apply_rules
space = rule.apply(func, target, tunable)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 79, in apply
return self.sch_inner_reduction(sch, target, block, vector_input_buffers, epilogue)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 412, in sch_inner_reduction
return apply(
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 228, in apply
assert sch.get(ts_o).extent.value == 1
AssertionError
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [I] [Bug] `relax.build` crashes with an `AttributeError` during the dlight GPU scheduling pass [tvm]
Posted by "XYZboom (via GitHub)" <gi...@apache.org>.
XYZboom commented on issue #20047:
URL: https://github.com/apache/tvm/issues/20047#issuecomment-5076460005
error:
```txt
Target cuda missing 'max_shared_memory_per_block'; using 49152 bytes.
Traceback (most recent call last):
File "/root/autodl-tmp/data/AIFuzzerData/tvm/20047/main.py", line 26, in <module>
ex = relax.build(mod, target="cuda")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/lib/python3.12/site-packages/tvm/relax/vm_build.py", line 270, in build
mod = relax_pipeline(mod)
^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 171, in __call__
return _ffi_transform_api.RunPass(self, mod)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python/tvm_ffi/cython/function.pxi", line 968, in tvm_ffi.core.Function.__call__
File "<unknown>", line 0, in TVMFFIPyCallback(void*, TVMFFIAny const*, int, TVMFFIAny*)
File "<unknown>", line 0, in TVMFFIPyCallManager::ForwardPyErrorToFFI()
File "<unknown>", line 0, in TVMFFICyErrorSetRaisedFromPyError(_object*)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/relax/backend/cuda/pipeline.py", line 87, in _pipeline
mod = seq(mod)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 171, in __call__
return _ffi_transform_api.RunPass(self, mod)
File "python/tvm_ffi/cython/function.pxi", line 968, in tvm_ffi.core.Function.__call__
File "<unknown>", line 0, in TVMFFIPyCallback(void*, TVMFFIAny const*, int, TVMFFIAny*)
File "<unknown>", line 0, in TVMFFIPyCallManager::ForwardPyErrorToFFI()
File "<unknown>", line 0, in TVMFFICyErrorSetRaisedFromPyError(_object*)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/ir/transform.py", line 238, in _pass_func
return inst.transform_module(mod, ctx)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/base/transform.py", line 70, in transform_module
sch = _apply_rules(func, target, self.rules, tunable=False)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/base/transform.py", line 88, in _apply_rules
space = rule.apply(func, target, tunable)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 79, in apply
return self.sch_inner_reduction(sch, target, block, vector_input_buffers, epilogue)
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 412, in sch_inner_reduction
return apply(
File "/root/miniconda3/lib/python3.12/site-packages/tvm/s_tir/dlight/gpu/gemv.py", line 228, in apply
assert sch.get(ts_o).extent.value == 1
AttributeError: 'FloorDiv' object has no attribute 'value'
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [I] [Bug] `relax.build` crashes with an `AttributeError` during the dlight GPU scheduling pass [tvm]
Posted by "Nanmur (via GitHub)" <gi...@apache.org>.
Nanmur commented on issue #20047:
URL: https://github.com/apache/tvm/issues/20047#issuecomment-5653557665
Thanks for the reproducer. I submitted #20330 to make the GEMV rule decline spatial-tile configurations whose outer extent cannot be proven to be one, allowing the GPU Fallback rule to schedule the function instead of crashing on `FloorDiv.value` or the follow-up assertion. The PR includes a regression test based on the reported convolution shape.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org