Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergekit-extract-lora does not extract - the destination is empty #447

Open
raulod opened this issue Oct 28, 2024 · 2 comments
Open

mergekit-extract-lora does not extract - the destination is empty #447

raulod opened this issue Oct 28, 2024 · 2 comments

Comments

@raulod
Copy link

raulod commented Oct 28, 2024

Tried to extracting LORA from gemma-2-it

mergekit-extract-lora models/gemma-2-2b-it/ models/gemma-2-2b models/lora/gemma-2-it-lora
The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable.
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 11.28it/s]
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:01<00:00,  1.66it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌| 288/289 [08:55<00:01,  1.86s/it]
Traceback (most recent call last):
  File "/usr/local/bin/mergekit-extract-lora", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/thirdparty/mergekit/mergekit/scripts/extract_lora.py", line 576, in main
    lora_weights, ranks = extract_lora(
                          ^^^^^^^^^^^^^
  File "/code/thirdparty/mergekit/mergekit/scripts/extract_lora.py", line 246, in extract_lora
    base_weight = base_loader.get_tensor(f"{module_name}.weight")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/thirdparty/mergekit/mergekit/io/lazy_tensor_loader.py", line 127, in get_tensor
    raise KeyError(key)
KeyError: 'lm_head.weight'

It look long time to complete but the destination folder is empty.

@Touch-Night
Copy link

Touch-Night commented Nov 4, 2024

Gemma 2 does not have lm_head.weight

@Touch-Night
Copy link

Try this:

    for module_type, module_name in tqdm(module_details):
        try:
            base_weight = base_loader.get_tensor(f"{module_name}.weight")
            finetuned_weight = finetuned_loader.get_tensor(f"{module_name}.weight")
        except KeyError:
            logging.warning(f"Module '{module_name}' not found in the model!")
            continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants