LoadCheckpoint
steerability.algorithms.structural_control.load_checkpoint
args
LoadCheckpoint argument validation.
control
LoadCheckpoint: a structural control that installs a checkpoint as the pipeline model.
logger = logging.getLogger(__name__)
module-attribute
LoadCheckpoint
Bases: StructuralControl
Installs a saved full-weights checkpoint as the pipeline model.
On the in-process backend, steer() loads the checkpoint with
AutoModelForCausalLM.from_pretrained and returns it, replacing the incoming model for
subsequent controls. On vLLM backends the checkpoint is served directly
(Capability.SERVE_CHECKPOINT), exported as a CheckpointArtifact. The frozen form of a
trained structural control (fine-tune, merge) is an instance of this control pointing at
the trained checkpoint.
Source code in steerability/algorithms/structural_control/load_checkpoint/control.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
RUNTIME_KWARGS_SCHEMA = []
class-attribute
instance-attribute
args = self.Args.validate(*args, **kwargs)
instance-attribute
enabled = True
class-attribute
instance-attribute
supports_batching = True
class-attribute
instance-attribute
__init__(*args, **kwargs)
Source code in steerability/algorithms/core/base_control.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
_configure()
Post-construction hook, called after Args fields are mirrored onto the instance.
Driver presets override this to map their mirrored args onto the fields their generic base
reads, so subclasses never bypass a parent __init__. Default no-op.
Source code in steerability/algorithms/core/base_control.py
67 68 69 70 71 72 73 | |
artifact_capability()
Capability.SERVE_CHECKPOINT; the configuration is an on-disk checkpoint.
Source code in steerability/algorithms/structural_control/load_checkpoint/control.py
31 32 33 | |
cleanup()
Release resources allocated during steer().
Override in subclasses that allocate GPU memory or other resources during steering. Default no-op.
Source code in steerability/algorithms/core/base_control.py
195 196 197 198 199 200 201 | |
clone_for_call(seed=None)
A configuration-preserving shallow clone for one generation call.
The clone shares steer-time artifacts (memories, steering vectors, attached tokenizers)
with the original but has its own attribute namespace, so per-call attribute mutation on
the clone never races another call using the original. When seed is given and the
control defines reseed(seed), the clone's client-side RNG is re-seeded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int | None
|
Optional seed forwarded to the clone's |
None
|
Returns:
| Type | Description |
|---|---|
BaseControl
|
The clone. |
Source code in steerability/algorithms/core/base_control.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
export_artifact()
The configured checkpoint directory.
Source code in steerability/algorithms/structural_control/load_checkpoint/control.py
35 36 37 | |
export_state()
Steer-time state to persist when freezing, keyed by logical name.
Values are typed artifacts (SteeringVector, Probe, ProbeSet, a Memory
implementation, CheckpointArtifact, LoRAArtifact, torch.Tensor, or a Path to an
on-disk product). Must be called after steer(). The default returns an empty mapping
(nothing to persist).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Mapping from logical name to artifact value. |
Source code in steerability/algorithms/core/base_control.py
117 118 119 120 121 122 123 124 125 126 127 128 | |
fit_identity()
The object whose canonical form defines this control's fit digest, or None.
The digest detects recipe edits that invalidate frozen artifacts, so the returned object should cover exactly the inputs a re-fit would consume (training data, fit specs) and exclude inert application parameters (strengths, multipliers). The default returns None (no fits).
Returns:
| Type | Description |
|---|---|
Any | None
|
The fit-identity object, or None. |
Source code in steerability/algorithms/core/base_control.py
161 162 163 164 165 166 167 168 169 170 171 172 | |
frozen_form(state)
The (registry method key, constructor kwargs) of this control's frozen form.
state is the output of export_state(); artifact values inside the returned kwargs
are replaced by store references at encode time. When steer_fits() is empty and
state is empty, the recipe is the frozen form and the control's own key and recipe
args are returned unchanged. A control whose freeze expands into several entries may
return a list of (method key, kwargs) pairs instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
dict[str, Any]
|
The output of |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, dict[str, Any]]
|
The frozen method key and its constructor kwargs. |
Raises:
| Type | Description |
|---|---|
NotFreezableError
|
If the control produces fits or state but declares no frozen form. |
Source code in steerability/algorithms/core/base_control.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
requirements()
Backend requirements computed from this instance's configuration, per phase.
The generate phase requires Capability.IN_PROCESS_TORCH for in-process adoption of
the returned model; when the configuration produces an on-disk artifact
(artifact_capability()), serving that artifact is an alternative, so a backend
advertising the matching serve capability also supports the generate phase.
Returns:
| Type | Description |
|---|---|
Requirements
|
The control's phase-keyed requirements. |
Source code in steerability/algorithms/structural_control/base.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
steer(model, tokenizer=None, **kwargs)
Load the checkpoint and return it as the new pipeline model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PreTrainedModel | None
|
The incoming pipeline model (unused; the checkpoint replaces it). |
required |
tokenizer
|
PreTrainedTokenizerBase | None
|
The pipeline tokenizer (unused). |
None
|
Returns:
| Type | Description |
|---|---|
PreTrainedModel
|
The loaded model. |
Source code in steerability/algorithms/structural_control/load_checkpoint/control.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
steer_access()
ModelAccess.MODULE; training happens on live weights.
Source code in steerability/algorithms/structural_control/base.py
112 113 114 | |
steer_fits()
The fit artifacts this instance's steer step will produce, for the steer plan.
Each entry is (artifact, artifact_class), where artifact is the fit source or
recipe class name and artifact_class is "direction" or "calibrated". The default
is an empty tuple (no fits).
Returns:
| Type | Description |
|---|---|
tuple[tuple[str, str], ...]
|
The declared fit artifacts, in declaration order. |
Source code in steerability/algorithms/core/base_control.py
105 106 107 108 109 110 111 112 113 114 115 | |