trunk/9903b576b6cb81682492904056e3c8dc663f6c9f: Move intrusive_ptr's is_always_lock_free static_assert to .cpp (#181719)
Moving a static_assert to .cpp resolves 64-bit atomic failures on CUDA backends
PyTorch's PR #181719 addresses a compilation issue with intrusive_ptr's is_always_lock_free static_assert. The assert was originally in the header, which is parsed by both host and device compilers like nvcc, hip, and various CUDA-like privateuse1 backends. Since std::atomic<uint64_t>::is_always_lock_free reflects the target compiler's code generation, a device pass targeting hardware without 64-bit atomics would fail the assert, even though combined_refcount_ is only ever touched from host code.
A preprocessor guard would only protect known device compilers. Moving the check to intrusive_ptr.cpp makes it host-only by construction, working for arbitrary unknown backends. This fix resolves issue #171775 and was authored with Claude. Approved by Skylion007, the change ensures broader compatibility across diverse hardware targets without sacrificing correctness.
- Moves is_always_lock_free static_assert from header to intrusive_ptr.cpp
- Fixes compilation failures on device compilers targeting hardware without 64-bit atomics
- Works for arbitrary unknown backends without preprocessor guards
Why It Matters
Ensures PyTorch compiles reliably across diverse hardware backends, improving developer experience