Skip to content

[BugFix][TIRx] Fix VerifyMemory crash for PrimFuncs without target attribute#19382

Merged
tlopex merged 1 commit into
apache:mainfrom
swjng:fix/tirx-verify-memory-no-target
Apr 10, 2026
Merged

[BugFix][TIRx] Fix VerifyMemory crash for PrimFuncs without target attribute#19382
tlopex merged 1 commit into
apache:mainfrom
swjng:fix/tirx-verify-memory-no-target

Conversation

@swjng

@swjng swjng commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Problem

VerifyMemory_ called TVM_FFI_ICHECK(target.defined()) unconditionally. When Relax lowers a model it generates host-side helper PrimFuncs (e.g. for reshape, mean) that carry no kTarget attribute. These functions hit the ICHECK and abort:

Check failed: (target.defined()) is false: Require the target attribute

This surfaces whenever tvm.compile is called on a Relax module targeting CUDA, because the Relax lowering pipeline produces target-less CPU helper functions alongside the GPU kernels.

Fix

Return {} (no errors) when target is absent. This is semantically correct: MemoryAccessVerifier::Run() is already gated on IsGPUDevice(dev_type_), so host-only functions carry no GPU memory access constraints and require no verification. The same early-exit pattern is already used for non-default calling conventions (line 184–186).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the VerifyMemory_ function in src/tirx/analysis/verify_memory.cc to skip verification for functions without a target attribute, preventing a crash. A review comment suggests refining the documentation within the code to focus on the current logic rather than the previous error state.

Comment thread src/tirx/analysis/verify_memory.cc Outdated
…tribute

VerifyMemory_ called TVM_FFI_ICHECK(target.defined()) unconditionally.
When Relax lowers a model it generates host-side helper PrimFuncs
(e.g. for reshape, mean) that carry no kTarget attribute.
These functions hit the ICHECK and abort.

Return {} (no errors) when target is absent. This is semantically
correct: MemoryAccessVerifier::Run() is already gated on
IsGPUDevice(dev_type_), so host-only functions carry no GPU memory
access constraints and require no verification.
@swjng swjng force-pushed the fix/tirx-verify-memory-no-target branch from bb1b582 to 5f22cd7 Compare April 10, 2026 15:16
@tlopex tlopex merged commit 3d9cf2e into apache:main Apr 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants