How to merge it?
#4
by
michaelfeil
- opened
I tried the following code snippet:
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from peft import PeftModelForFeatureExtraction
from colpali_engine.models import ColQwen2, ColQwen2Processor
peft_model = PeftModelForFeatureExtraction.from_pretrained(
ColQwen2.from_pretrained(
"vidore/colqwen2-base",
torch_dtype="bfloat16",
device_map="cuda",
),
model_id="vidore/colqwen2-v0.1", torch_dtype="bfloat16", device_map="cuda")
merged_model = peft_model.merge_and_unload()
merged_model.push_to_hub("michaelfeil/colqwen2-v0.1",max_shard_size = "2GB")
One a series of simple images, this did not lead to the same model:
Loading checkpoint shards: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2/2 [00:05<00:00, 2.93s/it]
tensor([[16.2500, 12.4375, 12.6250, 11.6250, 11.7500, 11.5625],
[12.9375, 13.1250, 14.1250, 14.1250, 13.1875, 12.7500],
[11.8125, 13.6875, 12.0000, 11.8125, 12.8750, 16.2500]]) with model vidore/colqwen2-v0.1
model-00001-of-00003.safetensors: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2.00G/2.00G [00:45<00:00, 44.2MB/s]
model-00002-of-00003.safetensors: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 1.99G/1.99G [00:45<00:00, 43.8MB/s]
model-00003-of-00003.safetensors: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 430M/430M [00:09<00:00, 43.3MB/s]
Downloading shards: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [01:41<00:00, 33.85s/it]
Loading checkpoint shards: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:01<00:00, 1.73it/s]
tensor([[16.3750, 12.4375, 12.6875, 11.5625, 11.8125, 11.5625],
[13.0625, 13.1875, 14.0000, 14.1250, 13.2500, 12.7500],
[11.8125, 13.6875, 11.9375, 11.8125, 12.8750, 16.1250]]) with model michaelfeil/colqwen2-v0.1