|
82 | 82 |
|
83 | 83 |
|
84 | 84 | if is_peft_available(): |
85 | | - import peft |
86 | | - from peft import PeftConfig, PeftModel, PrefixTuningConfig, PromptLearningConfig, get_peft_model |
| 85 | + from peft import PeftConfig, PeftModel, PromptLearningConfig, get_peft_model |
87 | 86 | from peft.tuners.tuners_utils import BaseTunerLayer |
88 | 87 |
|
89 | 88 |
|
@@ -526,17 +525,14 @@ def __init__( |
526 | 525 | get_peft_model_kwargs = {} |
527 | 526 | if args.deepspeed_plugin is not None and args.deepspeed_plugin.zero_stage == 3 and not _is_quantized_model: |
528 | 527 | get_peft_model_kwargs["autocast_adapter_dtype"] = False |
529 | | - # Prefix tuning moves the cache onto the model's device map, which reads `Cache.key_cache`, removed |
530 | | - # from transformers. Fixed in PEFT 0.18.0 (peft#2821). |
531 | | - if ( |
532 | | - isinstance(peft_config, PrefixTuningConfig) |
533 | | - and Version(peft.__version__) <= Version("0.17.1") |
534 | | - and hasattr(model, "hf_device_map") |
535 | | - ): |
| 528 | + # Rejected here rather than after wrapping, since `get_peft_model` itself fails on prefix tuning with |
| 529 | + # peft <= 0.17.1 (peft#2821). |
| 530 | + if isinstance(peft_config, PromptLearningConfig): |
536 | 531 | raise ValueError( |
537 | | - "Prefix tuning requires `peft>=0.18.0` when the model is loaded with a device map. Upgrade " |
538 | | - "peft, or load the model with `device_map=None`. See " |
539 | | - "https://github.com/huggingface/peft/issues/2821." |
| 532 | + "Prompt-learning PEFT methods (PromptTuning, PrefixTuning, P-Tuning) are not supported. The " |
| 533 | + "distillation loss bypasses `PeftModel.forward()` by calling the backbone directly, so virtual " |
| 534 | + "tokens are never prepended and the loss is computed on the wrong sequence. Use a weight-based " |
| 535 | + "adapter such as LoRA instead." |
540 | 536 | ) |
541 | 537 | model = get_peft_model(model, peft_config, **get_peft_model_kwargs) |
542 | 538 |
|
|
0 commit comments