Run init tests for distributions under Dynamo by disabling tracing in kstest helpers#176226
Closed
cleonard530 wants to merge 2 commits intopytorch:mainfrom
Closed
Run init tests for distributions under Dynamo by disabling tracing in kstest helpers#176226cleonard530 wants to merge 2 commits intopytorch:mainfrom
cleonard530 wants to merge 2 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176226
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 6ff43b7 with merge base 4bdfaaa ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ery slow for larger dimensions (dims = 4) so they were set to be skipped. However, the ktest were only used to check if the distributution was correct. Thus, I added the @torch._dynamo.disable decorator to the test helper functions. The slowdown and those errors come from tracing into those helpers (and thus into `scipy.stats.kstest`), while the initialization of the distributions under Dynamo is unchanged.
c66194a to
741dbd7
Compare
…d the torch._dynamo.disable decorator to the helper function.
peterbell10
approved these changes
Mar 9, 2026
Collaborator
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
EmanueleCoradin
pushed a commit
to EmanueleCoradin/pytorch
that referenced
this pull request
Mar 30, 2026
… kstest helpers (pytorch#176226) Fixes pytorch#116271 Allow test/nn/test_init.py to run under TorchDynamo (e.g. with PYTORCH_TEST_WITH_DYNAMO=1) by removing the @skipIfTorchDynamo decorators from the tests that use scipy.stats.kstest and by adding @torch._dynamo.disable to the helpers _is_uniform, _is_normal, and _is_trunc_normal. Those helpers only perform the distribution checks via kstest; the actual init logic (e.g. init.uniform_, init.normal_, init.trunc_normal_) is still exercised under Dynamo. Tracing into kstest under Dynamo is very slow (and can hit the read-only numpy array path in CI). Disabling Dynamo only for these helpers avoids that cost and those failures while keeping the init behavior under test when Dynamo is enabled. @peterbell10, @Lucaskabela Pull Request resolved: pytorch#176226 Approved by: https://github.com/peterbell10
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.
Fixes #116271
Allow test/nn/test_init.py to run under TorchDynamo (e.g. with PYTORCH_TEST_WITH_DYNAMO=1) by removing the @skipIfTorchDynamo decorators from the tests that use scipy.stats.kstest and by adding @torch._dynamo.disable to the helpers is_uniform, is_normal, and is_trunc_normal. Those helpers only perform the distribution checks via kstest; the actual init logic (e.g. init.uniform, init.normal, init.trunc_normal) is still exercised under Dynamo.
Tracing into kstest under Dynamo is very slow (and can hit the read-only numpy array path in CI). Disabling Dynamo only for these helpers avoids that cost and those failures while keeping the init behavior under test when Dynamo is enabled.
@peterbell10, @Lucaskabela