detrium.core.config
Clean configuration loader and lazy object container for Detrium.
Supports:
- File paths, built-in package recipe names, or in-memory Python dicts
- Recursive `__include__` YAML composition with safe deep merging
- Clean field names (`epochs`, `lr_scheduler_type`) while normalizing legacy aliases
- Stateless instantiation via `detrium.core.registry`
- Registered VFM teachers (no hardcoded if/elif teacher branches)
class DetriumConfig
Isolated configuration and lazy component builder for a single Detrium model/run.
| 名称 | 类型 | 默认值 |
|---|
cfg_or_path | Union[str, Path, Mapping[str, Any]] | — |
disable_backbone_pretrained | bool | False |
overrides | Any | — |
model(self) -> nn.Module
model(self, m: nn.Module) -> None
teacher_model(self) -> Optional[nn.Module]
postprocessor(self) -> Optional[nn.Module]
criterion(self) -> Optional[nn.Module]
optimizer(self) -> Optional[optim.Optimizer]
lr_scheduler(self) -> Optional[Any]
lr_warmup_scheduler(self) -> Optional[Any]
train_dataloader(self) -> Optional[DataLoader]
val_dataloader(self) -> Optional[DataLoader]
ema(self) -> Optional[nn.Module]
scaler(self) -> Optional[Any]
evaluator(self) -> Optional[Any]
writer(self) -> Optional[Any]
get_optim_params(cfg: Mapping[str, Any], model: nn.Module) -> Any
Build regex-matched parameter groups (preserving MuAdamW/MuSGD param metadata).
| 名称 | 类型 | 默认值 |
|---|
cfg | Mapping[str, Any] | — |
model | nn.Module | — |
get_rank_batch_size(loader_cfg: Mapping[str, Any]) -> int
| 名称 | 类型 | 默认值 |
|---|
loader_cfg | Mapping[str, Any] | — |
build_dataloader(self, name: str) -> DataLoader
merge_dict(base: Dict[str, Any], override: Mapping[str, Any], *, inplace: bool=False) -> Dict[str, Any]
Recursively merge `override` into `base`.
| 名称 | 类型 | 默认值 |
|---|
base | Dict[str, Any] | — |
override | Mapping[str, Any] | — |
inplace | bool | False |
dictify(dotted_key: str, value: Any) -> Dict[str, Any]
Convert `'a.b.c'` + `val` into `{'a': {'b': {'c': val}}}`.
| 名称 | 类型 | 默认值 |
|---|
dotted_key | str | — |
value | Any | — |
parse_cli_overrides(items: Optional[List[str]]) -> Dict[str, Any]
Parse `['a.b=1', 'epochs=50']` into a nested override dict.
| 名称 | 类型 | 默认值 |
|---|
items | Optional[List[str]] | — |
load_yaml_config(file_path: Union[str, Path]) -> Dict[str, Any]
Load a YAML config file with recursive `__include__` resolution.
| 名称 | 类型 | 默认值 |
|---|
file_path | Union[str, Path] | — |
strip_backbone_pretrained(cfg: Dict[str, Any]) -> Dict[str, Any]
Return a deep copy of `cfg` with backbone `pretrained` flags disabled cleanly.
| 名称 | 类型 | 默认值 |
|---|
cfg | Dict[str, Any] | — |