From ecf3aa0d7c932378b0d66b84ddaaecc95b6905ef Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Mon, 23 Sep 2024 20:13:01 -0700 Subject: [PATCH 1/5] Correcting Misleading Test Skip Reasons. --- .../graphbolt/impl/test_gpu_cached_feature.py | 26 ++++++++++++------- .../impl/test_hetero_cached_feature.py | 15 ++++++----- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py index 5d503aabda59..bcdf74da69d3 100644 --- a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py @@ -16,11 +16,21 @@ def to_on_disk_numpy(test_dir, name, t): np.save(path, t.cpu().numpy()) return path +def _skip_condition_CachedFeature(): + return (F._default_context_str != "gpu") or \ + (torch.cuda.get_device_capability()[0] < 7) + + +def _reson_to_skip_CachedFeature(): + if F._default_context_str != "gpu": + return "GPUCachedFeature tests are available only on GPU." + + return "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." + @unittest.skipIf( - F._default_context_str != "gpu" - or torch.cuda.get_device_capability()[0] < 7, - reason="GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", + _skip_condition_CachedFeature(), + reason=_reson_to_skip_CachedFeature(), ) @pytest.mark.parametrize( "dtype", @@ -116,9 +126,8 @@ def test_gpu_cached_feature(dtype, cache_size_a, cache_size_b): @unittest.skipIf( - F._default_context_str != "gpu" - or torch.cuda.get_device_capability()[0] < 7, - reason="GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", + _skip_condition_CachedFeature(), + reason=_reson_to_skip_CachedFeature(), ) @pytest.mark.parametrize( "dtype", @@ -155,9 +164,8 @@ def test_gpu_cached_feature_read_async(dtype, pin_memory): @unittest.skipIf( - F._default_context_str != "gpu" - or torch.cuda.get_device_capability()[0] < 7, - reason="GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", + _skip_condition_CachedFeature(), + reason=_reson_to_skip_CachedFeature(), ) @unittest.skipIf( not torch.ops.graphbolt.detect_io_uring(), diff --git a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py index 620999e2a6a4..edfe3a66dd37 100644 --- a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py @@ -1,3 +1,4 @@ +import unittest import backend as F import pytest @@ -6,17 +7,17 @@ from dgl import graphbolt as gb +@unittest.skipIf( + F._default_context_str != "gpu" + or torch.cuda.get_device_capability()[0] < 7, + reason="GPUCachedFeature tests are available only on GPU." + if F._default_context_str != "gpu" + else "GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", +) @pytest.mark.parametrize( "cached_feature_type", [gb.cpu_cached_feature, gb.gpu_cached_feature] ) def test_hetero_cached_feature(cached_feature_type): - if cached_feature_type == gb.gpu_cached_feature and ( - F._default_context_str != "gpu" - or torch.cuda.get_device_capability()[0] < 7 - ): - pytest.skip( - "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." - ) device = F.ctx() if cached_feature_type == gb.gpu_cached_feature else None pin_memory = cached_feature_type == gb.gpu_cached_feature From ae6b970122e19afca6615a11de2e0fd8e54b7362 Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Wed, 25 Sep 2024 10:24:32 -0700 Subject: [PATCH 2/5] Changes suggested by PR reviewer. --- .../graphbolt/impl/test_gpu_cached_feature.py | 15 ++++++++------- .../graphbolt/impl/test_gpu_graph_cache.py | 2 +- .../impl/test_hetero_cached_feature.py | 17 +++++++++-------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py index bcdf74da69d3..668f41ff8970 100644 --- a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py @@ -17,20 +17,21 @@ def to_on_disk_numpy(test_dir, name, t): return path def _skip_condition_CachedFeature(): - return (F._default_context_str != "gpu") or \ - (torch.cuda.get_device_capability()[0] < 7) + return (F._default_context_str != "gpu") or ( + torch.cuda.get_device_capability()[0] < 7 + ) -def _reson_to_skip_CachedFeature(): +def _reason_to_skip_CachedFeature(): if F._default_context_str != "gpu": - return "GPUCachedFeature tests are available only on GPU." + return "GPUCachedFeature tests are available only when testing the GPU backend." return "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." @unittest.skipIf( _skip_condition_CachedFeature(), - reason=_reson_to_skip_CachedFeature(), + reason=_reason_to_skip_CachedFeature(), ) @pytest.mark.parametrize( "dtype", @@ -127,7 +128,7 @@ def test_gpu_cached_feature(dtype, cache_size_a, cache_size_b): @unittest.skipIf( _skip_condition_CachedFeature(), - reason=_reson_to_skip_CachedFeature(), + reason=_reason_to_skip_CachedFeature(), ) @pytest.mark.parametrize( "dtype", @@ -165,7 +166,7 @@ def test_gpu_cached_feature_read_async(dtype, pin_memory): @unittest.skipIf( _skip_condition_CachedFeature(), - reason=_reson_to_skip_CachedFeature(), + reason=_reason_to_skip_CachedFeature(), ) @unittest.skipIf( not torch.ops.graphbolt.detect_io_uring(), diff --git a/tests/python/pytorch/graphbolt/impl/test_gpu_graph_cache.py b/tests/python/pytorch/graphbolt/impl/test_gpu_graph_cache.py index 6c6d242f14c1..dee0fb974e4d 100644 --- a/tests/python/pytorch/graphbolt/impl/test_gpu_graph_cache.py +++ b/tests/python/pytorch/graphbolt/impl/test_gpu_graph_cache.py @@ -11,7 +11,7 @@ @unittest.skipIf( F._default_context_str != "gpu" or torch.cuda.get_device_capability()[0] < 7, - reason="GPUCachedFeature tests are available only on GPU." + reason="GPUCachedFeature tests are available only when testing the GPU backend." if F._default_context_str != "gpu" else "GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", ) diff --git a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py index edfe3a66dd37..0686e4c1cfcf 100644 --- a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py @@ -1,4 +1,3 @@ -import unittest import backend as F import pytest @@ -7,17 +6,19 @@ from dgl import graphbolt as gb -@unittest.skipIf( - F._default_context_str != "gpu" - or torch.cuda.get_device_capability()[0] < 7, - reason="GPUCachedFeature tests are available only on GPU." - if F._default_context_str != "gpu" - else "GPUCachedFeature requires a Volta or later generation NVIDIA GPU.", -) @pytest.mark.parametrize( "cached_feature_type", [gb.cpu_cached_feature, gb.gpu_cached_feature] ) def test_hetero_cached_feature(cached_feature_type): + if cached_feature_type == gb.gpu_cached_feature and ( + F._default_context_str != "gpu" + or torch.cuda.get_device_capability()[0] < 7 + ): + pytest.skip( + "GPUCachedFeature tests are available only when testing the GPU backend." + if F._default_context_str != "gpu" else + "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." + ) device = F.ctx() if cached_feature_type == gb.gpu_cached_feature else None pin_memory = cached_feature_type == gb.gpu_cached_feature From 43b54a16be2bd32bf013a34b87b318db06922c30 Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Wed, 25 Sep 2024 10:30:46 -0700 Subject: [PATCH 3/5] Fixing lint problem --- .../pytorch/graphbolt/impl/test_hetero_cached_feature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py index 0686e4c1cfcf..f3caf34da38e 100644 --- a/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_hetero_cached_feature.py @@ -16,8 +16,8 @@ def test_hetero_cached_feature(cached_feature_type): ): pytest.skip( "GPUCachedFeature tests are available only when testing the GPU backend." - if F._default_context_str != "gpu" else - "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." + if F._default_context_str != "gpu" + else "GPUCachedFeature requires a Volta or later generation NVIDIA GPU." ) device = F.ctx() if cached_feature_type == gb.gpu_cached_feature else None pin_memory = cached_feature_type == gb.gpu_cached_feature From c13496030e55e2419a0d2ee743bd457281dfb92b Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Wed, 25 Sep 2024 10:35:02 -0700 Subject: [PATCH 4/5] Fixing lint problem --- tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py index 668f41ff8970..6c6374e3cd4f 100644 --- a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py @@ -16,6 +16,7 @@ def to_on_disk_numpy(test_dir, name, t): np.save(path, t.cpu().numpy()) return path + def _skip_condition_CachedFeature(): return (F._default_context_str != "gpu") or ( torch.cuda.get_device_capability()[0] < 7 From 930518cb7dc6927d64983a1c2903b47b31790e78 Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Wed, 25 Sep 2024 11:34:13 -0700 Subject: [PATCH 5/5] Renaming two functions --- .../graphbolt/impl/test_gpu_cached_feature.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py index 6c6374e3cd4f..d2e046389b56 100644 --- a/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py +++ b/tests/python/pytorch/graphbolt/impl/test_gpu_cached_feature.py @@ -17,13 +17,13 @@ def to_on_disk_numpy(test_dir, name, t): return path -def _skip_condition_CachedFeature(): +def _skip_condition_cached_feature(): return (F._default_context_str != "gpu") or ( torch.cuda.get_device_capability()[0] < 7 ) -def _reason_to_skip_CachedFeature(): +def _reason_to_skip_cached_feature(): if F._default_context_str != "gpu": return "GPUCachedFeature tests are available only when testing the GPU backend." @@ -31,8 +31,8 @@ def _reason_to_skip_CachedFeature(): @unittest.skipIf( - _skip_condition_CachedFeature(), - reason=_reason_to_skip_CachedFeature(), + _skip_condition_cached_feature(), + reason=_reason_to_skip_cached_feature(), ) @pytest.mark.parametrize( "dtype", @@ -128,8 +128,8 @@ def test_gpu_cached_feature(dtype, cache_size_a, cache_size_b): @unittest.skipIf( - _skip_condition_CachedFeature(), - reason=_reason_to_skip_CachedFeature(), + _skip_condition_cached_feature(), + reason=_reason_to_skip_cached_feature(), ) @pytest.mark.parametrize( "dtype", @@ -166,8 +166,8 @@ def test_gpu_cached_feature_read_async(dtype, pin_memory): @unittest.skipIf( - _skip_condition_CachedFeature(), - reason=_reason_to_skip_CachedFeature(), + _skip_condition_cached_feature(), + reason=_reason_to_skip_cached_feature(), ) @unittest.skipIf( not torch.ops.graphbolt.detect_io_uring(),