Skip to content

[Type] Tensor 10: Layout aliasing across supported Quadrants p…#530

Draft
hughperkins wants to merge 4 commits intohp/tensor-stork-9from
hp/tensor-stork-10
Draft

[Type] Tensor 10: Layout aliasing across supported Quadrants p…#530
hughperkins wants to merge 4 commits intohp/tensor-stork-9from
hp/tensor-stork-10

Conversation

@hughperkins
Copy link
Copy Markdown
Collaborator

…atterns

Test-only PR. Investigation found that in-kernel rebinding (y = x) is not supported by Quadrants for any ndarray — that's an upstream limitation that raises QuadrantsTypeError: Invalid constant scalar data type: AnyArray regardless of layout. The test file's docstring spells this out explicitly.

This PR pins down the aliasing patterns that Quadrants does support and that flexible-tensors layout metadata must propagate through:

  1. Same Ndarray passed twice to the same kernel: both AnyArrays get the same layout via the runtime feature tuple.
  2. Same Ndarray reused across two consecutive kernel calls: layout persists.
  3. Repeated .grad access inside a single kernel: each access inherits layout from the parent AnyArray.
  4. Same Ndarray bound to two kernels with different parameter names but compatible annotations: layout travels with the value, not the annotation.
  5. Tagged + untagged ndarrays in the same kernel: layout isolation per argument.
  6. Two separately-allocated tagged ndarrays: independence.

6 tests, all pass.

Issue: #

Brief Summary

copilot:summary

Walkthrough

copilot:walkthrough

…atterns

Test-only PR. Investigation found that in-kernel rebinding (``y = x``) is
**not** supported by Quadrants for any ndarray — that's an upstream
limitation that raises ``QuadrantsTypeError: Invalid constant scalar
data type: AnyArray`` regardless of layout. The test file's docstring
spells this out explicitly.

This PR pins down the aliasing patterns that Quadrants does support and
that flexible-tensors layout metadata must propagate through:

1. Same Ndarray passed twice to the same kernel: both AnyArrays get the
   same layout via the runtime feature tuple.
2. Same Ndarray reused across two consecutive kernel calls: layout
   persists.
3. Repeated ``.grad`` access inside a single kernel: each access
   inherits layout from the parent AnyArray.
4. Same Ndarray bound to two kernels with different parameter names but
   compatible annotations: layout travels with the value, not the
   annotation.
5. Tagged + untagged ndarrays in the same kernel: layout isolation per
   argument.
6. Two separately-allocated tagged ndarrays: independence.

6 tests, all pass.
@@ -0,0 +1,195 @@
"""Aliasing of layout metadata across the supported Quadrants aliasing
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

lets not mention pr numbers

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

also lets put all these tests into a single file probably, across all the prs.

@hughperkins hughperkins force-pushed the hp/tensor-stork-10 branch 2 times, most recently from fb5eb4f to f8c9fbd Compare April 20, 2026 20:59
Drops the 'flexible' prefix from filenames and identifiers introduced
in this branch series so the user-visible names are simply 'tensor'.
Also strips PR-N back-references that will be meaningless once these
PRs land. Touches only files owned by this series (no changes to
external/ or unrelated tests).
- black/ruff/pylint cleanups in python/quadrants/_tensor.py and the
  three new tensor test files (plus the import-block ordering nudged
  by the rename in python/quadrants/__init__.py). The pylint disable
  for the intentional late imports is hoisted to the module level so
  it does not force black to balloon the import lines (which then
  re-broke ruff).
- Replace the broken `#fields` / `#ndarrays` in-page anchors in
  tensor.md with a single link to tensor_types.md, which is the
  actual page where field vs ndarray are described.

Made-with: Cursor
…r-stork-10

Made-with: Cursor

# Conflicts:
#	docs/source/user_guide/tensor.md
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