-
Notifications
You must be signed in to change notification settings - Fork 111
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
sd3 pipeline support #916
base: main
Are you sure you want to change the base?
sd3 pipeline support #916
Conversation
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. |
a19a436
to
b543d94
Compare
The changes to be made in this PR after the refactorization are very simple and mostly will make it more readable:
I also suggest you take a look at the original refactorization work in huggingface/optimum#2021, I explain there issues with the previous approach and why the refactorization is not only that but also fixing many issues with the previous design (reproducibility of results & numeric consistency with diffusers), which weren't tested before or simply ignored for some architectures/tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can you run styling and add tests please.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be merged once tests are updated and passed
7916966
to
be4624d
Compare
@IlyasMoutawwakil now all relevant tests are fixed, please take a look one more time |
Co-authored-by: Ilyas Moutawwakil <[email protected]>
Co-authored-by: Ilyas Moutawwakil <[email protected]>
Co-authored-by: Ilyas Moutawwakil <[email protected]>
ov_outputs = self.request(model_inputs, share_inputs=True).to_dict() | ||
|
||
ov_outputs = self.request(model_inputs, share_inputs=True) | ||
main_out = ov_outputs[0] | ||
model_outputs = {} | ||
for key, value in ov_outputs.items(): | ||
model_outputs[next(iter(key.names))] = torch.from_numpy(value) | ||
|
||
if output_hidden_states: | ||
model_outputs["hidden_states"] = [] | ||
for i in range(self.config.num_hidden_layers): | ||
model_outputs["hidden_states"].append(model_outputs.pop(f"hidden_states.{i}")) | ||
model_outputs["hidden_states"].append(model_outputs.get("last_hidden_state")) | ||
model_outputs[self.model.outputs[0].get_any_name()] = torch.from_numpy(main_out) | ||
if len(self.model.outputs) > 1 and "pooler_output" in self.model.outputs[1].get_any_name(): | ||
model_outputs["pooler_output"] = torch.from_numpy(ov_outputs[1]) | ||
if self.hidden_states_output_names and "last_hidden_state" not in model_outputs: | ||
model_outputs["last_hidden_state"] = torch.from_numpy(ov_outputs[self.hidden_states_output_names[-1]]) | ||
if ( | ||
self.hidden_states_output_names | ||
and output_hidden_states | ||
or getattr(self.config, "output_hidden_states", False) | ||
): | ||
hidden_states = [torch.from_numpy(ov_outputs[out_name]) for out_name in self.hidden_states_output_names] | ||
model_outputs["hidden_states"] = hidden_states |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this complexity is needed, the original code does the same thing by seperating the torch.from_numpy
and collecting the hidden states in a list if requested, the only change you'll have to do is to account for the missing self.config.num_hidden_layers
by using self.config.num_layers
otherwise for t5-encoder https://huggingface.co/stabilityai/stable-diffusion-3-medium-diffusers/blob/main/text_encoder_3/config.json#L21
What does this PR do?
Fixes # (issue)
Before submitting