Skip to content
Merged
Changes from 2 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
7 changes: 3 additions & 4 deletions src/lighteval/models/transformers/transformers_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class TransformersModelConfig(ModelConfig):
subfolder: str | None = None
revision: str = "main"
batch_size: PositiveInt | None = None
generation_size: PositiveInt = 256
max_length: PositiveInt | None = None
model_loading_kwargs: dict = {}
add_special_tokens: bool = True
model_parallel: bool | None = None
dtype: str | None = None
Expand Down Expand Up @@ -384,9 +384,8 @@ def _create_auto_model(self) -> transformers.PreTrainedModel:

pretrained_config = self.transformers_config

kwargs = {}
if "quantization_config" not in pretrained_config.to_dict():
kwargs["quantization_config"] = quantization_config
self.config.model_loading_kwargs["quantization_config"] = quantization_config
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

Mutating config.model_loading_kwargs in place can lead to unexpected state if _create_auto_model is called multiple times. Consider merging into a local dict and passing that to from_pretrained.

Copilot uses AI. Check for mistakes.


model = AutoModelForCausalLM.from_pretrained(
self.config.model_name,
Expand All @@ -395,7 +394,7 @@ def _create_auto_model(self) -> transformers.PreTrainedModel:
device_map=device_map,
torch_dtype=torch_dtype,
trust_remote_code=self.config.trust_remote_code,
**kwargs,
**self.config.model_loading_kwargs,
)
# model.to(self.device)
model.eval()
Expand Down
Loading