From afa9753d399168ecc6506b4fcf2f6447735ae40e Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Tue, 14 May 2024 21:16:14 -0700 Subject: [PATCH] ruff cleanup (#4594) * check editor config * no editorconfig, it doesn't work * ruff cleanups --- .editorconfig | 4 ---- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 2 +- ruff.toml | 8 +++++--- test/imported/test_indexing.py | 1 - test/test_fuzz_shape_ops.py | 2 -- test/test_nn.py | 1 - tinygrad/codegen/kernel.py | 1 - 8 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index f5607c0582..0000000000 --- a/.editorconfig +++ /dev/null @@ -1,4 +0,0 @@ -# 2 space indentation -[*.py] -indent_style = space -indent_size = 2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2031342b93..87b4dc370a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,7 +84,7 @@ jobs: - name: Lint with ruff run: | pip3 install --upgrade --force-reinstall ruff - python3 -m ruff check . --preview + python3 -m ruff check . - name: Lint tinygrad with pylint run: python -m pylint tinygrad/ - name: Run mypy diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 804712aef0..267a37a9c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: pass_filenames: false - id: ruff name: ruff - entry: ruff check . --preview + entry: ruff check . language: system always_run: true pass_filenames: false diff --git a/ruff.toml b/ruff.toml index fd32a4958d..d2a221c6d2 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,7 +1,9 @@ indent-width = 2 +preview = true +target-version = "py38" lint.select = [ - "F", + "F", # Pyflakes "W6", "E71", "E72", @@ -10,8 +12,8 @@ lint.select = [ # "E124", "E203", # whitespace-before-punctuation "E272", # multiple-spaces-before-keyword - # "E303", - # "E304", + "E303", + "E304", "E501", # line-too-long # "E502", "E702", # multiple-statements-on-one-line-semicolon diff --git a/test/imported/test_indexing.py b/test/imported/test_indexing.py index f7a82efb8f..a6e8598d9e 100644 --- a/test/imported/test_indexing.py +++ b/test/imported/test_indexing.py @@ -378,7 +378,6 @@ class TestIndexing(unittest.TestCase): numpy_testing_assert_equal_helper(strided[rows, columns], np.array([[1, 3], [11, 13]])) - # setting values # strided is [[10, 11], diff --git a/test/test_fuzz_shape_ops.py b/test/test_fuzz_shape_ops.py index 8f20efc5c6..7f65571751 100644 --- a/test/test_fuzz_shape_ops.py +++ b/test/test_fuzz_shape_ops.py @@ -25,7 +25,6 @@ def st_shape(draw) -> tuple[int, ...]: assume(prod([d for d in s if d]) <= 1024 ** 4) return s - def tensors_for_shape(s:tuple[int, ...]) -> tuple[torch.tensor, Tensor]: x = np.arange(prod(s)).reshape(s) return torch.from_numpy(x), Tensor(x) @@ -51,7 +50,6 @@ class TestShapeOps(unittest.TestCase): assert len(tor) == len(ten) assert all([np.array_equal(tor.numpy(), ten.numpy()) for (tor, ten) in zip(tor, ten)]) - @settings.get_profile(__file__) @given(st_shape(), st_int32, st_int32) def test_chunk(self, s:tuple[int, ...], dim:int, num:int): diff --git a/test/test_nn.py b/test/test_nn.py index 98ddac7ffe..ad72979d7d 100755 --- a/test/test_nn.py +++ b/test/test_nn.py @@ -182,7 +182,6 @@ class TestNN(unittest.TestCase): np.testing.assert_allclose(gb.numpy(), torch_layer.bias.grad.numpy(), atol=5e-4, rtol=1e-5) np.testing.assert_allclose(gx.numpy(), torch_x.grad.numpy(), atol=5e-4, rtol=1e-5) - @unittest.skipIf(CI and Device.DEFAULT == "WEBGPU", "runs out of memory in CI") def test_conv_transpose1d(self): BS, C1, W = 4, 16, 224//4 diff --git a/tinygrad/codegen/kernel.py b/tinygrad/codegen/kernel.py index f8ebefe8d9..ddab479949 100644 --- a/tinygrad/codegen/kernel.py +++ b/tinygrad/codegen/kernel.py @@ -388,7 +388,6 @@ class Kernel: return True return False - def apply_tensor_cores(self, use_tensor_cores=1, extra_opts:Optional[List[Opt]]=None, axis:int=0, tc_opt:int=getenv("TC_OPT")) -> bool: """ Attempts to apply a tensor core optimization to the kernel. If one exists and applies properly, return true, otherwise return false. Tensor cores are optimized instructions that matrix multiply-accumulate across a wave of threads: D(M, N) = A(M, K) * B(K, N) + C(M, N).