Skip to content

[Inference Providers] Support for LoRAs #3005

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

Merged
merged 16 commits into from
Apr 29, 2025
Merged

[Inference Providers] Support for LoRAs #3005

merged 16 commits into from
Apr 29, 2025

Conversation

hanouticelina
Copy link
Contributor

This work mirrors the PR in the js client (see huggingface.js#1347).

This PR introduces the support of LoRAs for fal-ai, this should not be merged until the server-side PR is merged (private).

Changes

  • update _prepare_mapped_model to return a ProviderMappingInfo object. This object returns the provider id, the hf model id (optional) and the lora weights path (optional) that is expected to be sent in the payload.
  • update _prepare_payload_as_dict and _prepare_payload_as_bytes signatures to accept a ProviderMappingInfo object as an argument.

the logic is implemented within the TaskProviderHelper base class, to avoid duplicating similar logic when we support LoRAs for the other providers. Note that LoRAs can also be used with other tasks like text-to-video as instance.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

I haven't tested locally yet but left some high-level comments related to naming + structure to match as much as possible the JS counterpart.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina hanouticelina requested a review from Wauplin April 16, 2025 09:17
Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Looking forward to this!

@SBrandeis SBrandeis self-assigned this Apr 16, 2025
@hanouticelina hanouticelina requested a review from Wauplin April 17, 2025 10:26
SBrandeis added a commit to huggingface/huggingface.js that referenced this pull request Apr 25, 2025
Copy link
Contributor

@SBrandeis SBrandeis left a comment

Choose a reason for hiding this comment

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

lgtm

@hanouticelina
Copy link
Contributor Author

hanouticelina commented Apr 25, 2025

✅ I tested the PR with :

from huggingface_hub import InferenceClient


client = InferenceClient(
    provider="fal-ai",
)
image = client.text_to_image(
    prompt="a boy and a girl looking out of a window with a cat perched on the window sill",
    model="openfree/flux-chatgpt-ghibli-lora",
)

output image :
lora

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

All good! Pre-approving but still curious about this hardcoded model_name

@hanouticelina
Copy link
Contributor Author

i'm merging, CI is red for unrelated reasons (hub-ci seems to be down)

@hanouticelina hanouticelina merged commit bebc1f7 into main Apr 29, 2025
24 of 25 checks passed
@hanouticelina hanouticelina deleted the fal-ai-loras branch April 29, 2025 14:59
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

Successfully merging this pull request may close these issues.

4 participants