Skip to main content

ClikaRT::nn::LoadOptions

struct

Header: ClikaRT/nn/module.h

Options for the load_state_dict overloads (a plain aggregate; assign the fields you need). The same options serve BOTH load paths (an in-memory NamedTensors dict and a lazy checkpoint container), so a model accounts its weight names identically whichever way it loads. strict gates the completeness report; the allow-lists carve per-name exceptions out of it without turning the whole check off:

  • allow_missing: declared slot names the checkpoint may legitimately omit, e.g. a tied head's lm_head.weight, absent from checkpoints that share it with the embedding and bound by weight-sharing instead.
  • allow_unexpected: checkpoint names no slot declares that are fine to leave unread, e.g. a checkpoint shipping a redundant copy of a tied head's weight.
  • weight_residency: a load-scope residency override. When set, every module in the tree that admits a residency choice adopts this value before the checkpoint binds, as if it had been constructed with it, so one load call pins the whole model's posture without touching the model's own construction defaults. A module whose class pins its residency keeps the pin; the load logs one summary line with how many modules adopted the override and how many kept a class-pinned residency. Packed on a weight whose layout cannot pack still refuses readably at bind. Absent (the default) changes nothing.
  • pack_on_load: pack every bound weight at the end of THIS load, so a serving process pays the one-time pack at load time instead of on its first forward. It is the same pack the first forward would run (once, thread-safe), driven through the tree's own pack hooks from the root, so a composite that fuses or folds at pack time does that work here too. After it each packed weight has exactly one resident copy and still reads back through named_parameters() / state_dict(). Default off: the first forward packs.

Data members​

strict​

bool strict = true

Reject any missing/unexpected checkpoint key (the default). false binds what matches and ignores the rest.

Declared in ClikaRT/nn/module.h, line 116

allow_missing​

std::vector<std::string> allow_missing

Key patterns excused from the missing-key check while strict holds.

Declared in ClikaRT/nn/module.h, line 119

allow_unexpected​

std::vector<std::string> allow_unexpected

Key patterns excused from the unexpected-key check while strict holds.

Declared in ClikaRT/nn/module.h, line 122

weight_residency​

std::optional<WeightResidency> weight_residency

Overrides every residency-choosing module's posture for this load (see WeightResidency); absent changes nothing.

Declared in ClikaRT/nn/module.h, line 125

pack_on_load​

bool pack_on_load = false

Pack every bound weight at the end of this load (the first forward's pack, paid now). Default off.

Declared in ClikaRT/nn/module.h, line 128