-
Notifications
You must be signed in to change notification settings - Fork 60
fix guff scheme and device_map bug #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3a5319f
b81446b
5363860
32f5e80
6525fbc
94c2ef2
aa89b5c
09f4583
fedd4fe
797e2a7
253d7d7
b69e1d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,6 +355,19 @@ def get_packing_device(device: str | torch.device | None = "auto") -> torch.devi | |
| raise TypeError(f"Unsupported device type: {type(device)} ({device})") | ||
|
|
||
|
|
||
| def is_complex_device_mapping(device_map): | ||
| if device_map is None or isinstance(device_map, int): | ||
| return False | ||
| elif device_map == "auto": | ||
| return True | ||
| elif isinstance(device_map, str) and "," in device_map: | ||
| return True | ||
| elif isinstance(device_map, dict): | ||
| return True | ||
| else: | ||
| return False | ||
|
|
||
|
|
||
| class CpuInfo(object): | ||
| """Get CPU Info.""" | ||
|
|
||
|
|
@@ -598,15 +611,11 @@ def set_tuning_device_for_layer(model, name: str, device: str) -> None: | |
| def set_non_auto_device_map( | ||
| model: torch.nn.Module, device_map: Union[str, int, dict], quant_layer_names: Union[None, list, tuple] = None | ||
| ) -> None: | ||
| if not device_map: | ||
| return | ||
| if device_map == "auto": | ||
| return | ||
| if isinstance(device_map, str) and "," in device_map: # auto device map | ||
| return | ||
| if isinstance(device_map, int): | ||
| if not device_map or device_map == "auto" or isinstance(device_map, int): | ||
| return | ||
| if isinstance(device_map, str): | ||
| if "," in device_map: # auto device map | ||
| return | ||
| device_map = device_map.replace(" ", "") | ||
| infos = device_map.split(",") | ||
| device_map_dict = {} | ||
|
|
@@ -840,7 +849,7 @@ def set_auto_device_map_for_block_with_tuning( | |
| num_devices = torch.xpu.device_count() | ||
| device_name = "xpu" | ||
| else: | ||
| raise RuntimeError("No CUDA or XPU devices found.") | ||
| return | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to support all devices that are already supported by PyTorch, at least for single-device setups, such as NPUs or other accelerators?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change is to solve device_map={"*": "cpu"} |
||
| device_list = None | ||
| if isinstance(device_map, str) and "," in device_map: | ||
| device_list = [int(dev) for dev in device_map.split(",") if dev.isdigit()] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why need this, the default bits is in scheme="W4A16"
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the default values are in scheme, if users want to override some values in the scheme, then set the specific keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if use auto_round api as this: auto_round(data_type="rtn_int_sym_dq", bits=3), it will have some bugs since default scheme is W4A16 with super_bits = None and super_group_size = None