Skip to content

[IR][Relax] Include expression types in structural identity#19933

Open
tqchen wants to merge 1 commit into
apache:mainfrom
tqchen:expr-type-structural-identity
Open

[IR][Relax] Include expression types in structural identity#19933
tqchen wants to merge 1 commit into
apache:mainfrom
tqchen:expr-type-structural-identity

Conversation

@tqchen

@tqchen tqchen commented Jul 3, 2026

Copy link
Copy Markdown
Member

Rationale

After PrimExpr and Expr share one typed expression hierarchy, expression types are part of semantic identity. Structurally identical syntax with different types compare and hash differently, while source spans remain diagnostic metadata.

Invariant

ExprNode::ty participates in structural equality and hashing by default. GlobalVar and Relax variables retain their symbol identity rules. tirx.PrimFunc compares and hashes authoritative source fields while excluding its derived type cache until all transformation paths maintain that cache eagerly. Nested symbolic-shape rendering is isolated from outer diagnostic configuration so diagnostic context cannot become script-token content.

Changes

  • include expression types in generic structural equality and hashing
  • preserve GlobalVar and Relax variable identity plus definition-safe SeqExpr traversal
  • compare and hash PrimFunc from authoritative fields while excluding its stale derived type cache
  • normalize narrow Relax construction and expected-fixture types exposed by stricter identity
  • isolate nested symbolic-shape token rendering from outer printer configuration

@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 updates TVM's structural equality and hashing behavior to include the expression type (ty) by default, while defining custom equality and hashing overrides for specific nodes like GlobalVarNode and SeqExprNode. It also updates Python operator helpers to handle integer device indices, refactors PrimFunc construction in the distributed lowering pass, and updates corresponding tests to reflect the new structural equality traversal paths. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@tqchen tqchen force-pushed the expr-type-structural-identity branch 2 times, most recently from 99c4c27 to b04e58c Compare July 3, 2026 23:09
After unifying PrimExpr and Expr, expression types are part of
semantic identity while source spans remain diagnostic metadata. Include
types in generic equality and hashing, preserve symbol-specific identity
and definition-safe traversal, and exclude tirx.PrimFunc's derived type
cache until transformation paths maintain it eagerly.

Narrow Relax construction and expected fixtures now preserve the types
exposed by stricter identity. Nested symbolic-shape rendering uses an
independent configuration so outer diagnostics cannot alter script tokens.
@tqchen tqchen force-pushed the expr-type-structural-identity branch from 4447d68 to 21828f8 Compare July 4, 2026 02:08
@tqchen

tqchen commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

rerun ci

@tqchen

tqchen commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@tvm-bot rerun ci

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Failed to re-run CI in https://github.com/apache/tvm/actions/runs/28692271196

Details
Traceback (most recent call last):
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 588, in comment_failure
    raise item
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 694, in run
    pr.rerun_jenkins_ci()
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 547, in rerun_jenkins_ci
    post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
  File "/home/runner/work/tvm/tvm/ci/scripts/jenkins/git_utils.py", line 54, in post
    with request.urlopen(req, data) as response:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway

with response

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>

@tqchen

tqchen commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@tvm-bot rerun ci

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Failed to re-run CI in https://github.com/apache/tvm/actions/runs/28692313409

Details
Traceback (most recent call last):
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 588, in comment_failure
    raise item
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 694, in run
    pr.rerun_jenkins_ci()
  File "/home/runner/work/tvm/tvm/ci/scripts/github/github_tvmbot.py", line 547, in rerun_jenkins_ci
    post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
  File "/home/runner/work/tvm/tvm/ci/scripts/jenkins/git_utils.py", line 54, in post
    with request.urlopen(req, data) as response:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway

with response

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>

@tqchen

tqchen commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@tvm-bot rerun ci

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.

1 participant