Files
The model has 2 classes. The runtime drives the model class, and the model class calls the policy class, which runs the weights. This is the split that Model Structure describes.cosmos3_policy_droid_types.pydeclares the contract: the 3 video tracks, the commands, and the message.cosmos3_policy_droid.pyholds the model class,Cosmos3PolicyDroid. It decides when to predict and sends each chunk.cosmos3_policy_droid_model.pyholds the policy class,Cosmos3PolicyModel. It is plain Python with no Reactor imports. It loads the weights and predicts 1 chunk at a time.cosmos3_policy_droid_assets.pyclones the NVIDIA source and downloads the checkpoint.cosmos3_policy_droid.yamlsets the checkpoint, the NVIDIA source revision, and the sampler settings.
PolicyInput goes to the policy, and PolicyResult comes back.
Contract
The contract is everything a client can send or receive:cosmos3_policy_droid_types.py (simplified)
- Video tracks:
PolicyMediadeclares the 3 inbound tracks. The attribute names are the track names that the client publishes on. - Commands: each
InputFieldonPolicyStatecreates a command namedset_<field>. For example,set_task_descriptionwritestask_description. The runtime checksmax_lengthbefore the model reads the value.moderate=Trueasks the deployment to moderate the task text. - Counters:
_last_executedand_predictedtrack the prediction loop. Fields that start with_create no command, the client cannot see them, and they reset when a session ends. - Message:
ActionPredictionis theaction_predictionmessage. It holds the(32, 8)action array and the chunk number.
reset command with @event.
Loading
The runtime callsload() once per process, before the first session:
cosmos3_policy_droid.py (simplified)
config_path is cosmos3_policy_droid.yaml, set by runtime.config in reactor.yaml. get_weights_path() returns the
folder that holds the NVIDIA source and the weights, set by runtime.weights_path.
Cosmos3PolicyModel.load() then does 4 things:
- Reads
cosmos3_policy_droid.yaml. - Clones the NVIDIA source at the pinned revision, if it is not in the weights folder.
- Builds NVIDIA’s policy service, which downloads the checkpoint and tokenizer into the weights folder.
- Runs 2 warmup predictions, so the first compilation, about 20 seconds, happens before the first session.
Prediction step
The runtime runs the model in a loop of steps. Each step calls 3 methods in order:Check the inputs
process_input() decides whether the model can predict now. It raises ApplicationError when an input is missing. The
runtime then skips the step without calling generate(), and calls process_input() again on the next step:
cosmos3_policy_droid.py (simplified)
process_input()
has the real logic for each check.
The checks run in this order:
- Executed step: after the first chunk,
executed_step_jsonmust hold astepgreater than the last one accepted. When it does, the model asks for a new frame from each camera. - Camera frames: each of the 3 tracks must deliver a new frame. A new frame arrives after the executed step. If the
executed step includes
observation_time_us, a new frame is one captured at or after that time. - Robot state:
proprio_jsonmust parse into rows of 7 joint values and 1 gripper value, all finite.
process_input() records the executed step and returns a PolicyInput. The first chunk skips
the executed-step check.
Predict a chunk
Prediction crosses the 2 classes. The runtime callsgenerate() on the model class. That method hands the input to
generate() on the policy class, which runs the weights:
cosmos3_policy_droid.py (simplified)
cosmos3_policy_droid_model.py (simplified)
(32, 8) action array.
The policy keeps nothing between predictions. Each chunk depends only on the frames, the robot state, and the task in
its PolicyInput. The sampler settings, 4 steps with guidance 3.0, come from cosmos3_policy_droid.yaml.
Send the chunk
process_output() sends the result to the client:
cosmos3_policy_droid.py (simplified)
generate() is a GPU or checkpoint failure.
process_output() raises it again, and the runtime ends the session with an error that the client sees.
Sessions and reset
- Session start:
@session_startedclears the stored frames and asks for a new frame from each camera. - Session end:
@session_endedclears the frames and callsCosmos3PolicyModel.reset(). The policy keeps no state, so its reset is empty. The counters reset with the rest of the state. resetcommand: sets the counters back, so the next chunk is step0and needs no executed step.