Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Improve KVCacheInjector config failure message #1687

Merged
merged 1 commit into from
Jul 25, 2023
Merged
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
10 changes: 6 additions & 4 deletions src/sparseml/exporters/kv_cache_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def __init__(
Alternatively:
```python
onnx_model: onnx.ModelProto = ...
exporter = KeyValueCacheInjector(model_path="path/to/model")
exporter = KeyValueCacheInjector(num_attention_heads = 16,
exporter = KeyValueCacheInjector(model_path="path/to/model",
num_attention_heads = 16,
hidden_size_dim = 64)
exporter.export(onnx_model, "model.onnx")
```
Expand Down Expand Up @@ -106,8 +106,10 @@ def __init__(

else:
raise ValueError(
"Either `model_path` or kwargs must be provided to "
"KeyValueCacheInjector"
f"Unable to find KeyValueCacheConfig for model_path='{model_path}'. "
"Either kwargs must be provided to KeyValueCacheInjector to construct "
"OnnxTransform, or a new config should be registered in "
"`sparseml/src/sparseml/exporters/transforms/kv_cache/configs.py`"
)

super().__init__(transforms)
Expand Down