MCPcopy Create free account
hub / github.com/pytorch/examples / set_modules_to_forward_prefetch

Function set_modules_to_forward_prefetch

distributed/FSDP2/example.py:16–23  ·  view source on GitHub ↗
(model, num_to_forward_prefetch)

Source from the content-addressed store, hash-verified

14 return has_gpu and gpu_count >= min_gpus
15
16def set_modules_to_forward_prefetch(model, num_to_forward_prefetch):
17 for i, layer in enumerate(model.layers):
18 if i >= len(model.layers) - num_to_forward_prefetch:
19 break
20 layers_to_prefetch = [
21 model.layers[i + j] for j in range(1, num_to_forward_prefetch + 1)
22 ]
23 layer.set_modules_to_forward_prefetch(layers_to_prefetch)
24
25
26def set_modules_to_backward_prefetch(model, num_to_backward_prefetch):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected