Skip to content

Write golden input artifacts in the tensor's own byte order - #21851

Merged
rascani merged 1 commit into
pytorch:mainfrom
rascani:suite-golden-artifact-dim-order
Aug 14, 2026
Merged

Write golden input artifacts in the tensor's own byte order#21851
rascani merged 1 commit into
pytorch:mainfrom
rascani:suite-golden-artifact-dim-order

Conversation

@rascani

@rascani rascani commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

_dump_golden_artifacts wrote inputs through contiguous(), which means contiguous_format and re-lays a channels_last tensor back to NCHW. The .bin then disagrees with the dim_order the accompanying .pte declares, and the runtime ingests it as a raw memcpy, so anything replaying a golden input against the program feeds it transposed data.

Permuting by dim_order() first writes the bytes the runtime consumes. It is a no-op for a contiguous tensor, which is what every flow in the suite feeds today: all of its inputs are torch.randn and friends, and the permutes and transposes are inside the models rather than in the inputs.

Outputs deliberately keep contiguous(). reference_output is the eager result, so a model ending in a permute hands back a view whose dim_order describes the source rather than the result, while the program materializes that output contiguously. Permuting there would write the pre-permute values and corrupt the goldens for the permute and transpose operator tests, which is what the new test for that case pins down.

Test plan

Nothing consumes the channels_last path yet. The Cortex-M flow is the first to hand the harness such inputs, and CI uploads these artifacts, so this is a prerequisite for it.

Authored with Claude Code.

_dump_golden_artifacts wrote inputs through contiguous(), which means
contiguous_format and re-lays a channels_last tensor back to NCHW. The .bin
then disagrees with the dim_order the accompanying .pte declares, and the
runtime ingests it as a raw memcpy, so anything replaying a golden input
against the program feeds it transposed data.

Permuting by dim_order() first writes the bytes the runtime consumes. It is a
no-op for a contiguous tensor, which is what every flow in the suite feeds
today: all of its inputs are torch.randn and friends, and the permutes and
transposes are inside the models rather than in the inputs.

Outputs deliberately keep contiguous(). reference_output is the eager result,
so a model ending in a permute hands back a view whose dim_order describes the
source rather than the result, while the program materializes that output
contiguously. Permuting there would write the pre-permute values and corrupt
the goldens for the permute and transpose operator tests, which is what the
new test for that case pins down.

Nothing consumes the channels_last path yet. The Cortex-M flow is the first to
hand the harness such inputs, and CI uploads these artifacts, so this is a
prerequisite for it.

Authored with Claude Code.
@rascani
rascani requested a review from digantdesai August 14, 2026 18:33
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@pytorch-bot

pytorch-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21851

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 6 Pending

As of commit 9597db3 with merge base 5c3cb65 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 14, 2026
@rascani
rascani merged commit d18ca0f into pytorch:main Aug 14, 2026
191 of 197 checks passed
@rascani
rascani deleted the suite-golden-artifact-dim-order branch August 14, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants