protomotions.agents.peft.utils.model_state module#

Model-state loading rules for discrete-prior PEFT checkpoints.

The agent should not need to know why a missing key is acceptable. This module owns those low-level checkpoint rules and exposes one readable entry point: load a PEFT model state if it is adapter-only or a compatible full training checkpoint.

protomotions.agents.peft.utils.model_state.has_reference_state(model_state)[source]#

Return True when a PEFT checkpoint carries any reference-policy state.

class protomotions.agents.peft.utils.model_state.PEFTModelStateLoad(adapter_only, reference_loaded)[source]#

Bases: object

What load_compatible_peft_model_state found in a checkpoint.

Variables:
  • adapter_only (bool) – True for an adapter checkpoint without frozen prior weights.

  • reference_loaded (bool) – True when the checkpoint restored the reference policy.

adapter_only: bool#
reference_loaded: bool#
__init__(adapter_only, reference_loaded)#
protomotions.agents.peft.utils.model_state.load_compatible_peft_model_state(module, model_state)[source]#

Load adapter-only state or a compatible full PEFT training checkpoint.

Either kind restores the reference policy when the checkpoint stores one. A reference saved before it kept its own conditioning network is refused (scripts/migrate_peft_reference_conditioning.py writes a migrated file). Resume and inference use the restored reference; a new RLFT run replaces it at training start.

protomotions.agents.peft.utils.model_state.optional_full_checkpoint_state_prefixes(module)[source]#

Return state_dict prefixes that are optional for full PEFT checkpoints.

Each module owns the optional state it introduces by defining optional_full_checkpoint_state_prefixes() with local state_dict prefixes. This helper qualifies those local prefixes by walking named_modules(), keeping checkpoint compatibility rules close to the modules that create the state instead of centralizing private path strings.

protomotions.agents.peft.utils.model_state.is_adapter_only_model_state(model_state)[source]#

Return True for an adapter checkpoint: adapter/task state and reference state only.