Files
Liger-Kernel/Makefile
T
jiahao su 1fdb668d35 Update checkstyle and fix the format issue (#1071)
Summary
----------

1. I found that the benchmark_fused_add_rms_norm.py format issue led to
the collective failure of CI. fix it first.
2. The checkstyle script has been updated to enable it to display the
modified logs.

Test

```
>> make checkstyle
ruff check --output-format=concise .; ruff_check_status=$?; \
        ruff format --check --diff .; ruff_format_status=$?; \
        ruff check . --fix; \
        ruff format .; \
        if [ $ruff_check_status -ne 0 ] || [ $ruff_format_status -ne 0 ]; then \
                exit 1; \
        fi
All checks passed!
--- benchmark/scripts/benchmark_fused_add_rms_norm.py
+++ benchmark/scripts/benchmark_fused_add_rms_norm.py
@@ -103,7 +103,7 @@
     elif mode == "backward":
         y, s = y_fwd()
         ms_50, ms_20, ms_80 = triton.testing.do_bench(
-            lambda: (torch.autograd.backward((y, s), (dy, ds), retain_graph=True)),
+            lambda: torch.autograd.backward((y, s), (dy, ds), retain_graph=True),
             grad_to_none=[x, r],
             rep=500,
             quantiles=QUANTILES,

1 file would be reformatted, 226 files already formatted
All checks passed!
1 file reformatted, 226 files left unchanged
make: *** [checkstyle] Error 1
```
2026-02-05 17:09:31 +08:00

74 lines
2.5 KiB
Makefile

.PHONY: test checkstyle test-convergence all serve build clean
all: checkstyle test test-convergence
# Command to run pytest for correctness tests
test:
python -m pytest --disable-warnings \
--cov=src/liger_kernel \
--cov-report=term-missing \
--ignore=test/convergence \
test/
# Command to run coverage report
coverage:
coverage report -m
# Command to run ruff for linting and formatting code
checkstyle:
ruff check --output-format=concise .; ruff_check_status=$$?; \
ruff format --check --diff .; ruff_format_status=$$?; \
ruff check . --fix; \
ruff format .; \
if [ $$ruff_check_status -ne 0 ] || [ $$ruff_format_status -ne 0 ]; then \
exit 1; \
fi
# Command to run pytest for convergence tests
# We have to explicitly set HF_DATASETS_OFFLINE=1, or dataset will silently try to send metrics and timeout (80s) https://github.com/huggingface/datasets/blob/37a603679f451826cfafd8aae00738b01dcb9d58/src/datasets/load.py#L286
test-convergence:
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/fp32/test_mini_models.py
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/fp32/test_mini_models_multimodal.py
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/fp32/test_mini_models_with_logits.py
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/bf16/test_mini_models.py
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/bf16/test_mini_models_multimodal.py
HF_DATASETS_OFFLINE=1 python -m pytest --disable-warnings test/convergence/bf16/test_mini_models_with_logits.py
# Command to run all benchmark scripts and update benchmarking data file
# By default this doesn't overwrite existing data for the same benchmark experiment
# run with `make run-benchmarks OVERWRITE=1` to overwrite existing benchmark data
BENCHMARK_DIR = benchmark/scripts
BENCHMARK_SCRIPTS = $(wildcard $(BENCHMARK_DIR)/benchmark_*.py)
OVERWRITE ?= 0
run-benchmarks:
@for script in $(BENCHMARK_SCRIPTS); do \
echo "Running benchmark: $$script"; \
if [ $(OVERWRITE) -eq 1 ]; then \
python $$script --overwrite; \
else \
python $$script; \
fi; \
done
# MkDocs Configuration
MKDOCS = mkdocs
CONFIG_FILE = mkdocs.yml
SITE_DIR = site
# MkDocs targets
# Serve the documentation
serve:
$(MKDOCS) serve -f $(CONFIG_FILE)
# Build the documentation into the specified site directory
build:
$(MKDOCS) build -f $(CONFIG_FILE) --site-dir $(SITE_DIR)
# Clean the output directory
clean:
rm -rf $(SITE_DIR)/