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

Add PixArt support #731

Merged
merged 22 commits into from
Dec 22, 2024
Merged

Add PixArt support #731

merged 22 commits into from
Dec 22, 2024

Conversation

JingyaHuang
Copy link
Collaborator

@JingyaHuang JingyaHuang commented Nov 4, 2024

What does this PR do?

  • PixArt export support Alpha via CLI
  • Tiny
optimum-cli export neuron --model hf-internal-testing/tiny-pixart-alpha-pipe --batch_size 1 --height 64 --width 64 --num_images_per_prompt 1 --torch_dtype bfloat16 --sequence_length 32 pixart_alpha_neuron_tiny/
  • Regular
optimum-cli export neuron --model PixArt-alpha/PixArt-XL-2-512x512 --batch_size 1 --height 512 --width 512 --num_images_per_prompt 1 --torch_dtype bfloat16 --sequence_length 120 pixart_alpha_neuron_512/
  • PixArt export support Alpha via API
import torch
from optimum.neuron import NeuronPixArtAlphaPipeline

# Compile
model_id = "PixArt-alpha/PixArt-XL-2-512x512"
compiler_args = {"auto_cast": "none"}
input_shapes = {"batch_size": 1, "height": 512, "width": 512, "sequence_length": 120}

neuron_model = NeuronPixArtAlphaPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16, export=True, disable_neuron_cache=True, **compiler_args, **input_shapes)

# Save locally or upload to the HuggingFace Hub
save_directory = "pixart_alpha_neuron_512/"
neuron_model.save_pretrained(save_directory)
  • Caching support
  • PixArt inference support
from optimum.neuron import NeuronPixArtAlphaPipeline

# Inference
neuron_model = NeuronPixArtAlphaPipeline.from_pretrained("pixart_alpha_neuron_512/")
prompt = "An astronaut riding a green horse"
image = neuron_model(prompt=prompt).images[0]
image.save("out.png")
  • Tests
  • Documentation

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@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.

Copy link

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Nov 20, 2024
@github-actions github-actions bot removed the Stale label Nov 21, 2024
Copy link

github-actions bot commented Dec 8, 2024

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 8, 2024
@github-actions github-actions bot removed the Stale label Dec 10, 2024
@JingyaHuang JingyaHuang marked this pull request as ready for review December 12, 2024 12:02
Copy link
Member

@michaelbenayoun michaelbenayoun left a comment

Choose a reason for hiding this comment

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

Not very knowleadgeable on this part, but lgtm!

optimum/neuron/modeling_diffusion.py Outdated Show resolved Hide resolved
optimum/neuron/utils/optimization_utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@dacorvo dacorvo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks !

@JingyaHuang JingyaHuang merged commit f44211c into main Dec 22, 2024
8 of 12 checks passed
@JingyaHuang JingyaHuang deleted the add-pixart-support branch December 22, 2024 19:23
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