make style: runs formatters and linters, necessary to pass code style checksmake fix-repo: auto-fixes copies, modular conversions, doc TOCs, docstrings in addition to themake stylefixesmake check-repo— CI-style consistency checks- Many tests are marked as 'slow' and skipped by default in the CI. To run them, use:
RUN_SLOW=1 pytest ...
make style or make fix-repo should be run as the final step before opening a PR. The CI will run make check-repo and fail if any issues are found.
We try to avoid direct inheritance between model-specific files in src/transformers/models/. We have two mechanisms to manage the resulting code duplication:
- The older method is to mark classes or functions with
# Copied from .... Copies are kept in sync bymake fix-repo. Do not edit a# Copied fromblock, as it will be reverted bymake fix-repo. Ideally you should edit the code it's copying from and propagate the change, but you can break the# Copied fromlink if needed. - The newer method is to add a file named
modular_<name>.pyin the model directory.modularfiles can inherit from other models.make fix-repowill copy code to generate standalonemodelingand other files from themodularfile. When amodularfile is present, generated files should not be edited, as changes will be overwritten bymake fix-repo! Instead, edit themodularfile. See docs/source/en/modular_transformers.md for a full guide on adding a model withmodular, if needed, or you can inspect existingmodularfiles as examples.