--- ./c10/core/impl/LocalDispatchKeySet.cpp_orig	2025-01-14 01:19:03.884615205 -0600
+++ ./c10/core/impl/LocalDispatchKeySet.cpp	2025-01-13 21:24:39.485083750 -0600
@@ -11,9 +11,9 @@
 // default state is zero, we obtain the actual include keyset by XORing
 // raw_local_dispatch_key_set.included_ with c10::default_included_set.  This
 // logic is encapsulated in struct PODLocalDispatchKeySet.
-thread_local PODLocalDispatchKeySet raw_local_dispatch_key_set;
+__thread PODLocalDispatchKeySet raw_local_dispatch_key_set;
 
-#if defined(_MSC_VER) || defined(C10_ANDROID) || defined(C10_IPHONE)
+#if defined(_MSC_VER) || defined(C10_ANDROID) || defined(C10_IPHONE) || defined _AIX
 LocalDispatchKeySet tls_local_dispatch_key_set() {
   return raw_local_dispatch_key_set;
 }
--- ./c10/core/impl/LocalDispatchKeySet.h_orig	2025-01-14 01:21:14.724614770 -0600
+++ ./c10/core/impl/LocalDispatchKeySet.h	2025-01-14 01:21:25.354614185 -0600
@@ -62,10 +62,10 @@
 
 // thread_local variables cannot be C10_API on Windows.
 // Inlining this seems to break AutoDispatchBelowAutograd on Android.
-#if defined(_MSC_VER) || defined(C10_ANDROID) || defined(C10_IPHONE)
+#if defined(_MSC_VER) || defined(C10_ANDROID) || defined(C10_IPHONE) || defined _AIX
 C10_API LocalDispatchKeySet tls_local_dispatch_key_set();
 #else // defined(_MSC_VER) || defined(C10_ANDROID) || defined(C10_IPHONE)
-extern C10_API thread_local PODLocalDispatchKeySet raw_local_dispatch_key_set;
+extern C10_API __thread PODLocalDispatchKeySet raw_local_dispatch_key_set;
 
 inline C10_API LocalDispatchKeySet tls_local_dispatch_key_set() {
   // Don't let people fiddle with the thread_local directly just
