[feat] Add LoRA#592
Conversation
Summary of ChangesHello @rank-Yu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the system's capabilities by introducing comprehensive LoRA support for Large Language Models. It enables efficient fine-tuning of LLMs by integrating the PEFT library and adapting FSDP for optimal distributed training. A key innovation is the custom handling of LoRA weights within vLLM, allowing direct tensor loading for seamless model synchronization. This feature aims to reduce computational overhead and memory footprint during LLM fine-tuning and inference, ultimately leading to faster experimentation and deployment. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This PR introduces LoRA support for LLM, a valuable enhancement. The implementation correctly leverages peft for adapter management and adapts the FSDP strategy accordingly. A clever optimization is using the base model as a reference model during LoRA training to conserve memory. However, the integration with vLLM for rollouts relies on monkey-patching and includes some fragile logic for weight synchronization, particularly with hardcoded strings and parameter name manipulation, which could impact future maintainability. I've provided specific suggestions to improve these areas.
|
@Kuangdd01 Could you please verify the performance on a 7B model? |
|
🫡 Okay. will report result with rank=128 lr=1e-5 on Qwen2.5-7B-Inst here. |
|
THX AND HAPPY NEW YEAR! def _make_weight_iterator(
self, actor_weights: dict[str, Union[torch.Tensor, DTensor]]
) -> Iterable[tuple[str, torch.Tensor]]:
for name, tensor in actor_weights.items():
yield name, tensor.full_tensor() if self.world_size != 1 else tensorAlthough i don't know what happend here, I add a if-condition to avoid it. Can @rank-Yu explain what happened here? def _make_weight_iterator(
self, actor_weights: dict[str, Union[torch.Tensor, DTensor]]
) -> Iterable[tuple[str, torch.Tensor]]:
items = actor_weights.items() if isinstance(actor_weights, dict) else actor_weights
for name, tensor in items:
if not isinstance(name, str):
name = str(name)
if hasattr(tensor, "full_tensor"):
weight = tensor.full_tensor()
else:
weight = tensor # torch.Tensor
yield name, weight |
|
@Kuangdd01 @rank-Yu we need to first apply lora model then do fsdp sharding to have all params in dtensor |
Thanks! This can happen because In our LoRA path (e.g. So instead of using def _make_weight_iterator(
self, actor_weights: dict[str, Union[torch.Tensor, DTensor]]
) -> Iterable[tuple[str, torch.Tensor]]:
device = torch.device("cuda", torch.cuda.current_device())
for name, tensor in actor_weights.items():
yield name, tensor.to(device, non_blocking=True).full_tensor() if isinstance(tensor, DTensor) else tensorYour |
|
Qwen2.5-7B-Instruct Lora experiment log. |
Refactor model parameter casting for mixed precision and gradient checkpointing.
Refactor Lora handling in model optimization and log probability calculations.
|
@xlg-go Thanks for the information! We'll upgrade to vllm 0.14.0 recently |
Nice work!!!!!!! |
This PR introduces LoRA support.
Here's the test script used:
This run is over a 4090, which observes acc raise: