This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
AIMET (AI Model Efficiency Toolkit) is a software toolkit for quantizing trained ML models. It supports PyTorch and ONNX frameworks, providing post-training quantization (PTQ), quantization-aware training (QAT), and model compression techniques.
scripts/all/build_and_test.py is the canonical way to build and test AIMET (used by CI and
documented in Docs/overview/install/build_from_source.rst). It manages venv creation, system
dependency installation, and CMake/scikit-build-core configuration -- prefer it over invoking
CMake or pip directly.
# Build aimet-torch (CPU)
python3 scripts/all/build_and_test.py --task build --package aimet_torch
# Build aimet-torch (GPU/CUDA)
python3 scripts/all/build_and_test.py --task build --package aimet_torch --gpu
# Build aimet-onnx (CPU)
python3 scripts/all/build_and_test.py --task build --package aimet_onnx
# Build aimet-onnx (GPU/CUDA)
python3 scripts/all/build_and_test.py --task build --package aimet_onnx --gpu
# Editable install for local development
python3 scripts/all/build_and_test.py --task build --package aimet_torch --gpu -e
# List every available task
python3 scripts/all/build_and_test.py --task list--task test builds the package first if needed, then runs its unit test suite:
# Build (if needed) and run aimet-onnx unit tests
python3 scripts/all/build_and_test.py --task test --package aimet_onnx
# Run tests only, skipping the build step
python3 scripts/all/build_and_test.py --task test --package aimet_torch --only
# Force a rebuild before testing
python3 scripts/all/build_and_test.py --task test --package aimet_torch --force-rebuildFor running a single test file/method directly against an already-installed package, pytest still works as usual:
python -m pytest TrainingExtensions/torch/test/python/test_<name>.py::TestClass::test_method -v
python -m pytest TrainingExtensions/torch/test/python -m "not cuda"Test directories:
TrainingExtensions/torch/test/python/- PyTorch testsTrainingExtensions/onnx/test/python/- ONNX testsTrainingExtensions/common/test/- Common tests
- Formatter: ruff-format (configured in
.pre-commit-config.yaml) - Linter: pylint (configured in
.pylintrc) - Target Python version: 3.10
- Formatter: clang-format (configured in
.clang-format) - Style: Allman braces, 120 column limit, 4 space indent
pip install pre-commit
pre-commit run --all-filesaimet_torch (TrainingExtensions/torch/src/python/aimet_torch/)
- Core PyTorch quantization simulation and QAT
v2/- Latest quantization API (QuantizationSimModel)v1/- Legacy APIadaround/- Adaptive rounding implementationamp/- Automatic mixed precisionexperimental/- Experimental features (omniquant, spinquant, adascale)
aimet_onnx (TrainingExtensions/onnx/src/python/aimet_onnx/)
- ONNX model quantization and optimization
adaround/- AdaRound for ONNXsequential_mse/- SeqMSE optimizationgraph_passes/- ONNX graph transformations
aimet_common (TrainingExtensions/common/src/python/aimet_common/)
- Shared utilities across frameworks
ModelOptimizations/DlQuantization/
- Core C++ quantization library with CUDA kernels
- Pybind11 bindings exposed as
libpymo
aimet_torch.quantsim.QuantizationSimModel- Main quantization simulation classaimet_torch.adaround.adaround_weight.Adaround- AdaRound APIaimet_onnx.quantsim.QuantizationSimModel- ONNX quantization simulation
- Python: Follow pep8, use snake_case for functions/variables, PascalCase for classes
- C++: Follow Google C++ style guide
- Max line length: 100 characters (Python), 120 characters (C++)
- All commits must be signed with DCO (
git commit -s) - Run pre-commit hooks before committing
Editable mode (-e) is not reliable, so set PYTHONPATH explicitly:
# Set PYTHONPATH after build
export PYTHONPATH=$WORKSPACE/aimet/build/staging/universal/lib/python:$PYTHONPATH
# Or for development from source
export PYTHONPATH=$WORKSPACE/aimet/TrainingExtensions/torch/src/python:$WORKSPACE/aimet/TrainingExtensions/common/src/python:$PYTHONPATHpython3 scripts/all/build_and_test.py --task build --package docs
# Output: wheelhouse/Docs/python3 scripts/all/build_and_test.py --task build --package aimet_torch
# Output: wheelhouse/Docs/release_notes.rst entries are for end users deciding whether to upgrade, not a commit log. Keep them concise and user-focused:
- One line per change, phrased as the user-visible effect, not the implementation. Omit internal rationale, benchmarking detail, review-comment history, or multi-PR narration — that belongs in the commit message, not here.
- Group by framework, in this order under each section: ONNX, Torch, Common. Omit a framework subheading entirely if it has no entries for that section.
- Sections, in order:
New Features,Bug fixes and Improvements,Deprecations(only the sections that have entries). - Link every entry to its commit(s) via a short 7-char hash reference (e.g.
(`98862fd`_)), with the full.. _98862fd: https://github.com/qualcomm/aimet/commit/<full-sha>target listed at the bottom of that release's section. Multiple commits for one line:(`abc1234`_, `def5678`_). - Use double-backtick code formatting for API names, class names, and file names (e.g.
``QuantizationSimModel``). - Related small commits that land as one logical change (e.g. a feature plus its follow-up fix) collapse into a single bullet with multiple commit links, not one bullet per commit.
- When in doubt about whether a change belongs: ask "would a user upgrading AIMET care about this?" If it's test-only, CI-only, or an internal refactor with no API/behavior change, leave it out.