Peft should update the way of passing past_key_values of prefix-tuning, prompt tuning etc
Kamichanw opened this issue · 1 comments
Kamichanw commented
System Info
transformers
version: 4.46.0.dev0- Platform: Linux-4.15.0-76-generic-x86_64-with-glibc2.27
- Python version: 3.12.4
- Huggingface_hub version: 0.23.4
- Safetensors version: 0.4.3
- Accelerate version: 0.34.2
- Accelerate config: - compute_environment: LOCAL_MACHINE
- distributed_type: DEEPSPEED
- mixed_precision: fp16
- use_cpu: False
- debug: False
- num_processes: 4
- machine_rank: 0
- num_machines: 1
- rdzv_backend: static
- same_network: True
- main_training_function: main
- enable_cpu_affinity: False
- deepspeed_config: {'gradient_accumulation_steps': 16, 'gradient_clipping': 1.0, 'offload_optimizer_device': 'cpu', 'offload_param_device': 'cpu', 'zero3_init_flag': False, 'zero3_save_16bit_model': False, 'zero_stage': 3}
- downcast_bf16: no
- tpu_use_cluster: False
- tpu_use_sudo: False
- tpu_env: [] - PyTorch version (GPU?): 2.3.1+cu121 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?:
- Using GPU in script?:
- GPU type: NVIDIA GeForce RTX 3090
Who can help?
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examples
folder - My own task or dataset (give details below)
Reproduction
With the following code snippet (btw, it cannot run successfully both in transformers v4.44 and v4.46.0. I'm not sure who should be responsible for this):
import peft
from transformers import IdeficsForVisionText2Text, AutoProcessor
import sys
import torch
sys.path.insert(0, "..")
import config # my own file
device = torch.device("cuda:2")
model = IdeficsForVisionText2Text.from_pretrained(
config.idefics_9b_path, torch_dtype=torch.float16, trust_remote_code=True
).to(device)
processor = AutoProcessor.from_pretrained(
config.idefics_9b_path, torch_dtype=torch.float16, trust_remote_code=True
)
model = peft.get_peft_model(
model,
peft.PrefixTuningConfig(
peft_type="PREFIX_TUNING",
task_type="CAUSAL_LM",
num_virtual_tokens=1,
token_dim=4096,
num_transformer_submodules=1,
num_attention_heads=32,
num_layers=32,
encoder_hidden_size=768,
),
)
inputs = processor(["hello"]).to(device)
model(**inputs)
A deprecation warning appears:
We detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class (https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)
Expected behavior
Maybe you should update it.
BenjaminBossan commented