Refine Allocator Config error message friendly (#165288)

* __->__ #165288
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165288
Approved by: https://github.com/albanD
This commit is contained in:
Yu, Guangye
2025-10-17 17:16:41 +00:00
committed by PyTorch MergeBot
parent 5d62b63a76
commit 4888ed440e
4 changed files with 23 additions and 22 deletions

View File

@ -4582,21 +4582,21 @@ class TestCudaMallocAsync(TestCase):
reg_mem = torch.cuda.memory_stats()[key_allocated]
self.assertEqual(reg_mem - start_mem, nbytes)
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings("foo:1,bar:2")
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings(
"garbage_collection_threshold:1.2"
)
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings("max_split_size_mb:2")
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings("release_lock_on_cudamalloc:none")
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings(
"pinned_use_cuda_host_register:none"
)
@ -4606,7 +4606,7 @@ class TestCudaMallocAsync(TestCase):
"pinned_num_register_threads:none"
)
with self.assertRaises(RuntimeError):
with self.assertRaises(ValueError):
torch.cuda.memory._set_allocator_settings(
"pinned_num_register_threads:1024"
)