Skip to content

Repeatkv transform#1037

Open
quic-dhirajku wants to merge 8 commits into
quic:release/v1.22.0_tmpfrom
quic-dhirajku:repeatkv_transform
Open

Repeatkv transform#1037
quic-dhirajku wants to merge 8 commits into
quic:release/v1.22.0_tmpfrom
quic-dhirajku:repeatkv_transform

Conversation

@quic-dhirajku
Copy link
Copy Markdown
Contributor

This PR improves repeat_kv to be more reliable and portable across model/config variants and quantized backends. It adds shared config-key resolution (for common head aliases), centralized repeat-value calculation from (num_devices, model_config), and consistent propagation of num_kv_heads_repeat into qaic_config and hashing so export/compile state matches the effective runtime settings. It also hardens transform behavior: MLA models are explicitly skipped with a warning (instead of attempting unsafe replication), and ReplicateKVHeadTransform.apply() now reports transformed status only when replication is actually applied.
The main functional upgrade is quantized RepeatKV support. _duplicate_weights_for_linear_layer was updated to correctly handle packed layouts (instead of relying on generic reshape assumptions), including AWQ/GPTQ packed tensors and a full QuantLinearORT path (dequantize → replicate → resize buffers → repack). This directly fixes the observed failures in RepeatKV quantized tests (shape mismatch and MatMulNBits zero-point dtype issues), and the previously failing AWQ TinyLlama RepeatKV test now passes.

@quic-rishinr quic-rishinr added the 1.22 Release 1.22 candidate label Jun 5, 2026
@quic-rishinr quic-rishinr requested review from ochougul and vbaddi June 5, 2026 04:45
…VLMs. Based on PR quic#625. Addressed most of the comments made on the previous PR.

Repeat check is done on a subset of models during CI, primarily due to difference in configs of such models.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
…ng with changes made for the new transforms.

TODO: Check for the ONNX directory path name being different.
Check if the list of classes for mapping covers all the models that we support.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
…oder Wrappers were added to string mapping list to enable dummy model export for CI.

Changes were made to prevent multiple application of ReplicateKVTransform if done in either Encoder or Decoder Wrapper already.
Modeling files updated to access config in EncoderWrapper as well.
Infra added for causalLM and VLM checks for repeatKV setup CI tests.
CausalLM script APIRunner instantiation moved to allow updated input shapes to be made. Similarly commented export in VLM script since compile will call it with updated changes already.
TODO: Confirm the changes that were made for DeepSeekV3 model for RepeatKV, currently they were removed for a generic approach.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
Made changes to allow generic name based transformation of heads (num_attention_heads, n_heads, n_head etc).
Minor edits and utils created for this task.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
Edited the changes as suggested by quic-mamta.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
Enabled method to calculate best possible repeat_kv count based on model and num devices.
Added repeat_kv method for AWQ quantized models.

Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
@quic-dhirajku quic-dhirajku marked this pull request as ready for review June 5, 2026 06:24
Signed-off-by: Dhiraj Kumar Sah <dhirajku@qti.qualcomm.com>
@quic-dhirajku quic-dhirajku force-pushed the repeatkv_transform branch 2 times, most recently from fe75c92 to 008adc7 Compare June 5, 2026 08:30
@quic-rishinr quic-rishinr mentioned this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.22 Release 1.22 candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants