[Dynamo] Constant-fold CUDA Tensor.is_pinned() (#186494)
Dynamo traced Tensor.is_pinned() as a generic tensor method call. In user Triton paths such as Triton's pinned-memory helper, this meant a CUDA fake tensor produced an aten.is_pinned bool result while tracing. Older builds failed while fake-running aten.is_pinned; current main has FakeTensor coverage but still cannot wrap the bool-producing torch op in the FX graph. For non-CPU tensors, ATen is_pinned() is metadata-independent and always false. Add a TensorVariable method handler that returns a Python constant False for the no-argument non-CPU case before creating an FX proxy. Leave CPU tensors on the generic path because CPU pinned memory can vary independently of Dynamo's tensor metadata guards. This keeps the fix limited to the sound case needed by CUDA user Triton code instead of treating all is_pinned calls as metadata constants. Fixes #121526 Generated by my agent Test Plan: - python test/dynamo/test_misc.py -k test_cuda_tensor_is_pinned_constant_false - lintrunner -a - git diff --check Pull Request resolved: https://github.com/pytorch/pytorch/pull/186494 Approved by: https://github.com/eellison, https://github.com/mlazos
J
Jason Ansel committed
029e923dcfcc61cd22845719557a11b2b0da78f1
Parent: c2400e4
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com>
on 8/23/2026, 7:23:30 PM