To perform standard trajectory prediction, load the model using Alpamayo1_5.from_pretrained, process the scene images and ego history using a helper processor, and call sample_trajectories_from_data_with_vlm_rollout. The model generates a Chain-of-Causation (CoC) reasoning trace followed by predicted trajectories.
import torch
from alpamayo1_5.models.alpamayo1_5 import Alpamayo1_5
from alpamayo1_5 import helper
# Load model
model = Alpamayo1_5.from_pretrained("nvidia/Alpamayo-1.5-10B", dtype=torch.bfloat16).to("cuda")
processor = helper.get_processor(model.tokenizer)
# Prepare inputs (assuming data_scene1 is loaded via load_physical_aiavdataset)
messages = helper.create_message(
data_scene1["image_frames"].flatten(0, 1),
camera_indices=data_scene1["camera_indices"],
)
inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=False,
continue_final_message=True,
return_dict=True,
return_tensors="pt",
)
model_inputs = helper.to_device(
{
"tokenized_data": inputs,
"ego_history_xyz": data_scene1["ego_history_xyz"],
"ego_history_rot": data_scene1["ego_history_rot"],
},
"cuda",
)
# Run inference
with torch.autocast("cuda", dtype=torch.bfloat16):
pred_xyz, pred_rot, extra = model.sample_trajectories_from_data_with_vlm_rollout(
data=model_inputs,
top_p=0.98,
temperature=0.6,
num_traj_samples=1,
max_generation_length=256,
return_extra=True,
)
print("Chain-of-Causation:\n", extra["cot"][0])