Skip to content

Run init tests for distributions under Dynamo by disabling tracing in kstest helpers#176226

Closed
cleonard530 wants to merge 2 commits intopytorch:mainfrom
cleonard530:ktest_killed_in_ci
Closed

Run init tests for distributions under Dynamo by disabling tracing in kstest helpers#176226
cleonard530 wants to merge 2 commits intopytorch:mainfrom
cleonard530:ktest_killed_in_ci

Conversation

@cleonard530
Copy link
Copy Markdown
Collaborator

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Mar 2, 2026

🔗 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 (image):

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.

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Mar 2, 2026
…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.
…d the torch._dynamo.disable decorator to the helper function.
@cleonard530 cleonard530 requested a review from peterbell10 March 3, 2026 12:43
@jcaip jcaip added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Mar 4, 2026
@cleonard530
Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 9, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dynamo] Tests using kstest are being killed in CI

5 participants