Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 0 additions & 114 deletions src/llmcompressor/transformers/compression/quantization_format.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Comment on lines +231 to +232
Copy link
Collaborator

@kylesayrs kylesayrs Sep 8, 2025

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


if quantization_format is None and save_compressed:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this condition now redundant given the above if not save_compressed check?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought some more about it, if you swap to

if save_compressed and quantization_format is None:

It's a lot clearer that the two statements are disjoint.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also use elif quantization_format is None instead.

quantization_format: Optional[List[str]] = (
infer_and_set_per_module_quantization_format(
Copy link
Collaborator

@kylesayrs kylesayrs Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this function is still coupled with ModelCompressor.from_pretrained_model. I'd ideally like to see this function called inside ModelCompressor.from_pretrained_model at some point

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
)


Expand Down

This file was deleted.

Loading