Skip to content

Preserve output names for returned input aliases - #3018

Open
TANGBUDU wants to merge 2 commits into
microsoft:mainfrom
TANGBUDU:fix/return-alias-output-name-2714
Open

Preserve output names for returned input aliases#3018
TANGBUDU wants to merge 2 commits into
microsoft:mainfrom
TANGBUDU:fix/return-alias-output-name-2714

Conversation

@TANGBUDU

@TANGBUDU TANGBUDU commented Aug 28, 2026

Copy link
Copy Markdown

Fixes #2714.

When a graph input is returned through a local alias, use the alias name for the inserted Identity output instead of the generic return_val name. Directly returning an unchanged graph input keeps the existing naming behavior. Generated names still go through the existing uniqueness allocator.

The method audit found a missed case: Y = X; X = op.Neg(X); return Y returned the original input under the name X, not Y. Looking up the resolved ONNX name in the mutable Python symbol table incorrectly classified the value after X was rebound. The converter now checks the resolved IR value directly.

Regression coverage includes input-name rebinding, collisions with an existing input name, duplicate alias returns, ONNX checker validation, and runtime output parity. The rebinding regression fails before the follow-up fix ('X' != 'Y') and passes afterward.

Tests (2026-09-07):

  • python -m pytest onnxscript/_internal/converter_test.py -q: 56 passed, 1 skipped, 1 xfailed, 3 xpassed; 160 subtests passed, both with ONNX 1.22.0 / ONNX Runtime 1.29.0 and with ONNX 1.18.0 / ONNX Runtime 1.23.0 / ONNX IR 0.1.16.
  • lintrunner -a: no lint issues.
  • git diff --check: clean.

AI assistance was used for the source audit, patch preparation, and validation. The existing expected-failure / unexpected-pass results are reported above, not counted as ordinary passes.

@TANGBUDU

TANGBUDU commented Sep 7, 2026

Copy link
Copy Markdown
Author

Justin Chu (@justinchuby) gentle ping on this PR when you have a chance. It addresses #2714 and is ready for review. Happy to address any feedback — thanks!

Check the resolved ONNX value rather than looking its name up in the mutable Python symbol table. Cover input rebinding and collisions with existing input names, including duplicate returns and numerical parity.

Assisted-by: ChatGPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Unintuitive behavior: Returned input aliases generate Identity nodes with generic names instead of preserving Python variable names

1 participant