(block: torch.nn.Module, state_manager: StateManager, config: MagCacheConfig)
| 442 | |
| 443 | |
| 444 | def _apply_mag_cache_head_hook(block: torch.nn.Module, state_manager: StateManager, config: MagCacheConfig) -> None: |
| 445 | registry = HookRegistry.check_if_exists_or_initialize(block) |
| 446 | |
| 447 | # Automatically remove existing hook to allow re-application (e.g. switching modes) |
| 448 | if registry.get_hook(_MAG_CACHE_LEADER_BLOCK_HOOK) is not None: |
| 449 | registry.remove_hook(_MAG_CACHE_LEADER_BLOCK_HOOK) |
| 450 | |
| 451 | hook = MagCacheHeadHook(state_manager, config) |
| 452 | registry.register_hook(hook, _MAG_CACHE_LEADER_BLOCK_HOOK) |
| 453 | |
| 454 | |
| 455 | def _apply_mag_cache_block_hook( |
no test coverage detected
searching dependent graphs…