File size: 3,427 Bytes
314ecfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from typing import Dict, List, NamedTuple, Optional
import torch
from torch import Tensor

class DrivingOutput(NamedTuple):
    time_delta_sec: Tensor  # [B, F] float32
    waypoints: Tensor  # [B, F, 2] float32
    # Auxiliary outputs (MUST be at the end):
    language_tokens: Tensor  # [B, max(len(tokens))]
    trajectory_tokens: Tensor  # [B, F, max(len(tokens))]


class TrainingOutput(NamedTuple):
    loss: Tensor  # [] floating

    loss_averages: Dict[str, Tensor]  # [] floating
    loss_values: Dict[str, Tensor]  # [B] floating
    loss_counts: Dict[str, Tensor]  # [B] int64

    driving_output: Optional[DrivingOutput] = None

class ParamGroup(NamedTuple):
    pattern: str
    lr: float
    weight_decay: float

class DrivingInput(NamedTuple):
    camera_images: torch.Tensor  # [B, T, N, C, H, W] uint8 [0, 255] or preprocessed patches
    image_sizes: torch.Tensor  # image_grid_thw / video_grid_thw for qwen encoders
    camera_intrinsics: torch.Tensor  # [B, N, 3, 3] float32
    camera_extrinsics: torch.Tensor  # [B, N, 4, 4] float32
    vehicle_speed: torch.Tensor  # [B, S] float32 ms
    map_route: torch.Tensor  # [B, 3, RH, RW] uint8 [0, 255] or [B, 2, 2] target points
    target_point: torch.Tensor  # [B, 2] float32
    navigation_command: List[str]
    prompt: Optional[List[str]] = None  # free-form instruction (Action Dreaming)
    objects: Optional[torch.Tensor] = None  # [B, N, FEAT_DIM] object-bank tokens (dataloader.object_bank)
    object_mask: Optional[torch.Tensor] = None  # [B, N] bool, True for real objects

class DrivingLabel(NamedTuple):
    time_delta_sec: Tensor  # [B, F] 0-2 sec
    waypoints: Tensor  # [B, F, 2] 11 future waypoints 0.2s apart
    waypoints_1d: Tensor  # [B, F, 2] 11 future waypoints 0.2s apart
    route_adjusted: Tensor
    waypoints_org: Optional[Tensor] = None  # [B, F, 2] original trajectory (dreamer)
    route_adjusted_org: Optional[Tensor] = None  # [B, R, 2] original route (dreamer)
    future_states: Optional[Tensor] = None  # [B, 4, 64, 1024] fp16 V-JEPA2 future latents
    wm_valid: Optional[Tensor] = None  # [B] bool, False for shift-augmented / uncached samples
    consequence_risk_target: Optional[Tensor] = None  # [B, 10]
    consequence_risk_valid: Optional[Tensor] = None  # [B, 10] bool
    consequence_clearance_target: Optional[Tensor] = None  # [B, 10], metres
    consequence_clearance_valid: Optional[Tensor] = None  # [B, 10] bool
    future_obstacles: Optional[Tensor] = None  # [B, 10, M, 5] xy/extent/yaw
    future_obstacle_valid: Optional[Tensor] = None  # [B, 10, M] bool
    future_obstacle_step_valid: Optional[Tensor] = None  # [B, 10] bool
    safe_to_execute: Optional[Tensor] = None  # [B] bool (Action Dreaming)
    safe_to_execute_valid: Optional[Tensor] = None  # [B] bool
    is_dreamer: Optional[Tensor] = None  # [B] bool
    dream_safe_route: Optional[Tensor] = None  # [B, 20, 2]
    dream_safe_speed: Optional[Tensor] = None  # [B, 10, 2]
    dream_unsafe_route: Optional[Tensor] = None  # [B, 20, 2]
    dream_unsafe_speed: Optional[Tensor] = None  # [B, 10, 2]
    dream_pair_valid: Optional[Tensor] = None  # [B] bool
    object_relation: Optional[Tensor] = None  # [B, N] int64 relation class per object token, -100 = no label

class DrivingExample(NamedTuple):
    driving_input: DrivingInput
    driving_label: DrivingLabel
    run_id: List[str]
    timestamp: Tensor  # unix timestamp of ff cam