protomotions.agents.peft.prior_agent module#
RLFT agent for PEFT adapters on a frozen discrete-token GPC prior.
- class protomotions.agents.peft.prior_agent.DiscretePriorPEFTRLFTAgent(fabric, env, config, root_dir=None)[source]#
Bases:
DiscretePriorPEFTSetupMixin,FineTuningAgentPPO/RLFT for a PEFT-adapted discrete GPC prior.
This class is intentionally RL-only: it owns PPO ratio loss, critic loss, RLFT checkpoint warm-start from SFT, and the frozen KL/sampling reference. Supervised PEFT training lives in
sft_agent.pyand uses the generic supervised loop.- fit()[source]#
Main training loop for the agent.
Executes the complete training process including: 1. Experience buffer setup (auto-registers keys from model outputs) 2. Environment rollouts (data collection) 3. Model optimization 4. Periodic evaluation 5. Checkpoint saving 6. Logging and metrics
The loop runs for max_epochs epochs, where each epoch collects num_steps of experience from num_envs parallel environments, then performs multiple optimization steps on the collected data.
Note
This is the main entry point for training. Call setup() before fit().
- actor_step(batch_dict)[source]#
Compute actor loss and perform policy update.
Computes PPO clipped surrogate objective plus optional bounds loss and extra algorithm-specific losses.
- Parameters:
batch_dict (Dict) – Minibatch containing obs, actions, old neglogp, advantages.
- Returns:
actor_loss: Total actor loss for backprop
log_dict: Dictionary of actor metrics for logging
- Return type:
Tuple of (actor_loss, log_dict) where