Skip to content

[Feature] Dynamic Lora Support in SGLang #2686

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

Open
2 tasks done
grahama1970 opened this issue Dec 31, 2024 · 13 comments
Open
2 tasks done

[Feature] Dynamic Lora Support in SGLang #2686

grahama1970 opened this issue Dec 31, 2024 · 13 comments

Comments

@grahama1970
Copy link

Checklist

Motivation

In SGLang, I would to dynamically apply domain-specific Lora adapters to smaller/local models. Normally, I use SGLang for inference. Recently, I've switched to Vllm which already has the ability to unload/load adaptors: https://docs.vllm.ai/en/latest/usage/lora.html
If this feature is already exists in SGlang, can you add an example in the documentation?

Related resources

https://docs.vllm.ai/en/latest/usage/lora.html

@zhaochenyang20
Copy link
Collaborator

@Ying1123 and @Wenyueh is on this. Thanks!

@yileld
Copy link
Contributor

yileld commented Jan 7, 2025

it easy to implement dynamic lora, just copy lora_manager.init_loras() as lora_manager.update_loras(), and add a judge
`

    if not hasattr(self, 'lora_modules'):
        self.lora_modules = []
    for module_name, module in self.get_target_modules():
        lora_module = self.set_lora_module(module_name, module)
        if lora_module:
            self.lora_modules.append(
                (module_name, lora_module)
            )

`
then use lora_manager.update_loras() before model_runner.lora_manager.prepare_lora_batch(ret).

@Fridge003
Copy link
Collaborator

Can this issue be solved with the answer by @yileld above? Is it necessary to open a PR to fix up this issue?@Ying1123

@grahama1970
Copy link
Author

If it's more complex than the above solution, I'd love a coded explanation on how Loras are applied to the model, an, if multiple adaptors can be applied simultaneously, from different knowledge bases like finance and math adaptors.

@zhaochenyang20
Copy link
Collaborator

If it's more complex than the above solution, I'd love a coded explanation on how Loras are applied to the model, an, if multiple adaptors can be applied simultaneously, from different knowledge bases like finance and math adaptors.

@Fridge003

@Fridge003
Copy link
Collaborator

If it's more complex than the above solution, I'd love a coded explanation on how Loras are applied to the model, an, if multiple adaptors can be applied simultaneously, from different knowledge bases like finance and math adaptors.

After reading relevant codes, I feel the above solution is not enough to support the feature well because LoraManager instance has many attributes to maintain and update. I will try to come up with a better solution.

@zhaochenyang20
Copy link
Collaborator

@Fridge003 Thanks for pointing this out, and I hope to see your solutions!

@grahama1970
Copy link
Author

Hi. Has there been any progress on Dynamically switching LorRas in SGLang? Thanks in advance

@zhaochenyang20
Copy link
Collaborator

@Fridge003

Hi. Has there been any progress on Dynamically switching LorRas in SGLang? Thanks in advance

@Fridge003
Copy link
Collaborator

Hi. Has there been any progress on Dynamically switching LorRas in SGLang? Thanks in advance

Hi, this feature is still under development and I have started a relevant PR draft #2891. The feature design is also described in this PR.

@zhaochenyang20
Copy link
Collaborator

zhaochenyang20 commented Jan 22, 2025

Cool! @Fridge003

Copy link

This issue has been automatically closed due to inactivity. Please feel free to reopen it if needed.

@sunzx8
Copy link

sunzx8 commented Apr 18, 2025

Hi. Has there been any progress on Dynamically switching LorRas in SGLang? Thanks in advance

Hi, this feature is still under development and I have started a relevant PR draft #2891. The feature design is also described in this PR.

Hi, has any updates now? thanks for the hard work in advance

@zhaochenyang20 zhaochenyang20 changed the title [Feature] Dynamic Lora Support in SGLang (like VLLM) [Feature] Dynamic Lora Support in SGLang Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants