Skip to content

test(rfc-1300): migrate in-tree tests off pl.Tensor[..., pl.DN] shorthand (Q4 follow-up)#1354

Merged
Hzfengsy merged 1 commit into
hw-native-sys:mainfrom
lyfne123:rfc1300/dsl-cleanup
May 13, 2026
Merged

test(rfc-1300): migrate in-tree tests off pl.Tensor[..., pl.DN] shorthand (Q4 follow-up)#1354
Hzfengsy merged 1 commit into
hw-native-sys:mainfrom
lyfne123:rfc1300/dsl-cleanup

Conversation

@lyfne123
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1347. Migrates every in-tree test that still used the deprecated pl.Tensor[..., pl.DN] shorthand — so the new DeprecationWarning introduced in #1347 fires only at the deprecation sites we explicitly assert it at, not as background noise across unrelated tests.

After this PR, grep -rE 'pl\.DN|pl\.Tensor\[.*pl\.DN' tests/ returns zero hits.

Migration patterns

Three classes of sites, three migration patterns:

  1. B^T-matmul markers — the DN annotation was just a hint that the param feeds a transpose=True load. The load already encodes the transpose; the annotation adds nothing. Drop the marker, keep the source shape.

    Sites: test_expand_mixed_kernel_a5.py (4×), test_pto_codegen_paged_attn.py, test_paged_attention.py (st).

    # Before
    y: pl.Tensor[[128, 128], pl.BF16, pl.DN],
    # After
    y: pl.Tensor[[128, 128], pl.BF16],
  2. DN-specific codegen tests — the DN view is the test subject (column-vector codegen, 3-D DN canonical-stride codegen). Keep the DN view but switch to the explicit-stride pl.TensorView(stride=[...], layout=DN) form (RFC [RFC] Self-consistent IR TensorType layout representation #1300 supplementary 1 escape hatch).

    Sites: test_pto_codegen.py::test_column_vector_with_explicit_dn, test_pto_codegen_3d_dn_tensor_view_uses_canonical_stride.

    # Before
    col_vec: pl.Tensor[[16, 1], pl.FP32, pl.DN],
    # After (canonical-packed stride for shape [16, 1])
    col_vec: pl.Tensor[
        [16, 1], pl.FP32, pl.TensorView(stride=[1, 16], layout=pl.TensorLayout.DN)
    ],
  3. Parser tests that specifically exercise the shorthand — backward compat still resolves pl.DN to a DN-tagged TensorView, so the tests now assert the DeprecationWarning fires rather than silently accept the resolution.

    Sites: test_type_resolver.py::test_resolve_tensor_with_dn_layout_warns, test_function_with_dn_layout_warns. Parametrized lists drop the DN row (covered by the dedicated tests).

  4. Deleted testtest_already_dn_param_idempotent in test_lower_transpose_load_param_layout_pass.py. That test specifically validated the pass's behavior when a user wrote a DN-tagged param — exactly the input pattern feat: deprecate pl.Tensor[..., pl.DN] + strict TensorViewCanonical (RFC #1300 §2.4 + supplementary 1) #1347 deprecates. The pass's short-circuit branch is no longer reachable from valid DSL; existing TestNoOpCases and TestStridedParamFlipsCorrectly coverage still exercises every reachable code path.

Test plan

  • Full unit suite passes: 4655 passed, 41 skipped (locally on macOS arm64).
  • Deprecation warnings now fire only at the dedicated assertion sites in test_type_resolver.py, not as background warnings across unrelated tests.
  • DN-specific codegen tests (test_column_vector_with_explicit_dn, test_pto_codegen_3d_dn_tensor_view_uses_canonical_stride) still pass — the canonical-stride TensorView reaches codegen with the same effective view shape the shorthand produced.
  • CI runs (will be triggered automatically on PR open).

…hand (Q4)

Removes the deprecated ``pl.Tensor[..., pl.DN]`` shorthand from every
in-tree test that wasn't specifically validating the DN codegen path.

Migration patterns applied:

* **B^T-matmul marker** — drop the DN annotation; keep the
  ``transpose=True`` on the matching ``pl.load``. The Q5 path
  (ConvertTensorToTileOps lowering of transpose=True loads) is the
  intended replacement — annotating the param adds no information
  beyond what the load already encodes.

  Affected: ``test_expand_mixed_kernel_a5.py`` (4 sites),
  ``test_pto_codegen_paged_attn.py``, ``test_paged_attention.py``.

* **DN-specific codegen tests** — keep the DN view but use the
  canonical-stride ``pl.TensorView(stride=[...], layout=DN)`` form
  (RFC hw-native-sys#1300 supplementary 1 escape hatch). The DN view is the test
  subject here, not an alias — so it must stay, but in the explicit
  stride form rather than the deprecated shorthand.

  Affected: ``test_pto_codegen.py`` (``test_column_vector_with_explicit_dn``,
  ``test_pto_codegen_3d_dn_tensor_view_uses_canonical_stride``).

* **Parser tests for the shorthand itself** — the ``pl.DN`` parsing path
  still exists for backward compatibility, so the tests now assert the
  ``DeprecationWarning`` fires rather than silently accept the layout.

  Affected: ``test_type_resolver.py`` —
  ``test_resolve_tensor_with_dn_layout_warns``,
  ``test_function_with_dn_layout_warns``. Other parametrized cases drop
  the DN entry (covered by the dedicated tests).

* **Deleted test** — ``test_already_dn_param_idempotent`` in
  ``test_lower_transpose_load_param_layout_pass.py``. The "user wrote
  a DN-tagged param" input pattern is exactly what Q4 deprecates;
  the pass's short-circuit branch is now unreachable from valid DSL.
  Existing no-op coverage in ``test_no_transpose_unchanged`` plus the
  full TestNoOpCases / TestStridedParamFlipsCorrectly suite still
  exercises every reachable code path.

After this commit, ``grep -rE 'pl\.DN|pl\.Tensor\[.*pl\.DN' tests/``
returns zero hits — every remaining ``pl.TensorLayout.DN`` reference is
either an explicit ``pl.TensorView(stride=..., layout=DN)`` (the
supported form) or a printer/parser assertion about the layout enum
itself.

All 4630 unit tests pass.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@lyfne123 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 35 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e7108e22-715d-4613-8a28-77b40d04d57a

📥 Commits

Reviewing files that changed from the base of the PR and between 2b6d2a1 and 70198b5.

📒 Files selected for processing (6)
  • tests/st/codegen/test_paged_attention.py
  • tests/ut/codegen/test_pto_codegen.py
  • tests/ut/codegen/test_pto_codegen_paged_attn.py
  • tests/ut/ir/transforms/test_expand_mixed_kernel_a5.py
  • tests/ut/ir/transforms/test_lower_transpose_load_param_layout_pass.py
  • tests/ut/language/parser/test_type_resolver.py

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 and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request deprecates the pl.DN shorthand for tensor layouts across the test suite, aligning with RFC #1300. Changes include removing the shorthand from various tests, replacing it with explicit pl.TensorView in codegen tests, and adding verification for DeprecationWarning in the type resolver. Feedback was provided regarding the deletion of a test case in test_lower_transpose_load_param_layout_pass.py, which leaves a logic branch unexercised; it is recommended to refactor this test to use the explicit pl.TensorView form instead of removing it entirely.

I am having trouble creating individual review comments. Click here to see my feedback.

tests/ut/ir/transforms/test_lower_transpose_load_param_layout_pass.py (444-481)

medium

While the pl.Tensor[..., pl.DN] shorthand is deprecated, the LowerTransposeLoadParamLayout pass still contains logic to handle parameters that are already DN-tagged (e.g., from an explicit pl.TensorView). Deleting test_already_dn_param_idempotent leaves the if (view.layout == TensorLayout::DN) continue; branch in the pass unexercised. Consider refactoring this test to use the explicit pl.TensorView form instead of deleting it. Additionally, ensure the test function is explicitly annotated with the target function type (e.g., @pl.function(type=pl.FunctionType.InCore)) to ensure it is not skipped by the pass.

References
  1. When writing unit tests for IR passes, ensure the test functions are explicitly annotated with the target function type (e.g., InCore) to prevent them from being treated as Opaque and skipped.

@Hzfengsy Hzfengsy merged commit 1658cbb into hw-native-sys:main May 13, 2026
9 checks passed
lyfne123 added a commit to lyfne123/pypto that referenced this pull request May 13, 2026
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.

2 participants