Skip to content

Running jobs

Every remote trace or session is one job. This page covers what the status line means and the three ways to wait for a job: block until it finishes, poll for it, or await it.

The status line

While a job runs, nnsight prints one line and updates it in place. It passes through these states:

◉ [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.

Each line has the job's id, its status, the time spent in that status, and a message. On the last line the time is the whole job's.

Status Meaning
RECEIVED NDIF accepted the request.
PROVISIONING The model is not loaded. NDIF is finding GPUs for it.
DEPLOYING The model is loading.
QUEUED The job is waiting in the model's queue. The message gives its position.
DISPATCHED The job was handed to a loaded copy of the model.
RUNNING Your block is running.
LOG A line your block printed.
COMPLETED The job finished and the saved values are on their way.
ERROR The job failed. The message is raised on your machine as a RemoteError (Limits and errors).

A model that is loaded skips PROVISIONING and DEPLOYING. How NDIF works shows where each status happens.

Wait for the result

This is the default. The with block returns when the job is done, and the saved values are in your variables.

from nnsight import TransformersModel

model = TransformersModel("Qwen/Qwen3-8B")

with model.trace("The Eiffel Tower is in the city of", remote=True):
    token = model.lm_head.output[0, -1].argmax(-1).save()

print(model.tokenizer.decode(token))
#  Paris

Send now, fetch later

With blocking=False the with block returns as soon as the job is sent. tracer.backend holds the job. Call it to ask NDIF for the result: it returns None until the job is done, then a dict of the saved values, keyed by variable name.

import time

with model.trace("The Eiffel Tower is in the city of", remote=True, blocking=False) as tracer:
    token = model.lm_head.output[0, -1].argmax(-1).save()

job = tracer.backend
print(job.job_id)                       # a 32-character id

while (result := job()) is None:        # one request to NDIF per call
    time.sleep(2)

print(model.tokenizer.decode(result["token"]))
#  Paris

blocking=False works on model.session(...) the same way. A failed job raises RemoteError from the call that fetches it.

Fetch from another process

Keep the job id, and build the job again from it later.

from nnsight.intervention.backends.remote import RemoteBackend

job = RemoteBackend(model.to_model_key(), blocking=False, job_id="the id you kept")
result = job()
print(model.tokenizer.decode(result["token"]))
#  Paris

Await a job

In asyncio code, build an AsyncRemoteBackend, pass it as backend=, and await it for the dict of saved values.

import asyncio
from nnsight.intervention.backends.remote import AsyncRemoteBackend

async def ask(prompt):
    backend = AsyncRemoteBackend(model.to_model_key())
    with model.trace(prompt, backend=backend):
        token = model.lm_head.output[0, -1].argmax(-1).save()
    result = await backend
    return model.tokenizer.decode(result["token"])

print(asyncio.run(ask("The Eiffel Tower is in the city of")))
#  Paris

In a notebook, write await ask(...) in place of asyncio.run(...).

Many jobs at once uses both forms to run a batch of jobs.

Which to use

You are Use
Working in a notebook or a script, one job at a time The default
Sending a long job and doing other work meanwhile blocking=False
Sending many jobs from one script blocking=False, or AsyncRemoteBackend in async code
Running several traces that belong together One session, not several jobs