Skip to content

[Type] Tensor 7: Test layout= + needs_grad= grad-buffer round-…#527

Closed
hughperkins wants to merge 15 commits intohp/tensor-stork-6from
hp/tensor-stork-7
Closed

[Type] Tensor 7: Test layout= + needs_grad= grad-buffer round-…#527
hughperkins wants to merge 15 commits intohp/tensor-stork-6from
hp/tensor-stork-7

Conversation

@hughperkins
Copy link
Copy Markdown
Collaborator

…trip

Test-only PR closing the gap left by PRs 5 and 6: the combination of layout= and needs_grad= was checked at allocation time, but not yet exercised through a kernel write/read on the .grad buffer with a non- identity layout.

This pins down the pre-impl POC Q3b finding (grad SNode inherits the primal's axis_seq) so any upstream Quadrants regression in this area surfaces immediately.

Adds 8 tests:

  • rank-2 transposed-storage primal+grad kernel round-trip
  • rank-3 (2, 0, 1) primal+grad kernel round-trip
  • all 6 rank-3 layout permutations with primal+grad written and read

All tests pass; no production-code or doc changes.

Issue: #

Brief Summary

copilot:summary

Walkthrough

copilot:walkthrough

…trip

Test-only PR closing the gap left by PRs 5 and 6: the combination of
layout= and needs_grad= was checked at allocation time, but not yet
exercised through a kernel write/read on the .grad buffer with a non-
identity layout.

This pins down the pre-impl POC Q3b finding (grad SNode inherits the
primal's axis_seq) so any upstream Quadrants regression in this area
surfaces immediately.

Adds 8 tests:
- rank-2 transposed-storage primal+grad kernel round-trip
- rank-3 (2, 0, 1) primal+grad kernel round-trip
- all 6 rank-3 layout permutations with primal+grad written and read

All tests pass; no production-code or doc changes.
@hughperkins
Copy link
Copy Markdown
Collaborator Author

Would prefer to add the ndarray layout first really, but ...

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).
- ruff/black: re-sort imports and reformat python/quadrants/_tensor.py
  (and reorder _tensor import in __init__.py)
- pylint: silence import-outside-toplevel on the intentional late
  imports inside the qd.tensor* dispatchers
- test_api: add Backend, tensor, tensor_annotation, tensor_mat,
  tensor_vec to the qd allowlist (newly exported by _tensor)
- docs/tensor.md: drop broken #fields / #ndarrays anchors in the intro
  paragraph (the next paragraph already links to the actual pages)

Made-with: Cursor
…r-stork-7

Made-with: Cursor

# Conflicts:
#	python/quadrants/__init__.py
PR 6 made qd.tensor() reject the order= kwarg in favor of layout=, but
test_tensor_kwargs_pass_through_to_field still passed order="ji" and
expected it to reach qd.field. Switch the test to needs_grad=True, which
is the canonical field-only kwarg today, and assert the grad buffer is
allocated. The order=-rejection contract is already covered by
test_order_kwarg_rejected in test_tensor_layout.py.

Made-with: Cursor
…r-stork-7

Made-with: Cursor

# Conflicts:
#	docs/source/user_guide/tensor.md
#	python/quadrants/_tensor.py
…r-stork-7

# Conflicts:
#	python/quadrants/_tensor.py
…r-stork-7

# Conflicts:
#	python/quadrants/_tensor.py
… PR-6 merge

The PR-3 privatization renamed tensor_vec / tensor_mat to private impls
in _tensor.py. When merging PR 6 forward into PR 7 in this branch's
history, a conflict-resolution slip restored HEAD's copy of the file
(checkout --ours) which still had the old top-level names + the old
__all__. The Vector.tensor / Matrix.tensor classmethods on PR 7 import
_tensor_vec / _tensor_mat, so without this fix calling them raises
ImportError.

Re-apply the rename:
- _tensor.py: drop the dead public tensor_vec / tensor_mat function
  defs, restore the private _tensor_vec / _tensor_mat impls, drop the
  two stale entries from __all__ (already done correctly via PR 4
  merge resolution but the function defs hadn't followed).
- docs/source/user_guide/tensor.md: switch the "Vector and matrix
  tensors" section and the needs_grad note to qd.Vector.tensor /
  qd.Matrix.tensor wording.

No new functionality, no test changes — just bringing PR 7 in line
with what PRs 5 and 6 already had. Will cascade-merge into PRs 8-14
which still carry the same regression.
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