System Info
- PEFT
main: 051b2c5d
- Reproduction is config-only; no model download or accelerator is required.
Who can help?
No response
Information
Tasks
Reproduction
#3471 provisions prefix tuning for the largest per-layer KV footprint, but the selection loop compares only head_dim:
if layer_head_dim > head_dim:
head_dim = layer_head_dim
num_key_value_heads = layer_num_kv
A layer can have the same (or smaller) head dimension and more KV heads, making its total KV width larger. In that case the override is ignored. Later, _get_layer_kv_target_shape() returns the wider layer shape and get_prompt() skips that layer because the prefix was provisioned with too few heads.
Minimal reproduction:
from peft import PrefixTuningConfig, TaskType
from peft.utils.other import _prepare_prompt_learning_config
config = PrefixTuningConfig(task_type=TaskType.CAUSAL_LM, num_virtual_tokens=4)
model_config = {
"num_hidden_layers": 2,
"hidden_size": 1024,
"num_attention_heads": 8,
"num_key_value_heads": 4,
"head_dim": 128,
"per_layer_config": {
1: {"head_dim": 128, "num_key_value_heads": 8},
},
}
_prepare_prompt_learning_config(config, model_config)
print(config.num_attention_heads, config.token_dim)
Current output:
The largest per-layer KV footprint is 8 * 128 = 1024, so the prefix should be provisioned as:
The comparison should use layer_head_dim * layer_num_kv (including ties in head_dim) and retain the head/count pair that produces the largest footprint. A focused regression can exercise _prepare_prompt_learning_config() directly without depending on a Transformers 5.15 model. I can prepare that fix if this direction matches the intended behavior of #3471.
Expected behavior
Prefix tuning should provision enough KV width for the largest effective entry in per_layer_config, so a valid layer is not skipped solely because another layer has the same head dimension but fewer KV heads.
System Info
main:051b2c5dWho can help?
No response
Information
Tasks
examplesfolderReproduction
#3471 provisions prefix tuning for the largest per-layer KV footprint, but the selection loop compares only
head_dim:A layer can have the same (or smaller) head dimension and more KV heads, making its total KV width larger. In that case the override is ignored. Later,
_get_layer_kv_target_shape()returns the wider layer shape andget_prompt()skips that layer because the prefix was provisioned with too few heads.Minimal reproduction:
Current output:
The largest per-layer KV footprint is
8 * 128 = 1024, so the prefix should be provisioned as:The comparison should use
layer_head_dim * layer_num_kv(including ties inhead_dim) and retain the head/count pair that produces the largest footprint. A focused regression can exercise_prepare_prompt_learning_config()directly without depending on a Transformers 5.15 model. I can prepare that fix if this direction matches the intended behavior of #3471.Expected behavior
Prefix tuning should provision enough KV width for the largest effective entry in
per_layer_config, so a valid layer is not skipped solely because another layer has the same head dimension but fewer KV heads.