Skip to content

Add Finetuning Infrastructure#432

Open
Aditya-Gupta26 wants to merge 9 commits into
emerge/temp_trainingfrom
aditya/finetune_runs
Open

Add Finetuning Infrastructure#432
Aditya-Gupta26 wants to merge 9 commits into
emerge/temp_trainingfrom
aditya/finetune_runs

Conversation

@Aditya-Gupta26
Copy link
Copy Markdown

This PR adds Finetuning Infrastructure to our codebase. IT can be used to running several fine-tuning experiments by providing the respective .ini files while running puffer train.

It also adds support for truck world usage by specifying its dimensions if needed.

Some ini scripts are also added for reference.

@Aditya-Gupta26 Aditya-Gupta26 force-pushed the aditya/finetune_runs branch from 5bed292 to e0a8f63 Compare May 21, 2026 06:13
@Aditya-Gupta26 Aditya-Gupta26 marked this pull request as ready for review May 21, 2026 07:18
Copilot AI review requested due to automatic review settings May 21, 2026 07:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a finetuning workflow for Puffer training/eval (overlay .ini configs, checkpoint “architecture lock”, and parameter-efficient finetuning via freeze/LoRA), and extends the Drive environment with configurable vehicle spawn dimensions plus mixed truck/car spawning.

Changes:

  • Add finetune support: checkpoint arch-locking for train/eval, --finetune-config overlay layering, optimizer behavior changes for finetune vs resume, and finetune metadata logging.
  • Implement parameter-efficient finetuning utilities (freeze_regex, LoRA wrappers, and LoRA-specific optimizer param groups/LR multiplier).
  • Add Drive spawn dimension ranges and mixed truck spawning; remove the “seconds stopped” observation and adjust feature counts accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pufferlib/pufferl.py Adds checkpoint arch-locking, finetune overlay support, LoRA/freezing integration into policy load + optimizer param grouping, and finetune/resume semantics.
pufferlib/finetune.py New module implementing freeze + LoRA wrapping utilities and optimizer param-group construction.
pufferlib/ocean/drive/drive.py Plumbs new spawn dimension + truck spawning parameters from Python into the C env via init kwargs.
pufferlib/ocean/drive/binding.c Unpacks new spawn/truck parameters into the C Drive struct.
pufferlib/ocean/drive/drive.h Adds new Drive fields for spawn/truck parameters; updates spawning logic; removes stopped-time observation feature and related bookkeeping.
pufferlib/ocean/drive/datatypes.h Removes seconds_stopped from Agent.
pufferlib/config/ocean/drive.ini Adds finetune section + spawn/truck params; updates some default policy/env settings.
pufferlib/config/ocean/drive_finetune_truck_mixed.ini Example finetune overlay for mixed truck spawning.
pufferlib/config/ocean/drive_finetune_reward.ini Example finetune overlay using LoRA for reward retuning.
pufferlib/config/ocean/drive_finetune_nuplan.ini Example finetune overlay for nuPlan replay training (LoRA).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +51 to +68
; Per-agent spawn dimensions (meters). Training and eval use independent
; ranges so a policy trained on non-car shapes (e.g. trucks) can be eval'd
; on matching shapes. width is clipped to <= length at spawn time.
spawn_length_min = 0.8
spawn_length_max = 7.0
spawn_width_min = 0.8
spawn_width_max = 3.0
eval_spawn_length_min = 2.0
eval_spawn_length_max = 5.5
eval_spawn_width_min = 1.5
eval_spawn_width_max = 2.5
; Mixed-population spawn: per-agent P(is_truck). 0.0 (default) preserves
; the legacy single-population behavior
truck_fraction = 0.0
truck_spawn_length_min = 9.0
truck_spawn_length_max = 15.0
truck_spawn_width_min = 2.0
truck_spawn_width_max = 2.6
Comment on lines 13 to 16
[policy]
; Encoder layer
input_size = 64
input_size = 128
encoder_gigaflow = True
Comment on lines +337 to +359
// Per-agent spawn dimension ranges (training vs eval modes use separate ranges).
// length: longitudinal extent in meters; width: lateral extent in meters.
// width is clipped to <= length at spawn time.
float spawn_length_min;
float spawn_length_max;
float spawn_width_min;
float spawn_width_max;
float eval_spawn_length_min;
float eval_spawn_length_max;
float eval_spawn_width_min;
float eval_spawn_width_max;
// Mixed-population spawn: per-agent P(is_truck). When truck_fraction == 0
// (default), every agent samples dims from the spawn_*_{min,max} range above
// and behavior is identical to the single-population path. When > 0, a
// Bernoulli(truck_fraction) draw at spawn time picks between the car range
// (spawn_*) and the truck range (truck_spawn_*). Used for co-training a
// single policy on a realistic mixed-vehicle population (~10% trucks).
// Eval mode reuses the same truck range; eval_spawn_* still covers cars.
float truck_fraction;
float truck_spawn_length_min;
float truck_spawn_length_max;
float truck_spawn_width_min;
float truck_spawn_width_max;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants