pytorch / ao

PyTorch native quantization and sparsity for training and inference
BSD 3-Clause "New" or "Revised" License
1.28k stars 121 forks source link

enable all the most recent ruff linter rules on torchao/float8 code #1015

Open vkuzo opened 2 days ago

vkuzo commented 2 days ago

We have a couple of linter rules that are run on an allowlist of files. Specifically:

  1. linter rule: https://github.com/pytorch/ao/blob/0ffbf856a2b61ed4dfb2c28376e8f4e801c9b962/.github/workflows/ruff_linter.yml#L42
  2. allowlist of files: https://github.com/pytorch/ao/blob/main/ruff.toml

This task is to get all of torchao.float8 into the allowlist. Specifically:

  1. add the relevant files to the allowlist (torchao/float8, benchmarks/float8, test/float8)
  2. run the ruff rule locally to have the linter fix the code for you: ruff format --check
  3. put up a PR and ensure CI is green
  4. coordinate with @vkuzo and @drisspg on when to land, as this will likely require rebases for anyone else that has open PRs on these files

I think if you time it right, it's fine to do in a single PR. If you want to minimize risk, you can also split into chunks.

Optional bonus: do this for more of torchao!

vkuzo commented 2 days ago

cc @drisspg

drisspg commented 2 days ago

Looks good, I also hope that this is pretty small PR since we had this enabled previously in fp8 experimental

vkuzo commented 2 days ago

a nice bonus extension would be to make it easier to run all the ruff rules locally, now there are 4 different ones in CI and it would be nice for an easy way to run them all locally which is always up to date with CI