MCPcopy
hub / github.com/huggingface/alignment-handbook / get_kbit_device_map

Function get_kbit_device_map

src/alignment/model_utils.py:38–40  ·  view source on GitHub ↗

Useful for running inference with quantized models by setting `device_map=get_peft_device_map()`

()

Source from the content-addressed store, hash-verified

36
37
38def get_kbit_device_map() -> Dict[str, int] | None:
39 """Useful for running inference with quantized models by setting `device_map=get_peft_device_map()`"""
40 return {"": get_current_device()} if torch.cuda.is_available() else None
41
42
43def get_quantization_config(model_args: ModelArguments) -> BitsAndBytesConfig | None:

Callers 4

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 1

get_current_deviceFunction · 0.85

Tested by

no test coverage detected