MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / offload

Method offload

deepspeed/compile/util.py:385–410  ·  view source on GitHub ↗
(self, argument)

Source from the content-addressed store, hash-verified

383 self.non_tensor = {}
384
385 def offload(self, argument):
386
387 def is_base_tensor(tensor):
388 return torch.is_tensor(a) and not a._is_view() and not hasattr(tensor, "ds_id")
389
390 base_tensor_ids = set()
391 for a in argument:
392 if is_base_tensor(a):
393 base_tensor_ids.add(id(a))
394
395 for a in argument:
396 a_id = id(a)
397
398 if is_base_tensor(a):
399 # Base tensor
400 self.devices[a_id] = a.device
401 self.base_tensors[a_id] = a
402 else:
403 # other types or ds tensor
404 self.non_tensor[a_id] = a
405
406 self.arg_list.append(a_id)
407
408 for a in argument:
409 if is_base_tensor(a):
410 a.data = a.data.to("cpu")
411
412 def reload(self, in_place):
413

Callers 1

Calls 3

addMethod · 0.45
appendMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected