feat: Replace num_replicate_kv_heads with boolean replicate_kv_heads flag - #1212
Open
quic-dhirajku wants to merge 2 commits into
Open
feat: Replace num_replicate_kv_heads with boolean replicate_kv_heads flag#1212quic-dhirajku wants to merge 2 commits into
quic-dhirajku wants to merge 2 commits into
Conversation
quic-dhirajku
commented
Jul 24, 2026
Contributor
- Replace user-facing num_replicate_kv_heads int param in qaic_configwith a boolean replicate_kv_heads flag; value computation is now fully internal and never exposed to the user.
- maybe_apply_replicate_kv_transform reads only replicate_kv_headsfrom qaic_config; computed repeat factor is kept in hash_params and never written back into qaic_config.
- Resolve model_config.text_config before calling calculate_num_replicate_kv_heads so VLM top-level configs correctly surface text-side head counts.
ochougul
reviewed
Jul 24, 2026
Comment on lines
+1618
to
+1619
| num_replicate_kv_heads = self.lang_model.hash_params.get("num_replicate_kv_heads", 1) | ||
| offload_pt_weights = num_replicate_kv_heads <= 1 |
Contributor
There was a problem hiding this comment.
This change is not required.
ochougul
reviewed
Jul 24, 2026
Comment on lines
+136
to
+139
| num_replicate_kv_heads = calculate_num_replicate_kv_heads( | ||
| num_devices=num_devices, | ||
| text_model_config=effective_config, | ||
| ) |
Contributor
There was a problem hiding this comment.
Also update this logic such that, we replicate only when num_devices>num_kv_heads and num_devices%num_kv_heads==0
ochougul
requested changes
Jul 24, 2026
quic-dhirajku
force-pushed
the
boolean_replicate_kv
branch
2 times, most recently
from
July 27, 2026 10:04
d6773e0 to
ae4f304
Compare
ochougul
approved these changes
Jul 28, 2026
…flag - Replace user-facing num_replicate_kv_heads int param in qaic_configwith a boolean replicate_kv_heads flag; value computation is now fully internal and never exposed to the user. - maybe_apply_replicate_kv_transform reads only replicate_kv_headsfrom qaic_config; computed repeat factor is kept in hash_params and never written back into qaic_config. - Resolve model_config.text_config before calling calculate_num_replicate_kv_heads so VLM top-level configs correctly surface text-side head counts. Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
- Rewrite calculate_num_replicate_kv_heads to find the smallest repeat K such that new_kv_heads = num_kv_heads * K >= num_devices, satisfying new_kv_heads % num_devices == 0 and num_attention_heads % new_kv_heads == 0 - Return None when replication is not applicable (MHA or unachievable) - Update unit tests to reflect new minimum-repeat semantics and correct expected values for MQA and MHA cases Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
quic-dhirajku
force-pushed
the
boolean_replicate_kv
branch
from
July 28, 2026 08:47
ae4f304 to
4842a61
Compare
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.