Closed zxybazh closed 1 month ago
Hi @zxybazh , I am facing the same issue, when I try to metaschedule a resnet-50 relay workload.
Won't fix for now. Please feel free to reopen if this reproduces.
I don't know why this issue was closed, because it reproduces for me when I was tuning for quantized ResNet-18.
After some search I found that #16239 and #15505 may be related to this bug. I tried the workaround in #15505 and although AddWriteReuseTensorCore
no longer throws ValueError: The block no longer exists in the IRModule
, now AddReadReuseTensorCore
throws ScheduleError: An error occurred in the schedule primitive 'compute-at': The scope tir.Block#0 is not a stage pipeline
. Unfortunately I have no idea where to start debugging.
@zxybazh Could you please look into this a little more? The comments in #16239 might help. Also could you see any unsoundness in the workaround in #15505? @XFPlus Have you finally found a workaround for this issue? Also have you tried #15505?
Thank you for your help.
Thanks for reporting, I think the guard proposed in #15505 could be a temporary fix but a more principled solution would be to fix tensorization rule. CC @vinx13
After some digging I discovered the root cause of this bug: TileWithTensorIntrin
in src/tir/schedule/transform.cc
calls PadEinsum
and inlines the padded input (output) to its original producer (consumer). However it is possible that one of the inputs/outputs does not need to be padded, in which case that producer (consumer) is not padded by PadEinsum
. This means that TileWithTensorIntrin
may inline blocks that are irrelevant to padding and must not be inlined.
I found that #17171 is also related to this bug, but that PR along with #16239 and #15505 did not really solve this problem.
I have fixed this by tracking which producers (consumers) are padded by PadEinsum
. I will file a PR later, and hopefully it will be able to replace #17171 and #16239.
Expected behavior
MetaSchedule Tuning Works for the given Conv2d workload
Actual behavior
Triggers an error
ValueError: The block no longer exists in the IRModule
during application of schedule rule Multi-level tiling with tensor intrin. I notcied thatstate->tensor_core_reindex_store
would point to a block that is already merged into another block via ComputeInline during application ofTileWithTensorIntrin
.Environment
Latest TVM Main
Steps to reproduce