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 full PEFT checkpoint carries reference-policy state.

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.

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 when every checkpoint entry is adapter/task state.