Skip to content

[Relax][Analysis] Validate FuncStructInfo correctness - #16833

Closed
Lunderberg wants to merge 2 commits into
apache:mainfrom
Lunderberg:relax_analysis_validate_func_struct_info
Closed

Lunderberg wants to merge 2 commits into
apache:mainfrom
Lunderberg:relax_analysis_validate_func_struct_info

Conversation

@Lunderberg

Copy link
Copy Markdown
Contributor

Prior to this PR, the well-formed checker did not validate the FuncStructInfo annotations. While these FuncStructInfo annotations are generated during construction, they can be invalidated by CopyOnWrite(). This commit adds validation of the FuncStructInfo to the well-formed checker.

Any `FuncStructInfo` annotations should be correct.

@slyubomirsky slyubomirsky 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.

Good catch, also good to have regression tests.

@Lunderberg

Copy link
Copy Markdown
Contributor Author

Thank you!

CI has found a surprising number of failures for this check. It looks like the new check requiring the same GlobalVar and Function struct info has caught an issue with TVMScript. The GlobalVar instances are generated based solely on the function signature, where the Function instances can also infer the return type from the body.

For now, I think I'll make the check looser, using IsBaseOf instead of StructuralEqual. That would require the GlobalVar to be an accurate representation of the function, without requiring it to be a complete representation of the function.

@Lunderberg

Copy link
Copy Markdown
Contributor Author

Well, a check that finds a large number of errors is a good check to have, and a good source of cleanup. Unfortunately, I think it means that this PR will need to sit until I have time to clean them up.

The current CI failures are due to transforms that update a function's signature, but do not propagate that change to the GlobalVar. There's enough failures that it should have a common utility to resolve the mismatch, updating the GlobalVar of the function, and replacing it at all call sites. Resolving this cannot be done as part of the block builder's normalizer, because it would depend on the order in which the caller/callee are visited.

@Lunderberg

Copy link
Copy Markdown
Contributor Author

This PR has been stalled for a while, in part because there are a large number of passes that will need to be updated. The ReplaceGlobalVar function, introduced in #17202, should help to resolve these breakages. That way, when a function's signature is changed, we'd be able to easily update the GlobalVar to have the new StructInfo.

@tqchen tqchen closed this Feb 12, 2026
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.

3 participants