Repository navigation
Fix extra clone in torch.compile for stateless RNG APIs - #188495
jbschlosser wants to merge 4 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/188495
Note: Links to docs will display an error until the docs builds have been completed. ❌ 6 New FailuresAs of commit fbb9e5f with merge base caf9663 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
zou3519
left a comment
There was a problem hiding this comment.
seems fine, discussed offline that there is likely a bug in Inductor that we can investigate separately.
|
Update: instead of adding out-of-place op variants, I want to make the ops inplaceable with manual allowlist entries until we can get a more general fix in (e.g. #189080). |
|
@claude are the CI failures related? |
|
Claude finished @jbschlosser's task in 1m 25s —— View job Are the CI failures related?
No — the only failure is unrelated infrastructure flakiness. DetailsThe single failing workflow is The root cause is a read-only cache mount, not the code under test: This
Neither of those files is exercised by the torchtitan dataset loading path that fails. Everything else is green or still running: Recommendation: this failure is a runner-side flake. A rerun once the mount is healthy (or an unrelated infra fix) should clear it — no code change needed on this PR. |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 4 checks: torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_features_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), inductor / inductor-test / test-osdc (inductor_timm, 2, 2, mt-l-x86aavx2-29-113-a10g), inductor / inductor-test / test-osdc (inductor_timm, 1, 2, mt-l-x86aavx2-29-113-a10g) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-aarch64-py3.10 / test-osdc (default, 5, 5, lf-l-arm64g3-16-62) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 6 checks: torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_features_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), inductor / inductor-test / test-osdc (inductor_torchbench, 2, 2, mt-l-x86aavx2-29-113-a10g), inductor / inductor-test / test-osdc (inductor_timm, 2, 2, mt-l-x86aavx2-29-113-a10g), inductor / inductor-test / test-osdc (inductor_timm, 1, 2, mt-l-x86aavx2-29-113-a10g), trunk / linux-jammy-aarch64-py3.10 / test-osdc (default, 5, 5, lf-l-arm64g3-16-62) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
@claude make sure all the CI failures are still infra-related |
|
Claude finished @jbschlosser's task in 2m 41s —— View job Are all the CI failures still infra-related?
Mostly yes, but not all — the inductor accuracy failures are a stale merge base (benign), and the rest are pure infra flakiness. None are caused by this PR. Two categories: DetailsI split the 6 reported failures into two root causes. 1. Inductor accuracy failures — stale merge base (benign, NOT infra, NOT this PR)These are graph-break count assertions, not infra errors:
The expected counts were bumped on trunk. Comparing the CSVs: The observed graph-break counts in CI (7/6/7/6/6) exactly match the values already on
2. Pure infra flakiness (NOT this PR)
Bottom lineNo failure is caused by this PR. The inductor ones are a stale merge base (would vanish on rebase); the torchtitan/aarch64 ones are runner-side infra flakiness. Ignoring/merging remains safe. Green/passing: |
…kernels (#189735) Original repro in P2415048693. Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of #188495. `FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results. This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live. Pull Request resolved: #189735 Approved by: https://github.com/eellison ghstack dependencies: #189767
Benchmark script (P2398638090) shows a performance issue with the new stateless RNG APIs within torch.compile. Tracked this down to the auto-generated functional variants of the new ops performing an extra clone. To address this, this PR: * ~~Introduces explicit, non-autogenerated functional variants for the in-place ops that use `empty_like(self)` instead of `self.clone()` to indicate to functionalization that the data is completely overwritten and is not needed for correctness. This addresses the performance issue for the in-place ops, but still (briefly) results in a 2x allocation for an unused buffer alongside the output when the out-of-place APIs call the in-place ops.~~ * ~~Introduces new size-based overloads for the out-of-place APIs. Now they bypass the in-place ops entirely (preferring the size-based, out-of-place ops), avoiding the aforementioned 2x allocation.~~ * Adds `inplaceable_ops` registry entries for the philox uniform / normal ops. These will be unneeded once we land Inductor lowerings or a more general fix (e.g. pytorch#189080). Pull Request resolved: pytorch#188495 Approved by: https://github.com/ngimel, https://github.com/zou3519
Benchmark script (P2398638090) shows a performance issue with the new stateless RNG APIs within torch.compile. Tracked this down to the auto-generated functional variants of the new ops performing an extra clone. To address this, this PR: * ~~Introduces explicit, non-autogenerated functional variants for the in-place ops that use `empty_like(self)` instead of `self.clone()` to indicate to functionalization that the data is completely overwritten and is not needed for correctness. This addresses the performance issue for the in-place ops, but still (briefly) results in a 2x allocation for an unused buffer alongside the output when the out-of-place APIs call the in-place ops.~~ * ~~Introduces new size-based overloads for the out-of-place APIs. Now they bypass the in-place ops entirely (preferring the size-based, out-of-place ops), avoiding the aforementioned 2x allocation.~~ * Adds `inplaceable_ops` registry entries for the philox uniform / normal ops. These will be unneeded once we land Inductor lowerings or a more general fix (e.g. pytorch#189080). Pull Request resolved: pytorch#188495 Approved by: https://github.com/ngimel, https://github.com/zou3519
…kernels (pytorch#189735) Original repro in P2415048693. Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495. `FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results. This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live. Pull Request resolved: pytorch#189735 Approved by: https://github.com/eellison ghstack dependencies: pytorch#189767
…kernels (pytorch#189735) Original repro in P2415048693. Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495. `FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results. This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live. Pull Request resolved: pytorch#189735 Approved by: https://github.com/eellison ghstack dependencies: pytorch#189767
Benchmark script (P2398638090) shows a performance issue with the new stateless RNG APIs within torch.compile. Tracked this down to the auto-generated functional variants of the new ops performing an extra clone. To address this, this PR: * ~~Introduces explicit, non-autogenerated functional variants for the in-place ops that use `empty_like(self)` instead of `self.clone()` to indicate to functionalization that the data is completely overwritten and is not needed for correctness. This addresses the performance issue for the in-place ops, but still (briefly) results in a 2x allocation for an unused buffer alongside the output when the out-of-place APIs call the in-place ops.~~ * ~~Introduces new size-based overloads for the out-of-place APIs. Now they bypass the in-place ops entirely (preferring the size-based, out-of-place ops), avoiding the aforementioned 2x allocation.~~ * Adds `inplaceable_ops` registry entries for the philox uniform / normal ops. These will be unneeded once we land Inductor lowerings or a more general fix (e.g. pytorch#189080). Pull Request resolved: pytorch#188495 Approved by: https://github.com/ngimel, https://github.com/zou3519
…kernels (pytorch#189735) Original repro in P2415048693. Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495. `FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results. This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live. Pull Request resolved: pytorch#189735 Approved by: https://github.com/eellison ghstack dependencies: pytorch#189767
…kernels (pytorch#189735) Original repro in P2415048693. Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495. `FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results. This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live. Pull Request resolved: pytorch#189735 Approved by: https://github.com/eellison ghstack dependencies: pytorch#189767
Stack from ghstack (oldest at bottom):
Benchmark script (P2398638090) shows a performance issue with the new stateless RNG APIs within torch.compile. Tracked this down to the auto-generated functional variants of the new ops performing an extra clone. To address this, this PR:
Introduces explicit, non-autogenerated functional variants for the in-place ops that useempty_like(self)instead ofself.clone()to indicate to functionalization that the data is completely overwritten and is not needed for correctness. This addresses the performance issue for the in-place ops, but still (briefly) results in a 2x allocation for an unused buffer alongside the output when the out-of-place APIs call the in-place ops.Introduces new size-based overloads for the out-of-place APIs. Now they bypass the in-place ops entirely (preferring the size-based, out-of-place ops), avoiding the aforementioned 2x allocation.inplaceable_opsregistry entries for the philox uniform / normal ops. These will be unneeded once we land Inductor lowerings or a more general fix (e.g. [inductor] Generalize reinplacing to functional ATen ops with an in-place variant #189080).cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo