mit einem Klick
linting-and-formatting
// Code style and quality rules for NeMo AutoModel — ruff configuration, naming conventions, type hints, docstrings, copyright headers, and the code review checklist.
// Code style and quality rules for NeMo AutoModel — ruff configuration, naming conventions, type hints, docstrings, copyright headers, and the code review checklist.
Maintain the NeMo AutoModel Fern docs site under fern/ — add, update, move, or remove pages; manage redirects, slugs, navigation, and version aliases; run validation and previews.
Guide for onboarding new model families into NeMo AutoModel, including architecture discovery, implementation patterns, registration, and validation.
Dev environment setup for NeMo AutoModel — container-based development, uv package management, installation options, environment variables, and common build pitfalls.
CI/CD reference for NeMo AutoModel — pipeline structure, commit and PR workflow, CI failure investigation, and common failure patterns.
Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings.
Configure NeMo AutoModel job launches for interactive runs, Slurm clusters, and SkyPilot cloud execution.
| name | linting-and-formatting |
| description | Code style and quality rules for NeMo AutoModel — ruff configuration, naming conventions, type hints, docstrings, copyright headers, and the code review checklist. |
| when_to_use | Writing or reviewing code for style compliance, fixing ruff errors, understanding type hint or docstring conventions, copyright header questions, or pre-commit failures. |
Single source of truth for code style in NeMo AutoModel. Read this before writing new code or reviewing PRs.
Run before every commit:
# Auto-format all source files (line length, quotes, trailing commas, etc.)
ruff format .
# Lint and auto-fix what can be fixed (unused imports, isort, etc.)
ruff check --fix .
To check without modifying files:
ruff format --check . # exits non-zero if any file would change
ruff check . # exits non-zero on lint violations
To lint a single file or directory:
ruff format nemo_automodel/components/models/llama/model.py
ruff check --fix nemo_automodel/components/models/llama/
pyproject.toml)| Rule | ID | Description |
|---|---|---|
| Line length | — | 120 characters (formatter) |
| Quote style | — | Double quotes |
| Unused imports | F401 | Auto-removed by --fix (ignored in __init__.py) |
| Unused variables | F841 | Auto-removed by --fix |
| Undefined names | F821 | Error |
| f-string without placeholders | F541 | Error |
| Import sorting | I | isort-compatible ordering, auto-fixed |
| Docstring convention | D101/D103 | Google style (currently ignored — selected then suppressed) |
| No pickle | S301/S403 | Security: forbids pickle.load |
| Ambiguous variable names | E741 | Error (e.g., l, O, I) |
Tests (tests/) are excluded from lint checks. Docstring rules (D) are
also relaxed in test files.
Required on all public API functions and methods.
T | None instead of Optional[T]X | Y instead of Union[X, Y]list, dict, tuple) instead of typing equivalentsGoogle-style where docstrings are added:
def build_model(config: dict) -> torch.nn.Module:
"""Instantiate and shard the model from config.
Args:
config: Mapping with _target_ and model hyperparameters.
Returns:
Fully initialized model ready for distributed training.
"""
Every Python file must start with the NVIDIA copyright block. Do not remove or modify it. Use the current year (2026).
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
safe_import() from
nemo_automodel.shared.import_utils. Never let an optional import crash
module loading.import-linter
(see pyproject.toml).print() — use logging.getLogger(__name__)safe_import()components/ subdirectories