Repository navigation
Conversation
Summary: `test_random_float_draws_inductor_float32` is flaky internally (T294923386). On failure the third output, `x * random.random()`, equals `x * 0.7580`, the second draw after `random.seed(0)`, instead of `x * 0.8444`, the first. So something drew from the global RNG once between the reseed and the runtime draw. The test reseeds before `torch.compile`, and compilation is lazy, so any global RNG use during the first call's compile (internal module initializations and similar) shifts the draw. Fix it the way `test_multiple_consecutive_random_calls_before_graph` in the same file does: compile with a warm-up call, then reseed. The `random.Random` argument is guarded by type only, so the second call reuses the compiled code. This change was authored by an AI agent (Oncall Operator, TestX batch triage for pt2_stack_for_internal). Test Plan: ``` buck test fbcode//mode/opt fbcode//caffe2/test/dynamo:test_dynamo -- --exact 'caffe2/test/dynamo:test_dynamo - test_unspec.py::UnspecTests::test_random_float_draws_inductor_float32' --stress-runs 20 ``` Fixes T294923386 Differential Revision: D127783734
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (2): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202212
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 4 PendingAs of commit 04c6e60 with merge base a1f5fd0 ( 🟢 GREEN LIGHT - PR approved to be merged without human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@ezyang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127783734. |
There was a problem hiding this comment.
Automated review of 04c6e60: nothing blocking; ready for human review.
The PR fixes the internal flake in test_random_float_draws_inductor by making a warm-up compiled call before random.seed(0), the same pattern test_multiple_consecutive_random_calls_before_graph uses. The fix is sound, but the new comment names the wrong cause. Recommendation: Approve. Fix the comment wording before landing.
⚪ 2 non-blocking findings
pytorch/test/dynamo/test_unspec.py
Line 261 in 04c6e60
The comment blames the wrong source of the extra draw. Compilation itself cannot be the cause. Tracing and Inductor compilation run inside the Dynamo callback, which runs under PreserveGlobalState (torch/csrc/dynamo/eval_frame_cpp.cpp:227-253, used at :630). That saves Python's random state before compiling and restores it afterwards, and it also undoes the trace-time example_value draw in call_random_fn. So the extra draw has to happen outside that guard: in the torch.compile(...) construction (e.g. lazy imports) or in the Python eval_frame wrapper. The original test reseeded before torch.compile(...). The first-call tests at lines 820-855 reseed after it and do not appear to flake, which points at construction. Reword the comment to say what actually happens: one-time global-RNG use outside the compile itself, during torch.compile construction or the first-call wrapper. Alternatively, reuse the comment already used for this pattern at lines 161-162 / 212-213 / 420-421.
pytorch/test/dynamo/test_unspec.py
Line 263 in 04c6e60
Possible narrower fix (low confidence, needs an internal stress run): moving random.seed(0) to just after torch.compile(...) may be enough on its own. That would keep first-compiled-call coverage for the Inductor path, which the warm-up call now throws away.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
|
Superseded by #202224 (same change, resubmitted with the correct commit author email so the CLA check passes). |
|
/easycla |
Summary:
test_random_float_draws_inductor_float32is flaky internally (T294923386). On failure the third output,x * random.random(), equalsx * 0.7580, the second draw afterrandom.seed(0), instead ofx * 0.8444, the first. So something drew from the global RNG once between the reseed and the runtime draw. The test reseeds beforetorch.compile, and compilation is lazy, so any global RNG use during the first call's compile (internal module initializations and similar) shifts the draw.Fix it the way
test_multiple_consecutive_random_calls_before_graphin the same file does: compile with a warm-up call, then reseed. Therandom.Randomargument is guarded by type only, so the second call reuses the compiled code.This change was authored by an AI agent (Oncall Operator, TestX batch triage for pt2_stack_for_internal).
Test Plan:
Fixes T294923386
Differential Revision: D127783734
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98