Repository navigation
Honor model head dimensions in dummy KV caches - #2746
Open
林SO (Linxiushen) wants to merge 1 commit into
Open
林SO (Linxiushen) wants to merge 1 commit into
林SO (Linxiushen) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow correction preserves sharding behavior and has targeted regression coverage, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Corrects dummy KV-cache widths to honor model head dimensions while preserving existing KV-head sharding.
Changes:
- Uses the resolved
ModelWrapper.head_diminstead of recalculating width from sharded attention heads. - Adds regression coverage for cache shapes, dtypes, sharding, and a local Llama forward pass.
| File | Description |
|---|---|
| test/data_container/test_transformers_dummy_dataset.py | Adds shape and cache-extension regression tests. |
| olive/data/component/dataset.py | Uses the model’s resolved head dimension for dummy caches. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
TransformersDummyDataset.get_past_kv_inputs()calculates each KV head's width after dividing the attention-head count byworld_size. Forhidden_size=32, four attention heads andworld_size=2, it produces width 16 instead of 8. It also ignores an explicit modelhead_dim; a local Llama configured withhead_dim=12receives width-8 cached tensors and fails when extending the cache.Use the already-resolved
ModelWrapper.head_dimfor the width. The existing KV-head sharding remains in place. Regression coverage includes MHA/GQA, missing KV-head configuration, single-rank MQA, empty/populated caches, float32/float16, explicit/derived widths, and a randomly initialized two-layer Llama that extends the resulting cache in a real CPU forward pass.Validation on base
1ef7d129570ea0faafeb2554ef1208de1080d12d:python -m pytest -q test/data_container/test_transformers_dummy_dataset.py test/data_container/test_dataset.py test/model/test_kv_cache_config.py(normal repository fixtures, fresh local--basetemp, Hugging Face offline mode).lintrunner --verbose olive/data/component/dataset.py test/data_container/test_transformers_dummy_dataset.py, including Pylint, Ruff, formatting, whitespace and EditorConfig;git diff --checkalso passed. No further formatting fixes were needed.The full suite, ONNX export, distributed execution and GPU execution were not run. No pretrained weights were downloaded; this is cache-shape/compatibility validation, not model-quality or performance evidence. KV-head counts still use the existing floor division; KV-head replication and validation of unsupported sharding configurations are outside this change.
AI assistance: this patch and tests were developed and reviewed with Codex; the reported commands were executed locally.
Checklist before requesting a review
lintrunner(all applicable rules passed; no further fixes required).(Optional) Issue link
Found by inspecting the dummy-cache generator; no new issue was opened.