Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions .ai/skills/add-mlinter-rule/SKILL.md

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ tags
# ruff
.ruff_cache

# modeling structure lint cache
utils/mlinter/.mlinter_cache.json
# checkers cache
utils/.checkers_cache.json

# modular conversion
Expand Down
14 changes: 7 additions & 7 deletions docs/source/en/modeling_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ specific language governing permissions and limitations under the License.

# Model structure rules

Transformers enforces a set of static rules on every `modeling_*.py`, `modular_*.py`, and `configuration_*.py` file. The [mlinter](https://github.com/huggingface/transformers/tree/main/utils/mlinter) tool checks them as part of `make typing` and errors out if violations are found.
Transformers enforces a set of static rules on every `modeling_*.py`, `modular_*.py`, and `configuration_*.py` file. The [mlinter](https://github.com/huggingface/transformers-mlinter) tool checks them as part of `make typing` and errors out if violations are found.

These are the expected model conventions for adding or changing modeling code. They keep the codebase consistent and ensure compatibility with features like pipeline parallelism, device maps, and weight tying.

Expand All @@ -22,10 +22,10 @@ These are the expected model conventions for adding or changing modeling code. T
`make typing` runs `mlinter` alongside the `ty` type checker. Run `mlinter` on its own with the following commands.

```bash
python -m utils.mlinter # check all modeling files
python -m utils.mlinter --changed-only # check only files changed vs origin/main
python -m utils.mlinter --list-rules # list all rules and their enabled status
python -m utils.mlinter --rule TRF001 # show built-in docs for a specific rule
mlinter # check all modeling files
mlinter --changed-only # check only files changed vs origin/main
mlinter --list-rules # list all rules and their enabled status
mlinter --rule TRF001 # show built-in docs for a specific rule
```

The `--changed-only` flag is the fastest option during development. It only checks the files you've modified relative to the main branch.
Expand All @@ -52,7 +52,7 @@ Use the rule ID to look up the fix in the [rules reference](#rules-reference). T

## Rules reference

Each rule below lists what it enforces and a diff showing the fix. Run `python -m utils.mlinter --rule TRF001` to see the built-in docs for any rule.
Each rule below lists what it enforces and a diff showing the fix. Run `mlinter --rule TRF001` to see the built-in docs for any rule.

<!-- BEGIN RULES REFERENCE -->

Expand Down Expand Up @@ -247,7 +247,7 @@ Don't use `trf-ignore` to silence violations that should be fixed in the code.

### `allowlist_models`

For models with legacy code that can't be fixed immediately, add the model's directory name to the relevant rule's `allowlist_models` list in `utils/mlinter/rules.toml`.
For models with legacy code that can't be fixed immediately, add the model's directory name to the relevant rule's `allowlist_models` list in the [mlinter rules.toml](https://github.com/huggingface/transformers-mlinter/blob/main/mlinter/rules.toml).

```toml
[rules.TRF004]
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"rjieba",
"rouge-score!=0.0.7,!=0.0.8,!=0.1,!=0.1.1",
"ruff==0.14.10",
"transformers-mlinter @ git+https://github.com/huggingface/transformers-mlinter@b9d319ce264c106f97a959d926ef42bc3c0ea4d1",
"ty==0.0.20",
# `sacrebleu` not used in `transformers`. However, it is needed in several tests, when a test calls
# `evaluate.load("sacrebleu")`. This metric is used in the examples that we use to test the `Trainer` with, in the
Expand Down Expand Up @@ -182,7 +183,9 @@ def deps_list(*pkgs):
extras["audio"] += deps_list("kenlm")
extras["video"] = deps_list("av")
extras["timm"] = deps_list("timm")
extras["quality"] = deps_list("datasets", "ruff", "GitPython", "urllib3", "libcst", "rich", "ty", "tomli")
extras["quality"] = deps_list(
"datasets", "ruff", "GitPython", "urllib3", "libcst", "rich", "ty", "tomli", "transformers-mlinter"
)
extras["docs"] = deps_list("hf-doc-builder")
extras["kernels"] = deps_list("kernels")
extras["sentencepiece"] = deps_list("sentencepiece", "protobuf")
Expand Down
Loading
Loading