Skip to content

[cuda] int4: stabilize two-layer decode test via CUDA-seeded init#20196

Merged
Gasoonjia merged 1 commit into
mainfrom
g4-int4-dispatch-test-rng-fix
Jun 10, 2026
Merged

[cuda] int4: stabilize two-layer decode test via CUDA-seeded init#20196
Gasoonjia merged 1 commit into
mainfrom
g4-int4-dispatch-test-rng-fix

Conversation

@Gasoonjia

Copy link
Copy Markdown
Contributor

_make_int4_linear built the throwaway nn.Linear on CPU, so reset_parameters() drew from the CPU RNG between the two layer constructions and shifted the stream that seeds the quantized weights. That pushed test_two_layer_mlp's genuine INT4 error from 0.1405 to 0.1556, crossing the 0.15 bound. Build the module with device=cuda so init draws from the CUDA RNG, leaving the CPU stream (and the measured error) deterministic. Test-only; dequant math is unchanged.

_make_int4_linear built the throwaway nn.Linear on CPU, so reset_parameters()
drew from the CPU RNG between the two layer constructions and shifted the stream
that seeds the quantized weights. That pushed test_two_layer_mlp's genuine INT4
error from 0.1405 to 0.1556, crossing the 0.15 bound. Build the module with
device=cuda so init draws from the CUDA RNG, leaving the CPU stream (and the
measured error) deterministic. Test-only; dequant math is unchanged.
@Gasoonjia Gasoonjia requested a review from shoumikhin June 10, 2026 18:30
@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 Jun 10, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

@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.

@Gasoonjia Gasoonjia merged commit ae4b0a4 into main Jun 10, 2026
197 of 207 checks passed
@Gasoonjia Gasoonjia deleted the g4-int4-dispatch-test-rng-fix branch June 10, 2026 18:33
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