MCPcopy Create free account
hub / github.com/AMAP-ML/EMF / empty_cache

Function empty_cache

trl/trl/trainer/utils.py:1193–1208  ·  view source on GitHub ↗

Empties the cache of the available torch device. This function checks for the availability of different torch devices (XPU, MLU, NPU, CUDA) and empties the cache of the first available device it finds. If none of the specific devices are available, it defaults to emptying the CUDA cach

()

Source from the content-addressed store, hash-verified

1191
1192
1193def empty_cache() -> None:
1194 """Empties the cache of the available torch device.
1195
1196 This function checks for the availability of different torch devices (XPU, MLU, NPU, CUDA) and empties the cache of
1197 the first available device it finds.
1198
1199 If none of the specific devices are available, it defaults to emptying the CUDA cache.
1200 """
1201 if is_torch_xpu_available():
1202 torch.xpu.empty_cache()
1203 elif is_torch_mlu_available():
1204 torch.mlu.empty_cache()
1205 elif is_torch_npu_available():
1206 torch.npu.empty_cache()
1207 else:
1208 torch.cuda.empty_cache()
1209
1210
1211def decode_and_strip_padding(inputs: torch.Tensor, tokenizer: PreTrainedTokenizerBase) -> list[str]:

Callers 7

training_stepMethod · 0.85
trainMethod · 0.85
training_stepMethod · 0.85
get_train_dataloaderMethod · 0.85
compute_lossMethod · 0.85
trainMethod · 0.85
training_stepMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected