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

lora : raise error if lm_head is ignored #9103

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix style
  • Loading branch information
ngxson committed Aug 20, 2024
commit f3a30334154ba63e47f01ba8d3bb24897a7c737b
4 changes: 2 additions & 2 deletions convert_lora_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ def get_tensors(self) -> Iterator[tuple[str, Tensor]]:
yield (name, cast(torch.Tensor, LoraTorchTensor(tensor.A, tensor.B)))

def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
dest = super().modify_tensors(data_torch, name, bid)
dest = list(super().modify_tensors(data_torch, name, bid))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed to recast to a list super().modify_tensors(data_torch, name, bid)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@compilade compilade Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is needed because it can also be a Generator (when modify_tensors uses yield).

# for now, we cannot convert archs that use the same tensor for tok_embd and output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# for now, we cannot convert archs that use the same tensor for tok_embd and output
# for now, we cannot convert adapters with lm_head for archs that use the same tensor for tok_embd and output

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll rephrase this to void mixing naming scheme

# see: https://github.com/ggerganov/llama.cpp/issues/9065
if name == "lm_head.weight" and len(dest) == 0:
raise ValueError(f"lm_head is present in adapter, but is ignored in base model")
raise ValueError("lm_head is present in adapter, but is ignored in base model")
for dest_name, dest_data in dest:
assert isinstance(dest_data, LoraTorchTensor)
lora_a, lora_b = dest_data.get_lora_A_B()
Expand Down
Loading