From cbb901ac51bd6c41e4243ffb936ef0e2f7ca8ada Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Tue, 26 Jul 2022 12:12:38 -0700 Subject: Boilerplate and test for extract_outliers. --- tests/test_functional.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/test_functional.py b/tests/test_functional.py index 6cbe58f..b508367 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -1856,3 +1856,20 @@ def test_zp(): print(err1, err2, err3, err4, err5, err6) + +def test_extract_outliers(): + shapeA = (128, 128) + idx = torch.randint(0, shapeA[1], size=(10,)).int() + A = torch.randint(-128, 127, size=shapeA, device='cuda').to(torch.int8) + outliers1 = A[:, idx.long()] + + CA, SA = F.transform(A, 'col_turing') + + outliers2 = F.extract_outliers(CA, SA, idx) + + assert outliers2.shape[0] == shapeA[0] + assert outliers2.shape[1] == idx.numel() + + + + torch.testing.assert_allclose(outliers1, outliers2) -- cgit v1.2.3 From bcab99ec877ba063543bd7c03ba1cdd1b06e8078 Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Tue, 26 Jul 2022 17:39:30 -0700 Subject: Working outlier extraction for Turing. --- tests/test_functional.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/test_functional.py b/tests/test_functional.py index b508367..4d06447 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -1858,18 +1858,21 @@ def test_zp(): def test_extract_outliers(): - shapeA = (128, 128) - idx = torch.randint(0, shapeA[1], size=(10,)).int() - A = torch.randint(-128, 127, size=shapeA, device='cuda').to(torch.int8) - outliers1 = A[:, idx.long()] - - CA, SA = F.transform(A, 'col_turing') + for i in range(k): + shapeA = (4096, 4*4096) + idx = torch.unique(torch.randint(0, shapeA[1], size=(10,)).int()).cuda() + #idx = torch.Tensor([32]).int().cuda() + A = torch.randint(-128, 127, size=shapeA, device='cuda').to(torch.int8) + outliers1 = A[:, idx.long()] - outliers2 = F.extract_outliers(CA, SA, idx) + CA, SA = F.transform(A, 'col_turing') - assert outliers2.shape[0] == shapeA[0] - assert outliers2.shape[1] == idx.numel() + outliers2 = F.extract_outliers(CA, SA, idx) + assert outliers2.shape[0] == shapeA[0] + assert outliers2.shape[1] == idx.numel() + #print(outliers1) + #print(outliers2) - torch.testing.assert_allclose(outliers1, outliers2) + torch.testing.assert_allclose(outliers1, outliers2) -- cgit v1.2.3 From 32fa459ed7c812c79e847145004061f21b7ac0d9 Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Tue, 26 Jul 2022 18:15:51 -0700 Subject: Added col_ampere outlier extraction kernel. --- tests/test_functional.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_functional.py b/tests/test_functional.py index 4d06447..2d58fac 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -1859,9 +1859,9 @@ def test_zp(): def test_extract_outliers(): for i in range(k): - shapeA = (4096, 4*4096) + shapeA = (4096, 4096*4) idx = torch.unique(torch.randint(0, shapeA[1], size=(10,)).int()).cuda() - #idx = torch.Tensor([32]).int().cuda() + #idx = torch.Tensor([0]).int().cuda() A = torch.randint(-128, 127, size=shapeA, device='cuda').to(torch.int8) outliers1 = A[:, idx.long()] @@ -1872,7 +1872,13 @@ def test_extract_outliers(): assert outliers2.shape[0] == shapeA[0] assert outliers2.shape[1] == idx.numel() - #print(outliers1) - #print(outliers2) + torch.testing.assert_allclose(outliers1, outliers2) + + CA, SA = F.transform(A, 'col_ampere') + + outliers2 = F.extract_outliers(CA, SA, idx) + + assert outliers2.shape[0] == shapeA[0] + assert outliers2.shape[1] == idx.numel() torch.testing.assert_allclose(outliers1, outliers2) -- cgit v1.2.3