Debugging¶
This page covers the tools for finding out why a remote job failed or was slow: the error itself, the sizes of what was sent and returned, a dry run on your machine, a comparison of package versions, and the cost the server reports.
Read the error¶
An error on the server is raised on your machine as a RemoteError. Its message is the
server's traceback, and the last lines point at your own line.
from nnsight import TransformersModel
model = TransformersModel("Qwen/Qwen3-8B")
with model.trace("The Eiffel Tower is in the city of", remote=True):
hidden = model.model.layers[10].output
wrong = hidden @ hidden # shapes do not match
token = model.lm_head.output[0, -1].argmax(-1).save()
# RemoteError: Traceback (most recent call last):
# ...
# wrong = hidden @ hidden
# ~~~~~~~^~~~~~~~
# ...
# RuntimeError: Expected size for first two dimensions of batch2 tensor to be: [1, 4096] but got: [1, 10].
Limits and errors lists the messages NDIF writes itself.
See what a job sends and receives¶
verbose=True prints the size of the request, one line per status with the time spent in it,
and the size of the result.
with model.trace("The Eiffel Tower is in the city of", remote=True, verbose=True):
token = model.lm_head.output[0, -1].argmax(-1).save()
# [remote] payload: 5,363 bytes (compressed)
# ◉ [981e8920fda94484a67ed6d534053e8b] RECEIVED (0.0s) Your job has been received and is waiting to be queued.
# ◎ [981e8920fda94484a67ed6d534053e8b] QUEUED (0.0s) Added to Queue at position 1.
# ◈ [981e8920fda94484a67ed6d534053e8b] DISPATCHED (0.0s) Your job has been sent to the model deployment.
# ● [981e8920fda94484a67ed6d534053e8b] RUNNING (0.0s) Your job has started running.
# ✓ [981e8920fda94484a67ed6d534053e8b] COMPLETED (0.5s) Your job has been completed.
# [remote] result: 618 bytes
A request of many megabytes means the block uses a large local value (Writing a block). A large result means the block saves more than it needs.
CONFIG.APP.DEBUG = True does the same for every job, and also keeps nnsight's own frames in
tracebacks.
Print from the block¶
print inside a block runs on the server and shows up as a LOG line while the job runs
(Writing a block). Use it to check a shape or a value partway through.
Dry run on your machine¶
remote="local" packs the block as a real request, unpacks it the way the server would, and
runs it on a model whose weights you have loaded. It does not contact NDIF. It needs the
weights, so use a small model with the same module names.
from nnsight import TransformersModel
small = TransformersModel("Qwen/Qwen3-0.6B", dispatch=True)
with small.trace("The Eiffel Tower is in the city of", remote="local", verbose=True):
token = small.lm_head.output[0, -1].argmax(-1).save()
print(small.tokenizer.decode(token))
# [local] payload: 60,544 bytes
# [local] hid 921 modules, 1 paths
# Paris
The first line is the size of the request. The second says the block was unpacked with your own modules hidden, as it would be on the server.
The dry run finds problems with sending the block:
| Problem | What the dry run raises |
|---|---|
| The block uses code from a file that would not be sent | ModuleNotFoundError |
| The block uses a value that cannot be sent, such as a lock or an open file | TypeError: cannot pickle ... |
It does not find a package that is installed on your machine and missing on NDIF. Check
those with compare(). If the missing package is your own library,
register it.
Compare package versions¶
A block that works locally and fails on NDIF often depends on a package version. compare()
lists the server's packages beside yours and marks the ones that differ.
Differences in nnsight, torch and transformers matter most. They come first in the table.
Code on the server shows the output.
What a job cost¶
After a job, tracer.backend.meta holds what the server measured.
with model.trace("The Eiffel Tower is in the city of", remote=True) as tracer:
token = model.lm_head.output[0, -1].argmax(-1).save()
print(tracer.backend.meta)
# {'runtime': 0.3316, 'max_memory_usage': 4596224, 'max_mem_by_gpu': {'3': 4596224}, 'max_mem_pct_by_gpu': {'3': 0.07}}
| Key | Meaning |
|---|---|
runtime |
Seconds your job ran on the server. |
max_mem_by_gpu |
Peak bytes your job used on each GPU, beyond the model's weights. Keys are GPU ids as strings. |
max_mem_pct_by_gpu |
That peak as a percentage of the memory the job had available on each GPU. |
max_memory_usage |
The largest value in max_mem_by_gpu. |
A failed job reports its cost too. After an out-of-memory error, alloc_shortfall_by_gpu says
how many bytes of the refused allocation did not fit, per GPU.
from nnsight.intervention.backends.remote import RemoteError
try:
with model.trace(many_prompts, remote=True) as tracer:
hidden = model.model.layers[10].output.save()
except RemoteError:
print(tracer.backend.meta["alloc_shortfall_by_gpu"]) # GPU id -> bytes
For a session, read session.backend.meta from with model.session(remote=True) as session:.