Installation¶
Requirements¶
- Python 3.10 or higher
- PyTorch (installed automatically)
transformers5.x, if you are working with Hugging Face models
Model implementations and architectures change from one transformers version to the next, and
pip install nnsight does not pin the major. These docs are written against 5.x, so check what
you have:
Install from PyPI¶
The simplest way to install NNsight is via pip:
Install from Source¶
For the latest development version, install directly from GitHub:
Or clone the repository and install in editable mode:
Optional Dependencies¶
vLLM Support¶
For high-performance inference with vLLM, install the vllm extra:
Serving¶
nnsight-serve puts one vLLM engine behind HTTP so that clients without a GPU can trace it. The
extra pulls in vLLM plus the server dependencies:
Running the tests¶
The dev extra is everything the test suite needs on top of the core install:
Quantized models¶
Loading a checkpoint in 4 or 8 bits — TransformersModel(..., dtype="nf4") and friends — goes
through bitsandbytes and accelerate. Neither is a dependency of nnsight, so a plain
pip install nnsight leaves you without them:
Verify Installation¶
Next Steps¶
Head to the Quick Start and run your first intervention.