-
Notifications
You must be signed in to change notification settings - Fork 228
[QuantizationFormat] Remove code inferring format #1786
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,15 @@ | |
has_offloaded_params, | ||
register_offload_parameter, | ||
) | ||
from compressed_tensors.config import ( | ||
CompressionFormat, | ||
infer_and_set_per_module_quantization_format, | ||
) | ||
from loguru import logger | ||
from transformers import PreTrainedModel | ||
|
||
from llmcompressor.core import active_session | ||
from llmcompressor.pytorch.model_load.helpers import copy_python_files_from_model_cache | ||
from llmcompressor.transformers.compression.quantization_format import ( | ||
infer_and_set_per_module_quantization_format, | ||
) | ||
from llmcompressor.transformers.compression.sparsity_metadata_config import ( | ||
SparsityConfigMetadata, | ||
) | ||
|
@@ -227,21 +228,21 @@ def get_model_compressor( | |
SparsityConfigMetadata.infer_sparsity_structure(model) | ||
) | ||
|
||
quantization_format: Optional[List[str]] = ( | ||
infer_and_set_per_module_quantization_format( | ||
model=model, | ||
quantization_format=quantization_format, | ||
save_compressed=save_compressed, | ||
sparsity_structure=None | ||
if sparsity_config is None | ||
else sparsity_config.sparsity_structure, | ||
if not save_compressed: | ||
quantization_format = CompressionFormat.dense.value | ||
|
||
if quantization_format is None and save_compressed: | ||
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 this condition now redundant given the above 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. I thought some more about it, if you swap to
It's a lot clearer that the two statements are disjoint. 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. could also use |
||
quantization_format: Optional[List[str]] = ( | ||
infer_and_set_per_module_quantization_format( | ||
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. FYI this function is still coupled with 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 there ever a time we'd want to infer quant format outside of instantiating a ModelCompressor? If not, tying the logic into the call makes sense to me |
||
model=model, | ||
sparsity_structure=None | ||
if sparsity_config is None | ||
else sparsity_config.sparsity_structure, | ||
) | ||
) | ||
) | ||
|
||
return ModelCompressor.from_pretrained_model( | ||
model, | ||
sparsity_config=sparsity_config, | ||
quantization_format=quantization_format, | ||
model, sparsity_config=sparsity_config, quantization_format=quantization_format | ||
) | ||
|
||
|
||
|
This file was deleted.
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.
Should there not be a warning if a user specifies a format but also specifies
save_compressed=False
? This seems like an invalid configuration that they should be aware of