(
block: torch.nn.Module,
state_manager: StateManager,
config: MagCacheConfig,
is_tail: bool = False,
)
| 453 | |
| 454 | |
| 455 | def _apply_mag_cache_block_hook( |
| 456 | block: torch.nn.Module, |
| 457 | state_manager: StateManager, |
| 458 | config: MagCacheConfig, |
| 459 | is_tail: bool = False, |
| 460 | ) -> None: |
| 461 | registry = HookRegistry.check_if_exists_or_initialize(block) |
| 462 | |
| 463 | # Automatically remove existing hook to allow re-application |
| 464 | if registry.get_hook(_MAG_CACHE_BLOCK_HOOK) is not None: |
| 465 | registry.remove_hook(_MAG_CACHE_BLOCK_HOOK) |
| 466 | |
| 467 | hook = MagCacheBlockHook(state_manager, is_tail, config) |
| 468 | registry.register_hook(hook, _MAG_CACHE_BLOCK_HOOK) |
no test coverage detected
searching dependent graphs…