nvalchemi.training.hooks.ModulePatchHook#
- pydantic model nvalchemi.training.hooks.ModulePatchHook[source]#
Patch model submodules at registration time.
Patches run when the hook is registered on a workflow. Each target path must include the model key followed by an existing parent path and a final child attribute, for example
"main.model.projection". The parent module must exist; the final child is added when missing or replaced when present. Shape compatibility is intentionally user-owned and is validated naturally by the model’s forward pass or downstream checkpoint loading.- Warns:
UserWarning – If the same direct module instance is assigned to multiple targets.
Examples
>>> import torch >>> from nvalchemi.training.hooks import ModulePatchHook >>> hook = ModulePatchHook( ... patches={"main.model.projection": torch.nn.Linear(8, 1)} ... ) >>> hook.frequency 1