Skip to content

fix(language): Bind pl.create_tile to one function in both namespaces - #2266

Open
Hzfengsy wants to merge 1 commit into
hw-native-sys:mainfrom
Hzfengsy:issue-2265-unify-create-tile-namespace
Open

fix(language): Bind pl.create_tile to one function in both namespaces#2266
Hzfengsy wants to merge 1 commit into
hw-native-sys:mainfrom
Hzfengsy:issue-2265-unify-create-tile-namespace

Conversation

@Hzfengsy

@Hzfengsy Hzfengsy commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

create_tile resolved to two different functions:

Namespace Resolved to Signature
pypto.language.create_tile op/tile_ops.py (create_tile = create) (shape, dtype, target_memory=Vec, transpose=None, *, flat_layout=None)
pypto.language.op.create_tile op/unified_ops.py (shape, dtype, target_memory=Vec)

The DSL parser resolves unified pl.<op> calls against pypto.language.op, so inside a @pl.function body it got the 3-parameter forwarder and rejected transpose= / flat_layout= — parameters that inspect.signature, IDE autocomplete and the docstring all advertise on the pl.create_tile a user can reach everywhere else.

The unified block is imported after tile_ops so genuine Tensor/Tile dispatchers (abs, the bitwise family) win. That rationale never applied here: create_tile is Tile-only — the Tensor counterpart is a separately named create_tensor — and unified_ops.create_tile performed no dispatch at all. It was a pure forwarder whose only effect was to narrow the signature.

Fix: delete the forwarder rather than widen it. Widening fixes today's symptom but leaves the duplicate definition in place, so the next parameter added to tile_ops.create reintroduces the identical bug. tile_ops.create_tile already aliases create, so the name stays exported from both namespaces.

Changes

File Change
python/pypto/language/op/unified_ops.py Remove the forwarder, its __all__ entry, and the now-unused MemorySpace import
python/pypto/language/op/__init__.py Import create_tile from tile_ops; correct both rationale comments
tests/ut/language/test_unified_ops.py Namespace guard + single-binding test + transpose / flat_layout regressions
docs/{en,zh}/user/02-operation_reference.md Real signature and transpose / flat_layout semantics

create_tile was the only name exported under both namespaces that resolved to two different objects — this was isolated, not systemic. The pld / pld.op namespaces have no equivalent divergence.

Testing

  • All tests pass — full tests/ut: 8579 passed, 2 skipped. The one failure, test_ir_trace.py::test_installed_console_script_preserves_main_exit_codes, asserts a pypto-ir-trace console script exists in the environment; it is byte-identical on main and unaffected by this change.
  • Code review completed
  • Documentation updated

test_namespaces_agree_on_shared_names asserts every callable exported from both pypto.language and pypto.language.op resolves to the same object, so any future shadow of this class fails loudly. It was verified to fail against the pre-fix state.

The two op regressions assert on the emitted layout (slayout=col_major / none_box) rather than only that the call parses, so they also catch the failure mode where a kwarg is accepted and then silently dropped.

Related Issues

Fixes #2265

Fixes hw-native-sys#2265

`create_tile` resolved to two different functions. `pypto.language`
imported it from `.op.tile_ops` (the `create_tile = create` alias, which
accepts `transpose` and the keyword-only `flat_layout`), while
`pypto.language.op` imported it from `.unified_ops`, whose forwarder
declared only `(shape, dtype, target_memory)`.

The DSL parser resolves unified `pl.<op>` calls against
`pypto.language.op`, so inside a `@pl.function` body it got the narrow
forwarder and rejected `transpose=` / `flat_layout=` — parameters that
`inspect.signature`, IDE autocomplete and the docstring all advertise on
the `pl.create_tile` a user can reach outside the parser.

The unified block is imported after `tile_ops` so genuine Tensor/Tile
dispatchers (`abs`, the bitwise family) win. That rationale never applied
here: `create_tile` is Tile-only — the Tensor counterpart is a separately
named `create_tensor` — and `unified_ops.create_tile` did no dispatch at
all. It was a pure forwarder whose only effect was to narrow the
signature.

Delete the forwarder rather than widening it. Widening fixes today's
symptom but leaves the duplicate definition, so the next parameter added
to `tile_ops.create` reintroduces the identical bug. `tile_ops.create_tile`
already aliases `create`, so the name stays exported from both namespaces.

Add `test_namespaces_agree_on_shared_names`, which asserts every callable
exported from both `pypto.language` and `pypto.language.op` resolves to the
same object, so any future shadow of this class fails loudly.
Copilot AI review requested due to automatic review settings August 3, 2026 10:57

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68144e21-b3ea-4877-aeff-d3f7aeed88c6

📥 Commits

Reviewing files that changed from the base of the PR and between 6730e96 and 7c61a70.

📒 Files selected for processing (5)
  • docs/en/user/02-operation_reference.md
  • docs/zh/user/02-operation_reference.md
  • python/pypto/language/op/__init__.py
  • python/pypto/language/op/unified_ops.py
  • tests/ut/language/test_unified_ops.py

📝 Walkthrough

Walkthrough

The change removes the shadowing unified create_tile, keeps the tile_ops implementation in both namespaces, documents transpose and flat_layout, and adds tests for alias identity and generated layouts.

Changes

create_tile namespace alignment

Layer / File(s) Summary
Document create_tile parameters
docs/en/user/02-operation_reference.md, docs/zh/user/02-operation_reference.md
The operation references document default Mem.Vec, transpose, and keyword-only flat_layout parameters for promoted and tile-level creation.
Remove the unified create_tile shadow
python/pypto/language/op/__init__.py, python/pypto/language/op/unified_ops.py
create_tile remains sourced from tile_ops; the unified forwarder and unused MemorySpace import are removed.
Validate aliases and layouts
tests/ut/language/test_unified_ops.py
Tests verify namespace callable identity and structural equivalence for transposed and flat-layout tile creation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A rabbit hops where tile paths meet,
One create_tile makes exports complete.
Transpose turns the layout bright,
Flat L1 staging fits just right.
Tests guard each alias in sight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: binding pl.create_tile to one function in both namespaces.
Description check ✅ Passed The description directly explains the namespace mismatch, the removal of the redundant forwarder, tests, and documentation updates.
Linked Issues check ✅ Passed The changes satisfy issue [#2265] by unifying create_tile bindings, preserving transpose and flat_layout support, and adding regression coverage.
Out of Scope Changes check ✅ Passed The code, tests, comments, and documentation changes are directly related to the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c61a703f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"shrs",
"set_validshape",
"create_tile",
"read",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the exported unified_ops.create_tile alias

Code importing create_tile directly from pypto.language.op.unified_ops now fails because this commit removes both the function and its __all__ entry, even though the module previously advertised it as exported. The duplicate wrapper can be eliminated without breaking that import path by retaining create_tile = _tile.create; this also provides the desired object identity and complete signature.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug] pl.create_tile resolves to two different functions — parser namespace rejects transpose=/flat_layout= that the signature advertises

2 participants