Cover a CUDA model with weights in the wheel smoke test - #22089
Open
shoumikhin wants to merge 1 commit into
Open
Cover a CUDA model with weights in the wheel smoke test#22089shoumikhin wants to merge 1 commit into
shoumikhin wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22089
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 40 PendingAs of commit cbbe528 with merge base 9a2d135 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
The CUDA rows of the wheel smoke test export one model through the CUDA delegate and run it. That model is an add of two inputs, so it has no weights. A model with no weights needs nothing from the delegate's external data file, so it runs whether or not that path works. The CUDA delegate does not put weights in the .pte. It writes them to a separate file named aoti_cuda_blob.ptd, and the caller has to hand that file back at load time. Every runner script in this repository passes it by name. Nothing in the smoke test loaded one, so a wheel that could not produce or consume that file passed the check and shipped. Add a second model, a small linear layer, to the same child process: - export it through the CUDA partitioner and write both the .pte and the data file, - assert the program actually carries a CUDA delegate, so a partitioner that silently declined the model cannot pass this check on the portable kernels, - assert the data file is present under the name the runners expect, - assert the data file is larger than the one the weightless model above produces, by at least the size of this model's weight matrix, - load the program with the data file and compare the result against eager. The size check is written as a difference rather than a threshold on purpose. A data file is written even when there are no weights, and it is not small: measured on sm_80, the weightless model produces a 256-byte container around an empty payload. Any fixed lower bound below that is satisfied by an empty file, so the check has to calibrate itself. It writes the weightless program's data file in the same run and subtracts. Comparing against the sum over parameters() would not work either: measured on sm_80, the delegate wrote this Linear's 128-byte weight into the data file and kept its 16-byte bias out, so that sum is not a bound on what the file has to hold. Test plan: ran the new child code on a Linux x86_64 machine with an sm_80 GPU against a published nightly CUDA wheel. Both models pass: PASS: a CUDA-delegated model ran on sm_80 and matched eager PASS: a CUDA-delegated model with weights ran on sm_80 from a 384-byte aoti_cuda_blob.ptd carrying 128 bytes of weights, and matched eager The delegate log on that run names a real content hash for the weights blob, not the hash of an empty one. Also confirmed the check is meaningful in both directions. Loading the same weighted program without the data file makes the delegate report the weights as not found, and the run then fails inside forward with an illegal memory access. And if the delegate wrote an empty data file for the weighted model, the measured numbers give a difference of 0 against a 128-byte weight matrix, so the assertion fires.
shoumikhin
force-pushed
the
cuda-wheel-weights-blob
branch
from
August 24, 2026 18:36
58d3b1a to
cbbe528
Compare
shoumikhin
requested a deployment
to
cadence
August 24, 2026 19:08 — with
GitHub Actions
In progress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The CUDA rows of the wheel smoke test export one model through the CUDA delegate and run it. That model is
x + y, so it has no weights.A model with no weights needs nothing from the delegate's external data file, so it runs whether or not that path works. The CUDA delegate does not put weights in the
.pte. It writes them to a separate file namedaoti_cuda_blob.ptd, and the caller has to hand that file back at load time. Every runner script in this repository passes it by name. Nothing in the smoke test loaded one, so a wheel that could not produce or consume that file would pass the check and ship.What this changes
A second model, a small
nn.Linear, in the same child process:CudaPartitionerand write both the.pteand the data file,Only the x86_64 rows execute this, the same as the existing check. The aarch64 rows have no GPU on their validation runner and keep skipping with a printed reason.
Why the size check is written as a difference
A data file is written even when the model has no weights, and it is not small. Measured on sm_80, the weightless model above produces a 256-byte file: a container around an empty payload. So any fixed lower bound below 256 is satisfied by a file with nothing in it, and a check like
size >= weight_bytesfor a small model is true no matter what the delegate did.Instead the check writes the weightless program's data file in the same run, which costs nothing because that program is already compiled, and subtracts. That keeps working if the container format changes size later, which a hardcoded 256 would not.
Comparing against the sum over
parameters()would not work either. Measured on sm_80 with this model, the delegate wrote the 128-byte weight into the data file and kept the 16-byte bias out, so that sum is not a bound on what the file has to hold. The check uses the weight matrix only.Test plan
Ran the new child code on a Linux x86_64 machine with an sm_80 GPU, against a published nightly CUDA wheel. Both models pass:
The delegate log on that run names a real content hash for the weights blob, not the hash of an empty one.
Also confirmed the new check is meaningful in both directions.
Loading the same weighted program without the data file gives:
And if the delegate wrote an empty data file for the weighted model, the measured numbers give 256 minus 256, a difference of 0, against a 128-byte weight matrix, so the assertion fires. The previous version of this check did not: it compared the raw file size against the parameter total, and 256 is already larger than 144, so it would have passed on an empty file.