MCPcopy Create free account
hub / github.com/bytedance/ABQ-LLM / forward_hook_wrapper

Function forward_hook_wrapper

algorithm/parallel_utils.py:149–159  ·  view source on GitHub ↗
(gpu_id)

Source from the content-addressed store, hash-verified

147
148# forward hook
149def forward_hook_wrapper(gpu_id):
150 def forward_hook(module, input, kwargs):
151 # breakpoint()
152 input = tuple(_.to(f"cuda:{gpu_id}") for _ in input)
153 kwargs = {
154 k: v.to(f"cuda:{gpu_id}") if isinstance(v, torch.Tensor) else v
155 for k, v in kwargs.items()
156 }
157 return input, kwargs
158
159 return forward_hook
160
161
162def add_forward_hooks(layer_gpu_map):

Callers 1

add_forward_hooksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected