Skip to content
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ CLAUDE.md

# artifacts
inference_results/
.rbyte_cache
.rbyte_cache*

.dprint.json

Expand Down
4 changes: 2 additions & 2 deletions config/_templates/dataset/yaak/predict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ samples:
waypoints_geom,
normalized_waypoints_geom,
ego_geom,
"waypoints/xy",
"headings_denoised/heading"
"waypoints/xy"
),
[
ST_X(ego_geom),
Expand Down Expand Up @@ -376,6 +375,7 @@ samples:
"meta/VehicleMotion/steering_angle_normalized"::FLOAT[6] AS "meta/VehicleMotion/steering_angle_normalized",
"meta/VehicleState/turn_signal"::INT8[6] AS "meta/VehicleState/turn_signal",
"meta/Gnss/xy"::FLOAT[2][6] AS "meta/Gnss/xy",
"headings_denoised/heading"::FLOAT[6] AS "headings_denoised/heading",
"waypoints/xy_normalized"::FLOAT[2][10][6] AS "waypoints/xy_normalized",
"waypoints/xy"::FLOAT[2][10][6] AS "waypoints/xy",
FROM
Expand Down
32 changes: 27 additions & 5 deletions config/_templates/dataset/yaak/train.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -947,16 +947,16 @@ samples:
waypoints_geom,
normalized_waypoints_geom,
ego_geom,
"waypoints/xy",
"headings_denoised/heading"
"waypoints/xy"
),
-- Some vehicles (Niro106, Niro109, Niro110, Niro121, Niro124, Niro127, Niro132)
-- have a constant brake sensor offset of up to ~4 quantisation steps (< 0.05)
-- that reads as non-zero while the gas pedal is pressed. This is sensor noise,
-- not real braking. Clamp it to zero so the model does not learn to predict
-- spurious simultaneous brake+gas presses.
IF(
"meta/VehicleMotion/brake_pedal_normalized" < 0.05
${oc.select:clamp_brake_pedal,1} = 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please collect statistics how the new filter affects the number of episodes to ensure we are not accidentally dropping high signal datapoints

AND "meta/VehicleMotion/brake_pedal_normalized" < 0.05
AND "meta/VehicleMotion/gas_pedal_normalized" > 0.0,
0.0,
"meta/VehicleMotion/brake_pedal_normalized"
Expand Down Expand Up @@ -1028,6 +1028,7 @@ samples:
"meta/VehicleMotion/steering_angle_normalized"::FLOAT[6] AS "meta/VehicleMotion/steering_angle_normalized",
"meta/VehicleState/turn_signal"::INT8[6] AS "meta/VehicleState/turn_signal",
"meta/Gnss/xy"::FLOAT[2][6] AS "meta/Gnss/xy",
"headings_denoised/heading"::FLOAT[6] AS "headings_denoised/heading",
"waypoints/xy_normalized"::FLOAT[2][10][6] AS "waypoints/xy_normalized",
"waypoints/xy"::FLOAT[2][10][6] AS "waypoints/xy",
FROM
Expand All @@ -1046,14 +1047,15 @@ samples:
-- genuinely fluctuating brake signal (Niro101, Niro107, Niro112,
-- Niro115, Niro128, Niro130, Niro131) where the clamp does not
-- apply (brake > 0.05). Such conflicts are unrecoverable noise.
AND len(list_filter(
-- Disable with: +drop_pedal_conflict_episodes=0
AND (${oc.select:drop_pedal_conflict_episodes,1} = 0 OR len(list_filter(
list_zip(
"meta/VehicleMotion/gas_pedal_normalized",
"meta/VehicleMotion/brake_pedal_normalized"
),
x -> x[1] > (1.0 / 255 + 0.001)
AND x[2] > (1.0 / 164 + 0.001)
)) = 0
)) = 0)

- _target_: pipefunc.PipeFunc
renames:
Expand All @@ -1072,3 +1074,23 @@ samples:
_target_: polars.DataFrame.with_row_index
_partial_: true
name: meta/sample_id
- _target_: pipefunc.PipeFunc
output_name: samples_scored
renames:
df: samples_with_id
func:
_target_: rmind.utils.pipeline.left_join_parquet
_partial_: true
path: "${oc.select:scores_parquet,''}"
"on": "meta/sample_id"
right_on: "batch/data/meta/sample_id"
select: "${oc.select:resampling.select,null}"
- _target_: pipefunc.PipeFunc
output_name: samples_filtered
renames:
df: samples_scored
func:
_target_: rmind.utils.pipeline.drop_overrepresented_by_loss
_partial_: true
columns: "${oc.select:resampling.columns,null}"
max_bin_freq: "${oc.select:loss_max_bin_freq,1}"
32 changes: 27 additions & 5 deletions config/_templates/dataset/yaak/train_debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,16 @@ samples:
waypoints_geom,
normalized_waypoints_geom,
ego_geom,
"waypoints/xy",
"headings_denoised/heading"
"waypoints/xy"
),
-- Some vehicles (Niro106, Niro109, Niro110, Niro121, Niro124, Niro127, Niro132)
-- have a constant brake sensor offset of up to ~4 quantisation steps (< 0.05)
-- that reads as non-zero while the gas pedal is pressed. This is sensor noise,
-- not real braking. Clamp it to zero so the model does not learn to predict
-- spurious simultaneous brake+gas presses.
IF(
"meta/VehicleMotion/brake_pedal_normalized" < 0.05
${oc.select:clamp_brake_pedal,1} = 1
AND "meta/VehicleMotion/brake_pedal_normalized" < 0.05
AND "meta/VehicleMotion/gas_pedal_normalized" > 0.0,
0.0,
"meta/VehicleMotion/brake_pedal_normalized"
Expand Down Expand Up @@ -376,6 +376,7 @@ samples:
"meta/VehicleMotion/steering_angle_normalized"::FLOAT[6] AS "meta/VehicleMotion/steering_angle_normalized",
"meta/VehicleState/turn_signal"::INT8[6] AS "meta/VehicleState/turn_signal",
"meta/Gnss/xy"::FLOAT[2][6] AS "meta/Gnss/xy",
"headings_denoised/heading"::FLOAT[6] AS "headings_denoised/heading",
"waypoints/xy_normalized"::FLOAT[2][10][6] AS "waypoints/xy_normalized",
"waypoints/xy"::FLOAT[2][10][6] AS "waypoints/xy",
FROM
Expand All @@ -394,14 +395,15 @@ samples:
-- genuinely fluctuating brake signal (Niro101, Niro107, Niro112,
-- Niro115, Niro128, Niro130, Niro131) where the clamp does not
-- apply (brake > 0.05). Such conflicts are unrecoverable noise.
AND len(list_filter(
-- Disable with: +drop_pedal_conflict_episodes=0
AND (${oc.select:drop_pedal_conflict_episodes,1} = 0 OR len(list_filter(
list_zip(
"meta/VehicleMotion/gas_pedal_normalized",
"meta/VehicleMotion/brake_pedal_normalized"
),
x -> x[1] > (1.0 / 255 + 0.001)
AND x[2] > (1.0 / 164 + 0.001)
)) = 0
)) = 0)

- _target_: pipefunc.PipeFunc
renames:
Expand All @@ -420,3 +422,23 @@ samples:
_target_: polars.DataFrame.with_row_index
_partial_: true
name: meta/sample_id
- _target_: pipefunc.PipeFunc
output_name: samples_scored
renames:
df: samples_with_id
func:
_target_: rmind.utils.pipeline.left_join_parquet
_partial_: true
path: "${oc.select:scores_parquet,''}"
"on": "meta/sample_id"
right_on: "batch/data/meta/sample_id"
select: "${oc.select:resampling.select,null}"
- _target_: pipefunc.PipeFunc
output_name: samples_filtered
renames:
df: samples_scored
func:
_target_: rmind.utils.pipeline.drop_overrepresented_by_loss
_partial_: true
columns: "${oc.select:resampling.columns,null}"
max_bin_freq: "${oc.select:loss_max_bin_freq,1}"
12 changes: 7 additions & 5 deletions config/_templates/dataset/yaak/val.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,16 @@ samples:
waypoints_geom,
normalized_waypoints_geom,
ego_geom,
"waypoints/xy",
"headings_denoised/heading"
"waypoints/xy"
),
-- Some vehicles (Niro106, Niro109, Niro110, Niro121, Niro124, Niro127, Niro132)
-- have a constant brake sensor offset of up to ~4 quantisation steps (< 0.05)
-- that reads as non-zero while the gas pedal is pressed. This is sensor noise,
-- not real braking. Clamp it to zero so the model does not learn to predict
-- spurious simultaneous brake+gas presses.
IF(
"meta/VehicleMotion/brake_pedal_normalized" < 0.05
${oc.select:clamp_brake_pedal,1} = 1
AND "meta/VehicleMotion/brake_pedal_normalized" < 0.05
AND "meta/VehicleMotion/gas_pedal_normalized" > 0.0,
0.0,
"meta/VehicleMotion/brake_pedal_normalized"
Expand Down Expand Up @@ -378,6 +378,7 @@ samples:
"meta/VehicleMotion/steering_angle_normalized"::FLOAT[6] AS "meta/VehicleMotion/steering_angle_normalized",
"meta/VehicleState/turn_signal"::INT8[6] AS "meta/VehicleState/turn_signal",
"meta/Gnss/xy"::FLOAT[2][6] AS "meta/Gnss/xy",
"headings_denoised/heading"::FLOAT[6] AS "headings_denoised/heading",
"waypoints/xy_normalized"::FLOAT[2][10][6] AS "waypoints/xy_normalized",
"waypoints/xy"::FLOAT[2][10][6] AS "waypoints/xy",
FROM
Expand All @@ -396,14 +397,15 @@ samples:
-- genuinely fluctuating brake signal (Niro101, Niro107, Niro112,
-- Niro115, Niro128, Niro130, Niro131) where the clamp does not
-- apply (brake > 0.05). Such conflicts are unrecoverable noise.
AND len(list_filter(
-- Disable with: +drop_pedal_conflict_episodes=0
AND (${oc.select:drop_pedal_conflict_episodes,1} = 0 OR len(list_filter(
list_zip(
"meta/VehicleMotion/gas_pedal_normalized",
"meta/VehicleMotion/brake_pedal_normalized"
),
x -> x[1] > (1.0 / 255 + 0.001)
AND x[2] > (1.0 / 164 + 0.001)
)) = 0
)) = 0)

- _target_: pipefunc.PipeFunc
renames:
Expand Down
17 changes: 17 additions & 0 deletions config/datamodule/yaak/predict_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
defaults:
- /dataset/yaak/train@predict.dataset
- _self_

_target_: rmind.datamodules.GenericDataModule
predict:
_target_: rbyte.dataloader.TorchDataNodeDataLoader
batch_size: 128
shuffle: false
collate_fn:
_target_: rbyte.types.Batch.to_dict
_partial_: true

num_workers: 2
pin_memory: true
method: thread
12 changes: 12 additions & 0 deletions config/datamodule/yaak/train_debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
defaults:
- /dataset/yaak/train_debug@train.dataset
- /dataset/yaak/train_debug@val.dataset
- /dataset/yaak/train_debug@predict.dataset
- _self_

_target_: rmind.datamodules.GenericDataModule
Expand All @@ -27,3 +28,14 @@ val:
pin_memory: true
num_workers: 2
method: thread

predict:
_target_: rbyte.dataloader.TorchDataNodeDataLoader
batch_size: 2
shuffle: false
collate_fn:
_target_: rbyte.types.Batch.to_dict
_partial_: true
pin_memory: true
num_workers: 2
method: thread
1 change: 1 addition & 0 deletions config/experiment/yaak/control_transformer/finetune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
defaults:
- /model: yaak/control_transformer/policy_finetune
- /datamodule: yaak/train
- /resampling: policy
- /trainer: default
- /trainer/callbacks: finetune
- /paths: yaak/default
Expand Down
1 change: 1 addition & 0 deletions config/experiment/yaak/control_transformer/pretrain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
defaults:
- /model: yaak/control_transformer/raw
- /datamodule: yaak/train
- /resampling: pretrained
- /trainer: default
- /trainer/callbacks: pretrain
- /paths: yaak/default
Expand Down
7 changes: 7 additions & 0 deletions config/inference/yaak/control_transformer/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ trainer:
- prediction_value
- prediction_std
- prediction_probs
- loss
- score_l1
- score_logprob
- score_signed_error
Expand All @@ -40,14 +41,20 @@ trainer:
write_interval: batch
path: ${hydra:run.dir}/predictions/${oc.select:model.artifact,}/{batch_idx:06}.parquet
select:
- [batch, data, meta/sample_id]
- [batch, data, meta/ImageMetadata.cam_front_left/time_stamp]
- [batch, data, meta/ImageMetadata.cam_front_left/frame_idx]
- [batch, data, meta/VehicleMotion/speed]
- [batch, data, meta/Gnss/xy]
- [batch, data, headings_denoised/heading]
- [batch, meta, input_id]
- [batch, data, waypoints/xy_normalized]
- [batch, data, waypoints/xy]
- [policy, ground_truth, value]
- [policy, prediction_value, value]
- [policy, prediction_std, value]
- [policy, prediction_probs, value]
- [policy, loss, value]
- [policy, score_l1, value]
- [policy, score_logprob, value]
- [policy, score_l1_rel, value]
Expand Down
37 changes: 37 additions & 0 deletions config/inference/yaak/control_transformer/policy_loss_only.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# @package _global_
---
defaults:
- /model: yaak/control_transformer/finetuned
- /datamodule: yaak/predict
- /paths: yaak/default
- /logger: yaak/rerun/prediction_policy
- _self_

trainer:
_target_: pytorch_lightning.Trainer
_convert_: all
accelerator: gpu
devices: 1
benchmark: true
precision: "bf16-mixed"
logger: false
callbacks:
- _target_: rmind.callbacks.PredictionConfigSetter
config:
objectives:
- loss

- _target_: rmind.callbacks.DataFramePredictionWriter
write_interval: batch
path: ${hydra:run.dir}/predictions/${oc.select:model.artifact,}/{batch_idx:06}.parquet
final_path: ${oc.select:scores_output}
select:
- [batch, data, meta/sample_id]
- [batch, data, meta/ImageMetadata.cam_front_left/time_stamp]
- [batch, data, meta/ImageMetadata.cam_front_left/frame_idx]
- [policy, loss, value]
writer:
_target_: polars.DataFrame.write_parquet
_partial_: true
- _target_: pytorch_lightning.callbacks.ModelSummary
max_depth: 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @package _global_
---
defaults:
- /model: yaak/control_transformer/pretrained
- /datamodule: yaak/predict
- /paths: yaak/default
- /logger: yaak/rerun/prediction_pretrain
- _self_

trainer:
_target_: pytorch_lightning.Trainer
_convert_: all
accelerator: gpu
devices: 1
benchmark: true
precision: "bf16-mixed"
logger: false
callbacks:
- _target_: rmind.callbacks.PredictionConfigSetter
config:
objectives:
- loss

- _target_: rmind.callbacks.DataFramePredictionWriter
write_interval: batch
path: ${hydra:run.dir}/predictions/${oc.select:model.artifact,}/{batch_idx:06}.parquet
final_path: ${oc.select:scores_output}
select:
- [batch, data, meta/sample_id]
- [batch, data, meta/ImageMetadata.cam_front_left/time_stamp]
- [batch, data, meta/ImageMetadata.cam_front_left/frame_idx]
- [inverse_dynamics, loss, value]
- [forward_dynamics, loss, value]
- [memory_extraction, loss, value]
writer:
_target_: polars.DataFrame.write_parquet
_partial_: true
- _target_: pytorch_lightning.callbacks.ModelSummary
max_depth: 5
11 changes: 11 additions & 0 deletions config/resampling/policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
select:
- "policy/loss/value/continuous/gas_pedal"
- "policy/loss/value/continuous/brake_pedal"
- "policy/loss/value/continuous/steering_angle"
- "policy/loss/value/discrete/turn_signal"

columns:
- "policy/loss/value/continuous/gas_pedal"
- "policy/loss/value/continuous/brake_pedal"
- "policy/loss/value/continuous/steering_angle"
- "policy/loss/value/discrete/turn_signal"
Loading
Loading