Contributing guide#
This guide summarizes how to set up a development environment, follow project conventions, run checks locally, and align with the CI pipeline. For test commands and layout, see Testing Guide. The repository root CONTRIBUTING.md summarizes key contribution guidelines, such as branch naming conventions, commit message style, and pull request requirements.
1. Development setup#
Clone the repository (include submodules):
git clone --recurse-submodules https://github.com/AMD-AGI/Primus.git cd Primus
Install Python dependencies:
pip install -r requirements.txt
Install pre-commit hooks (recommended):
pip install pre-commit pre-commit install
Optional—JAX / MaxText work:
pip install -r requirements-jax.txt
Quick verification (from the repository root, with Primus on your
PATHor via the bundled launcher):./primus-cli direct -- benchmark gemm --M 4096 --N 4096 --K 4096
2. Code style#
Configuration lives in .pre-commit-config.yaml. Hooks run automatically on git commit after pre-commit install.
Tool |
Version |
Purpose |
|---|---|---|
black |
24.8.0 |
Python formatter, line length 110 |
isort |
5.13.2 |
Import sorting, profile |
autoflake |
2.3.1 |
Removes unused imports and variables (see hook args for star imports and |
shellcheck |
0.10.0.1 (shellcheck-py) |
Shell script analysis |
pre-commit-hooks |
v4.0.1 |
|
Manual one-off runs (repository root):
black --line-length=110 .
isort --profile black .
autoflake --remove-all-unused-imports --remove-unused-variables --expand-star-imports --ignore-init-module-imports --recursive --in-place .
CI runs pre-commit run --all-files --show-diff-on-failure, so lint behavior follows .pre-commit-config.yaml rather than a separate hand-written list of formatter commands.
3. Branch naming convention#
Format:
<type>/<scope>/<short-description>
Types: feat, fix, docs, refactor, test, chore, ci
Scope (optional): engine, model, scheduler, docs, tests, config, or another short area name.
Examples:
feat/model/implement-moe-routingfix/engine/init-error
4. Commit convention#
Follow Conventional Commits:
<type>(<scope>): <description>
Examples:
feat(model): add MOE routing functionalityfix(engine): resolve initialization error
5. Testing requirements#
Before opening a pull request, run the following from the repository root:
Shell integration tests:
bash ./tests/runner/run_all_tests.shPython unit tests:
pytest tests/unit_tests/ --maxfail=1 -s
Backend / trainer tests (GPU, datasets, and sometimes Hugging Face tokens): run the relevant file under
tests/trainer/when your change touches that backend. See Testing Guide.Pre-commit on all files:
pre-commit run --all-files
6. Pull request process#
Fork the repository (unless you have write access and use a feature branch).
Create a branch that follows the naming convention above.
Implement changes and commit using the commit message convention.
Run tests and pre-commit locally.
Push and open a pull request with a clear description.
Reference related issues when applicable.
Request reviewers.
Address review feedback.
Ensure CI passes (lint and unit tests on the paths your PR triggers).
7. CI pipeline#
The workflow .github/workflows/ci.yaml defines how changes are validated.
Triggers: workflow_dispatch, pushes to main, tags matching v*, and pull requests.
Jobs (high level):
code-lint: Ubuntu, Python 3.12—installspre-commitand runspre-commit run --all-files --show-diff-on-failure, so the checks (black, isort, autoflake, shellcheck, and thepre-commit-hooksset) follow.pre-commit-config.yamlexactly.build-docker: Builds and pushes Docker images (depends oncode-lint).run-unittest-torch: Self-hosted GPU runner—installs dependencies (including Primus-Turbo and AITER as defined in the workflow), runsbash ./tests/runner/run_all_tests.sh,pytestontests/unit_tests/(with a few deselected tests), then Megatron and TorchTitan trainer tests withDATA_PATH,MASTER_PORT,HSA_NO_SCRATCH_RECLAIM=1, andHF_TOKENwhere required.run-unittest-jax: JAX runner—installsrequirements-jax.txt, runs shell tests andpython ./tests/run_unit_tests.py --jaxwith CI-specific environment variables.
Lint checks mirror the pre-commit stack. Trainer jobs require GPU resources and shared secrets (for example HF_TOKEN) in the hosted environment.
For a focused description of local vs CI test commands, see Testing Guide.