Skip to content

Commit

Permalink
Ensure user sets backend to local w/ quantization (#3524)
Browse files Browse the repository at this point in the history
  • Loading branch information
Infernaught authored Aug 11, 2023
1 parent 404718b commit 190f208
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ludwig/config_validation/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ def _get_llm_model_config(model_name: str) -> AutoConfig:
def check_llm_quantization_backend_incompatibility(config: "ModelConfig") -> None: # noqa: F821
"""Checks that LLM model type with quantization uses the local backend."""
if config.backend is None:
if config.model_type == MODEL_LLM and config.quantization:
raise ConfigValidationError("LLM with quantization requires the 'local' backend to be set in the config.")
return

backend_type = config.backend.get("type", "local")
Expand Down
5 changes: 4 additions & 1 deletion tests/ludwig/config_validation/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ def test_check_llm_quantization_backend_incompatibility():
ModelConfig.from_dict(config)

del config["backend"]
ModelConfig.from_dict(config)
with pytest.raises(ConfigValidationError):
ModelConfig.from_dict(config)

del config["quantization"]
config["backend"] = {"type": "ray"}
Expand All @@ -443,6 +444,8 @@ def test_check_qlora():
type: text
trainer:
type: finetune
backend:
type: local
"""
)

Expand Down
1 change: 1 addition & 0 deletions tests/ludwig/schema/test_model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ def test_llm_quantization_config(bits: Optional[int], expected_qconfig: Optional
"quantization": {"bits": bits},
INPUT_FEATURES: [{NAME: "text_input", TYPE: "text"}],
OUTPUT_FEATURES: [{NAME: "text_output", TYPE: "text"}],
"backend": {"type": "local"},
}

if bits is None:
Expand Down

0 comments on commit 190f208

Please sign in to comment.