nnsight on NDIF¶
NDIF (the National Deep Inference Fabric) is a public service that keeps large models loaded on
GPUs. With remote=True, nnsight sends your trace block to NDIF, runs it there on the real
model, and returns the values you saved. The weights stay on NDIF, so your machine needs no GPU.
Use it for a model that does not fit on your hardware. A model you can run yourself is faster to trace locally, and the block is the same.
First run¶
from nnsight import TransformersModel
model = TransformersModel("Qwen/Qwen3-8B") # the module tree only; no weights are loaded
with model.trace("The Eiffel Tower is in the city of", remote=True):
hidden = model.model.layers[10].output.save() # [1, tokens, 4096]
token = model.lm_head.output[0, -1].argmax(-1).save()
print(hidden.shape, model.tokenizer.decode(token))
# torch.Size([1, 10, 4096]) Paris
While the job runs, one status line shows where it is: QUEUED, RUNNING, COMPLETED.
Running jobs lists every status.
What differs from a local trace¶
- The model has no weights on your machine. Build it without
dispatch=True. You get the module tree, which is all a block is written against. - Only saved values come back. A value you do not
.save()stays on the server and is dropped when the job ends. Saved tensors arrive on the CPU. - NDIF has to load the model. A model that is already loaded runs your block as soon as its turn comes. One that is not is loaded first, which takes longer. See Models.
- Your block waits its turn. Each loaded copy of a model runs one request at a time.
- What the block uses is uploaded with it. A tensor you made locally travels in the request and arrives on the CPU. Move it to the activation's device and dtype where you use it.
- Several traces belong in one session.
model.session(remote=True)runs them as one job.
Writing a block and Sessions cover each of these.
Pages¶
| Page | What it covers |
|---|---|
| How NDIF works | A step-by-step walk through what happens to a request |
| Get set up | Install, API key, the settings you can change |
| Models | What is loaded, what happens when your model is not, what names a model |
| Writing a block | What comes back, what is sent, helpers, print, generation, gradients |
| Sessions | Several traces, loops and imports in one job |
| Running jobs | The status line, and waiting, polling or awaiting a job |
| Code on the server | Installed packages, sending a library of your own, files from the Hub, what needs trusted access |
| Debugging | Reading an error, request sizes, a dry run on your machine, what a job cost |
| Limits and errors | The limits on a job, and what each error message means |
| Patterns | Data and weights loaded on the server, sweeps, training, many jobs, adapters, long runs |
| Anti-patterns | Common mistakes, what each one costs, and the fix |
| FAQ | Short answers |
| Self-hosting | Pointing nnsight at your own NDIF server |
The snippets in this section were run against api.ndif.us on Qwen/Qwen3-8B, with an API key
that has no special access. The outputs shown are what came back.