Skip to content

Commit ba2d3b1

Browse files
authored
add in formatting skip everything (#779)
ghstack-source-id: 34fe56595eac4d1a2fecb07a230307c0b2b767d7 Pull Request resolved: #688
1 parent d0e6246 commit ba2d3b1

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

Diff for: .github/workflows/ruff_linter.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Code Analysis with Ruff
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9"]
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install ruff
25+
- name: Analyzing the code with ruff
26+
run: |
27+
ruff check .
28+
- name: Check well formatted code
29+
run: |
30+
ruff format --check

Diff for: .pre-commit-config.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.5.6
15+
hooks:
16+
# Run the linter.
17+
- id: ruff
18+
args: [--fix]
19+
# Run the formatter.
20+
- id: ruff-format

Diff for: dev-requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ tabulate # QOL for printing tables to stdout
1717

1818
# Custom CUDA Extensions
1919
ninja
20+
21+
# Linting
22+
ruff
23+
pre-commit

Diff for: ruff.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Currently, we ignore all files in the project by default.
2+
# We plan to add files in chunks using the 'include' list below.
3+
# To add a new path: Simply add it to the 'include' list.
4+
# Example: To lint all files in every subfolder of 'test', add "test/**/*"
5+
include = [
6+
"torchao/float8/inference.py",
7+
"torchao/float8/float8_utils.py",
8+
]

Diff for: torchao/float8/inference.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
from dataclasses import dataclass
1111

1212
from enum import auto, Enum
13-
from typing import Callable, List, Optional, Tuple
13+
from typing import Callable, Optional, Tuple
1414

1515
import torch
1616
import torch.nn as nn
1717
from torchao.float8.float8_linear_utils import swap_linear_layers
18+
from torchao.float8.float8_utils import is_row_major, pad_tensor_for_matmul
1819

1920
from torchao.float8.float8_tensor import (
2021
Float8Tensor,
@@ -244,9 +245,6 @@ def quantize_to_float8(
244245
)
245246

246247

247-
from torchao.float8.float8_utils import is_row_major, pad_tensor_for_matmul
248-
249-
250248
def preprocess_data(
251249
a_data: torch.Tensor, b_data: torch.Tensor, scaled_mm_config: ScaledMMConfig
252250
) -> Tuple[torch.Tensor, torch.Tensor]:

0 commit comments

Comments
 (0)