-
Notifications
You must be signed in to change notification settings - Fork 61
Diffusers support #604
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
base: main
Are you sure you want to change the base?
Diffusers support #604
Conversation
ffed450 to
eb55c51
Compare
42cf8b6 to
1cf4b30
Compare
1cf4b30 to
0ee0b9f
Compare
0ee0b9f to
1e0fbfd
Compare
bb01d84 to
00f5286
Compare
00f5286 to
0a26f1b
Compare
ac6382a to
19e0ccd
Compare
| # text_encoder=custom_text_encoder, # Your custom CLIP text encoder | ||
| # transformer=custom_transformer, # Your custom transformer model | ||
| # tokenizer=custom_tokenizer, # Your custom tokenizer |
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.
this is nice.
19e0ccd to
8d78ac9
Compare
Signed-off-by: Amit Raj <amitraj@qti.qualcomm.com> Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcomm.com> Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcomm.com> Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
…nd comments addressed Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
… export 3. Hash getting changed after each export Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
226e65a to
901d293
Compare
| def encode_prompt( | ||
| self, | ||
| prompt: Union[str, List[str]], | ||
| prompt_2: Optional[Union[str, List[str]]] = None, |
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.
nit(suggestion): better to use prompt and secondary_prompt as variable names
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.
These are official names from diffusers, as we are alligned with diffusers pipeline, In my sugggestion we should keep the name same. Plaease refer this- Link
| @@ -0,0 +1,95 @@ | |||
|
|
|||
| <div align="center"> | |||
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.
move it to docs folder and create a new page for diffusers
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.
Sure Rishin, Will put this in the docs as well as it will be helpful for the sphinx documentation. But keeping it here also make sense as it gives the proper idea about `How anyone can run diffusers supported model using Qefficient?"
| @@ -0,0 +1,55 @@ | |||
| # ----------------------------------------------------------------------------- | |||
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.
Add a readme file explaining the usage, follow the the contribution.md file in the example folder
| parallel { | ||
| stage('Run Non-CLI Non-QAIC Tests') { | ||
| steps { | ||
| timeout(time: 25, unit: 'MINUTES') { |
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.
Create a new tag and add tests as well
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.
Yes, with the following PR we will add pytest as well.
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.
Added here- PR to add pytest
Please review.
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
fc06ca3 to
901d293
Compare
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
| try: | ||
| # 4. Execute the actual export | ||
| onnx_path = func(self, *args, **kwargs) | ||
|
|
||
| # 5. Save export metadata | ||
| _save_export_metadata(export_dir, filtered_hash_params) | ||
|
|
||
| return onnx_path | ||
|
|
||
| finally: | ||
| # 6. Always cleanup subfunctions if they were setup | ||
| if use_subfunctions: | ||
| _cleanup_onnx_subfunctions(self) |
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.
try/finally is not required. Let's not loop one try/except inside another.
| **kwargs, | ||
| ) | ||
|
|
||
| def export(self, export_dir: Optional[str] = None, use_onnx_subfunctions: bool = False) -> str: |
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.
is it possible to make this logic common for any diffusers model?
User only defines an ordered dictionary and uses the export method from base class?
user's job is to define a orderdict for modules and the get_onnx_config method for export params.
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.
With logic of having on more base class, this could be possible. In upcoming time will add support of QEffDiffusionPipeline as a base class, which will have all these logic common.
| """ | ||
| for module_name, module_obj in tqdm(self.modules.items(), desc="Exporting modules", unit="module"): | ||
| # Get ONNX export configuration for this module | ||
| example_inputs, dynamic_axes, output_names = module_obj.get_onnx_config() |
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.
name the method better you are not returning a config here.
| ) | ||
|
|
||
| # Initialize QAIC inference session if not already created | ||
| if self.text_encoder_2.qpc_session is None: |
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.
why are we keeping session in memory?
This will hold the card occupied unless we explicitly del this or program execution terminates
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.
We want to keep it in the memory for genertating multple images sequentially in loop and not load the qpc again and again after each image generation.
| from QEfficient.utils.logging_utils import logger | ||
|
|
||
|
|
||
| def calculate_compressed_latent_dimension(height: int, width: int, vae_scale_factor: int) -> int: |
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.
is this method common to all diffusion models?
Support for Diffusers Architecture in Efficient Transformers
Overview
This pull request introduces Diffusers architecture support to the Efficient Transformers framework, enabling seamless integration of diffusion models.
Key Highlights
parallel_compile