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:
objectWhat
load_compatible_peft_model_statefound in a checkpoint.- Variables:
- __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.pywrites 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 walkingnamed_modules(), keeping checkpoint compatibility rules close to the modules that create the state instead of centralizing private path strings.