Skip to content

[Lang] Fix annotated tuple returns in inline functions - #8804

Open
tianrking wants to merge 3 commits into
taichi-dev:masterfrom
tianrking:codex/fix-annotated-tuple-returns
Open

tianrking wants to merge 3 commits into
taichi-dev:masterfrom
tianrking:codex/fix-annotated-tuple-returns

Conversation

@tianrking

@tianrking tianrking commented Oct 4, 2026 •

Copy link
Copy Markdown

Issue: Fixes #8457

Brief Summary

Inline ti.func and ti.pyfunc calls with an annotated tuple return raise TypeError: 'tuple' object does not support item assignment when the existing return conversion casts a scalar element. For example, an annotated scalar/Vector pair fails during compilation.

Temporarily make tuple return data mutable while applying the existing casts, then restore the tuple. The regression coverage checks both decorators, the supported tuple annotation spellings, scalar positions, mixed Vector/Matrix/Struct results, forwarded returns, and existing container/single-return/Python-scope behavior.

Walkthrough

  • Add the conversion and restoration in the inline-function branch of build_Return.
  • Add 25 native CPU cases, including 14 cases that fail on the original implementation and 11 controls.

Validation

  • Original implementation RED: 14 distinct regression cases fail at the original tuple assignment, 11 controls and 79 existing frontend cases pass. The custom xdist runner also reports 14 duplicate worker-exit failures. This source-built run used Python 3.12.14.
  • Exact final source validation, commit 3b1c3279dd781ba923f9f76d7defe973fe5d2583, Ubuntu 22.04, Python 3.11.16, LLVM 15.0.4: 25 regressions, 79 frontend cases, and 239 C++ cases pass; the full regular CPU selection has 2,412 passed / 258 skipped, and the serial selection has 7 passed / 1 skipped. Black, Pylint, whitespace, and end-of-file hooks pass. Imported native core reports the full final SHA, and pre/post-hook source blobs match that commit.
  • Later source-proof supplement, on the same unchanged commit and environment, records actual raw SHA-256 manifests before tests, after the last native test, and after hooks. All 12,275 tracked files, 20 gitlinks, and native core/C++ binary hashes remain identical; HEAD/index and tracked diffs are clean. The 25 regressions, 79 frontend cases, 239 C++ cases, serial selection, and hooks pass again. However, its regular CPU selection exits 1: 2,411 passed / 258 skipped, with one distinct failure in test_inner_loops_local_variable_fixed_stack_size_kernel_grad[arch=x64], RuntimeError: argument not found at kernel_impl.py:702, plus a duplicate worker-exit report. This later run is not an overall GREEN result; its cause is not established. The earlier successful run did not contain these full raw manifests, and the supplement is not presented as a historical receipt for it.
  • The same final job separately builds baseline ba0e81dce559fb63a5958bf82feb1d00c55c02fe. Its regular CPU result is 2,386 passed / 258 skipped / 1 failed, exit 1: a worker terminates while running test_sparse_matrix_nonsymmetric_multiplication[arch=x64-dtype3-row_major]. This baseline failure is retained; no causal claim is made about it.
  • Both final-job builds use Rich 13.9.4, Twine 6.2.0, and scikit-build 0.19.1, with pip check passing. Full CPU selections exclude optional Torch/Paddle integrations and separate serial-marked cases; no failure-specific exclusion or -r retry is added. Earlier Python 3.12 exploratory runs failed and are retained separately: first, second, third. The third run's formal core had a stale baseline stamp and is not accepted as final-source proof.

The validation helper and dependency constraints are confined to the public fork and are outside this two-file patch. GPU behavior was not validated.

AI assistance was used for investigation, implementation, and test authoring. The reported tests use Taichi's native source builds and existing runners.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

This branch has not been deployed

No deployments
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.

Multiple return type hint with @ti.func not working on 1.7

1 participant