Phoslight commented on code in PR #18120:
URL: https://github.com/apache/tvm/pull/18120#discussion_r2209004802


##########
tests/python/relax/test_dataflow_rewriter.py:
##########
@@ -1169,9 +1171,9 @@ def expected(
             ],
         )
 
-        v = embedded_qkv_tuple[2]
         q_embed = embedded_qkv_tuple[0]
         k_embed = embedded_qkv_tuple[1]
+        v = embedded_qkv_tuple[2]

Review Comment:
   Got some time this week to reinvestigate this issue, and it turns out I 
initially missed the root cause, which is an undefined behavior caused by 
out-of-bounds iterator access.
   
   The test environment I used earlier was macOS, where the test consistently 
fails. On Linux, as you pointed out, the test passes.
   
   The root issue is that indices.begin() + (j + 1) can exceed indices.end(), 
leading to undefined behavior. In this case, `indices.size()` is `3`, but 
`info_vec.size()` is `7`, and `j` can be `5`, causing `indices.begin() + (j + 
1)` to go out of bounds. In the worst case, I think `std::all_of` may never 
terminate.
   
   Verified all tests from the Rewriter PR, passing on both macOS and Linux.
   
   Hopefully this explains it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to