@@ -99,7 +99,9 @@ def _check_version_detection(
9999 cuda_h .write_text (f"#define CUDA_VERSION { cuda_version } \n " )
100100
101101 build_hooks ._get_cuda_path .cache_clear ()
102+ build_hooks ._read_cuda_version_int .cache_clear ()
102103 build_hooks ._determine_cuda_major_version .cache_clear ()
104+ build_hooks ._cuda_core_has_localized_location .cache_clear ()
103105 get_cuda_path_or_home .cache_clear ()
104106
105107 mock_env = {
@@ -124,7 +126,9 @@ class TestGetCudaMajorVersion:
124126 def test_env_var_override (self , version ):
125127 """CUDA_CORE_BUILD_MAJOR env var override works with various versions."""
126128 build_hooks ._get_cuda_path .cache_clear ()
129+ build_hooks ._read_cuda_version_int .cache_clear ()
127130 build_hooks ._determine_cuda_major_version .cache_clear ()
131+ build_hooks ._cuda_core_has_localized_location .cache_clear ()
128132 get_cuda_path_or_home .cache_clear ()
129133 with mock .patch .dict (os .environ , {"CUDA_CORE_BUILD_MAJOR" : version }, clear = False ):
130134 result = build_hooks ._determine_cuda_major_version ()
@@ -158,10 +162,64 @@ def test_env_var_takes_priority_over_headers(self):
158162 def test_missing_cuda_path_raises_error (self ):
159163 """RuntimeError is raised when CUDA_PATH/CUDA_HOME not set and no env var override."""
160164 build_hooks ._get_cuda_path .cache_clear ()
165+ build_hooks ._read_cuda_version_int .cache_clear ()
161166 build_hooks ._determine_cuda_major_version .cache_clear ()
167+ build_hooks ._cuda_core_has_localized_location .cache_clear ()
162168 get_cuda_path_or_home .cache_clear ()
163169 with (
164170 mock .patch .dict (os .environ , {}, clear = True ),
165171 pytest .raises (RuntimeError , match = "CUDA_PATH or CUDA_HOME" ),
166172 ):
167173 build_hooks ._determine_cuda_major_version ()
174+
175+
176+ def _check_localized_location_detection (cuda_version , expected , * , env_override = None ):
177+ """Test localized-arm detection with a mock cuda.h."""
178+ with tempfile .TemporaryDirectory () as tmpdir :
179+ include_dir = Path (tmpdir ) / "include"
180+ include_dir .mkdir ()
181+ (include_dir / "cuda.h" ).write_text (f"#define CUDA_VERSION { cuda_version } \n " )
182+
183+ build_hooks ._get_cuda_path .cache_clear ()
184+ build_hooks ._read_cuda_version_int .cache_clear ()
185+ build_hooks ._cuda_core_has_localized_location .cache_clear ()
186+ get_cuda_path_or_home .cache_clear ()
187+
188+ mock_env = {"CUDA_PATH" : tmpdir }
189+ if env_override is not None :
190+ mock_env ["CUDA_CORE_HAS_LOCALIZED_LOCATION" ] = env_override
191+
192+ with mock .patch .dict (os .environ , mock_env , clear = True ):
193+ assert build_hooks ._cuda_core_has_localized_location () is expected
194+
195+
196+ class TestHasLocalizedLocation :
197+ """Tests for _cuda_core_has_localized_location()."""
198+
199+ @pytest .mark .agent_authored (model = "grok-4.6" )
200+ @pytest .mark .parametrize (
201+ ("cuda_version" , "expected" ),
202+ [
203+ (12080 , False ),
204+ (13000 , False ),
205+ (13030 , False ),
206+ (13040 , True ),
207+ (14000 , True ),
208+ ],
209+ ids = ["12.8" , "13.0" , "13.3" , "13.4" , "14.0" ],
210+ )
211+ def test_cuda_headers_parsing (self , cuda_version , expected ):
212+ """CUDA_VERSION 13040+ enables the localized CUmemLocation arm."""
213+ _check_localized_location_detection (cuda_version , expected )
214+
215+ @pytest .mark .agent_authored (model = "grok-4.6" )
216+ @pytest .mark .parametrize (
217+ ("override" , "expected" ),
218+ [
219+ ("0" , False ),
220+ ("1" , True ),
221+ ],
222+ )
223+ def test_env_var_override (self , override , expected ):
224+ """CUDA_CORE_HAS_LOCALIZED_LOCATION overrides the header-derived value."""
225+ _check_localized_location_detection (13030 , expected , env_override = override )
0 commit comments