-
Notifications
You must be signed in to change notification settings - Fork 15
More fixes needed when QuantizationConfig is None #184
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
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 |
---|---|---|
|
@@ -107,8 +107,8 @@ def load_pretrained_quantization(model: Module, model_name_or_path: str): | |
|
||
|
||
def apply_quantization_config( | ||
model: Module, config: QuantizationConfig, run_compressed: bool = False | ||
) -> Dict: | ||
model: Module, config: Union[QuantizationConfig, None], run_compressed: bool = False | ||
) -> OrderedDict: | ||
""" | ||
Initializes the model for quantization in-place based on the given config | ||
|
||
|
@@ -117,6 +117,10 @@ def apply_quantization_config( | |
:param run_compressed: Whether the model will be run in compressed mode or | ||
decompressed fully on load | ||
""" | ||
# Workaround for when HF Quantizer passes None, see PR #180 | ||
if config is None: | ||
return OrderedDict() | ||
|
||
# remove reference to the original `config` | ||
# argument. This function can mutate it, and we'd | ||
# like to keep the original `config` as it is. | ||
|
@@ -186,14 +190,14 @@ def apply_quantization_config( | |
return names_to_scheme | ||
|
||
|
||
def process_quantization_config(config: QuantizationConfig) -> QuantizationConfig: | ||
def process_quantization_config(config: Optional[QuantizationConfig]) -> Optional[QuantizationConfig]: | ||
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. Seems like the only use of |
||
""" | ||
Preprocess the raw QuantizationConfig | ||
|
||
:param config: the raw QuantizationConfig | ||
:return: the processed QuantizationConfig | ||
:param config: Optional raw QuantizationConfig | ||
:return: the processed QuantizationConfig, if the raw config is not None | ||
""" | ||
if config.kv_cache_scheme is not None: | ||
if config is not None and config.kv_cache_scheme is not None: | ||
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. Do we use this function outside of |
||
config = process_kv_cache_config(config) | ||
|
||
return config | ||
|
Uh oh!
There was an error while loading. Please reload this page.