Skip to content

docs: update Flux tutorial as a more general image generation tutorial#127

Merged
davidberenstein1957 merged 16 commits intomainfrom
docs/120-doc-update-end-to-end-tutorial-of-using-flux
Jun 24, 2025
Merged

docs: update Flux tutorial as a more general image generation tutorial#127
davidberenstein1957 merged 16 commits intomainfrom
docs/120-doc-update-end-to-end-tutorial-of-using-flux

Conversation

@davidberenstein1957
Copy link
Copy Markdown
Member

  • Deleted the flux_small.ipynb tutorial as it is no longer relevant.
  • Introduced image_generation.ipynb tutorial to demonstrate optimizing and evaluating image generation models using the pruna package, including details on optimization algorithms and evaluation metrics.
  • Updated the tutorial index to reflect these changes.

Description

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

@davidberenstein1957 davidberenstein1957 linked an issue May 16, 2025 that may be closed by this pull request
@davidberenstein1957 davidberenstein1957 changed the title docs: remove outdated Flux tutorial and add new image generation tutorial docs: update Flux tutorial as a more general image generation tutorial May 16, 2025
@davidberenstein1957 davidberenstein1957 removed the request for review from nifleisch May 20, 2025 13:25
@nifleisch nifleisch force-pushed the docs/120-doc-update-end-to-end-tutorial-of-using-flux branch from 5b9d1de to 79e5544 Compare May 21, 2025 10:14
@davidberenstein1957 davidberenstein1957 marked this pull request as ready for review May 22, 2025 09:58
@davidberenstein1957
Copy link
Copy Markdown
Member Author

@nifleisch, that looks good! I would leave the printed statements in the tutorials so people can actually read the output and understand better what is happening.

@nifleisch
Copy link
Copy Markdown
Collaborator

@nifleisch, that looks good! I would leave the printed statements in the tutorials so people can actually read the output and understand better what is happening.

I see your point. This way, users could follow the tutorial without running it on their own machines. I just spoke with Johanna, and we’re now clearing the outputs of all tutorial notebooks by default. So even if outputs remain in the tutorial, they won’t be included in the documentation.

@nifleisch nifleisch requested review from nifleisch and sharpenb and removed request for nifleisch May 26, 2025 14:22
@davidberenstein1957
Copy link
Copy Markdown
Member Author

That's good to know. Let's remove the output clearing, then. I think the output helps understanding, so it is fine to keep them, but feel free to verify with @johannaSommer since we initially decided to remove them.

@nifleisch
Copy link
Copy Markdown
Collaborator

That's good to know. Let's remove the output clearing, then. I think the output helps understanding, so it is fine to keep them, but feel free to verify with @johannaSommer since we initially decided to remove them.

Good point. I just checked with @johannaSommer, and she’s on board with this as well. Will add them back to the tutorial.

@nifleisch nifleisch force-pushed the docs/120-doc-update-end-to-end-tutorial-of-using-flux branch from fe9f419 to ed412f9 Compare May 28, 2025 11:29
Comment thread docs/tutorials/index.rst Outdated
Copy link
Copy Markdown
Member

@sharpenb sharpenb left a comment

Choose a reason for hiding this comment

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

THanks for the tutorial. Here are my comments on the ntoebook :)

  • I like the idea of a tutorial card at the top but it could be made cleaner (e.g. in a table?). I would also not mention the distinciton between metrics. The term "base/statefull" is more a implementation relevant rather than a user relevant. I would also remove the libraries from there.
  • Do we need to show how ot install pruna? We do not do this in the other tutorialx and have a doc page for it.
  • We could merge the set device cell with theload model cell
  • Could we have "1., 2. 3." in subtitles like in other tutorials?
  • We could mention how long is the smashing for this smash config so that peopl know what to expect.
  • Define all metrics in a single list.
  • first_results - > base_model_results (and smashed_model_results.
  • Could we print all metrics in a nice way in a single cell? i.e. merge cell 9. 10. 11.?
  • Is this tutorial only with SD2.1? Make sense since it is quick to run but also unclear since a bit outdated.

@davidberenstein1957 davidberenstein1957 force-pushed the docs/120-doc-update-end-to-end-tutorial-of-using-flux branch from 7137812 to c6f5b01 Compare June 6, 2025 06:17
Copy link
Copy Markdown
Member

@sharpenb sharpenb left a comment

Choose a reason for hiding this comment

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

Thanks for the udpate! Here are still some left comments:

  • Let's remove the library row from the table
  • Do we need to show how ot install pruna? We do not do this in the other tutorialx and have a doc page for it. I would suggest o redicrect to the installation page if people need.
  • We could merge the "set device" cell with the "load model" cell
  • Let's have numbers for sections like in other tutorials. Could we have "1., 2. 3." in subtitles like in other tutorials? :)
  • I feel that we could find a nicer way to print the metrics e.g. the python print a small table with metrics before/after and relative difference in 3 columns.
  • I feel that a small intro at the start of the tutorial to explain what we try to do and that it can work with other model than SD2.1 would be nice to give context
  • We should also update the title of the notebook itself for "Compress and evaluate"

@davidberenstein1957
Copy link
Copy Markdown
Member Author

davidberenstein1957 commented Jun 6, 2025

Hi @sharpenb, I think I once typed a response already but did not post it. Underneath are some of my reasons for the choices.

Thanks for the udpate! Here are still some left comments:

  • Let's remove the library row from the table

sure

  • Do we need to show how ot install pruna? We do not do this in the other tutorialx and have a doc page for it. I would suggest o redicrect to the installation page if people need.

Yes, but if people want to run this as a standalone notebook, let's say in Jupyter or Google Colab or whatever other IDE, we need to install Pruna.

  • We could merge the "set device" cell with the "load model" cell

I kept this separate as it is a bit more explicit and the device is used in multiple places throughout the notebook

  • Let's have numbers for sections like in other tutorials. Could we have "1., 2. 3." in subtitles like in other tutorials? :)

I left this out because I don't feel it adds value, and it makes it more challenging to maintain as it is a manual process.

  • I feel that we could find a nicer way to print the metrics, e.g. the Python print a small table with metrics before/after and relative difference in 3 columns.

I agree it could be nicer, but do you feel this is worth spending 30 minutes on (re-running the notebook evals and such)?

  • I feel that a small intro at the start of the tutorial to explain what we try to do and that it can work with other models than SD2.1 would be nice to give context

If you feel it is important to use a more modern model, I am happy to set that up, but I think it makes it
less approachable to run end-to-end. Perhaps we can use stabilityai/stable-diffusion-3.5-medium or Efficient-Large-Model/SANA1.5_4.8B_1024px_diffusers?

  • We should also update the title of the notebook itself for "Compress and evaluate"

I think it is better to keep it more general, although the specific techniques we apply focus on compression.

@davidberenstein1957 davidberenstein1957 requested review from SaboniAmine, nifleisch and sharpenb and removed request for nifleisch June 6, 2025 15:57
@davidberenstein1957
Copy link
Copy Markdown
Member Author

@nifleisch @sharpenb @SaboniAmine could you review this PR, I think it would be nice to merge before the release.

…rial

- Deleted the `flux_small.ipynb` tutorial as it is no longer relevant.
- Introduced `image_generation.ipynb` tutorial to demonstrate optimizing and evaluating image generation models using the `pruna` package, including details on optimization algorithms and evaluation metrics.
- Updated the tutorial index to reflect these changes.
…setup instructions

- Added installation instructions for the `pruna` package.
- Included a section on setting the device for optimization, ensuring users can utilize the best available hardware.
davidberenstein1957 and others added 12 commits June 12, 2025 15:37
…ation details

- Changed language ID in the notebook metadata for better compatibility.
- Added sections for loading the model and tokenizer, including a specific example using the CompVis/stable-diffusion-v1-4 model.
- Included code snippets for model optimization and evaluation, enhancing the tutorial's comprehensiveness.
- Updated tutorial index to reflect changes in the image generation process.
…ts and output enhancements

- Updated execution counts for several code cells to ensure proper sequencing.
- Modified output messages for improved clarity and accuracy during model evaluation.
- Adjusted configuration parameters for the `hqq_diffusers` quantizer to optimize performance.
- Added new image outputs to enhance the visual representation of results.
- Reformatted the introduction section into a table for better readability.
- Enhanced explanations regarding model optimization and evaluation metrics.
- Updated code snippets for consistency and improved execution flow.
- Removed unnecessary output cells to streamline the tutorial experience.
…ents

- Updated model reference to [segmind/Segmind-Vega] for improved performance.
- Revised evaluation metrics to include `throughput` and `total time`.
- Adjusted execution counts for code cells to maintain proper flow.
- Enhanced output display for clearer metric comparisons during evaluation.
- Changed model saving and loading references from "stable-diffusion-2-1-smashed" to "segmind-vega-smashed" for consistency with recent updates.
- Updated corresponding comments to reflect the new model name.
- Clarified the output quality discussion by removing redundant phrasing regarding the CLIP score, enhancing the overall readability of the section.
- Removed `elapsed_time` from the evaluation metrics to focus on key performance indicators.
- Cleared unnecessary output cells to enhance the tutorial's clarity and flow.
- Changed the tutorial title from "Optimize and Evaluate Image Generation Models" to "Compress and Evaluate Image Generation Models" for clarity.
- Added numbered sections to improve navigation and organization within the tutorial.
- Removed unnecessary metadata from code cells to streamline the content.
@davidberenstein1957 davidberenstein1957 force-pushed the docs/120-doc-update-end-to-end-tutorial-of-using-flux branch from 2fff38d to 94302a3 Compare June 12, 2025 13:38
Copy link
Copy Markdown
Member

@sharpenb sharpenb left a comment

Choose a reason for hiding this comment

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

Thanks for the update! A last update before merging would be to indicate the units with througput (samples/s), latency (s/samples) and Base Model, Compressed Model, Relative Difference in the row/columns names to be complete :)

- Replaced `TotalTimeMetric` with `LatencyMetric` to better reflect performance evaluation.
- Updated markdown table headers and content for clarity, changing "Original" and "Optimized" to "Base Model" and "Compressed Model" respectively.
- Added units to the markdown table for improved understanding of metric values.
@davidberenstein1957
Copy link
Copy Markdown
Member Author

hi @sharpenb I resolved your comments.

Copy link
Copy Markdown
Member

@sharpenb sharpenb left a comment

Choose a reason for hiding this comment

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

Looks good! Similar to the LLM docs, it would be great to put latency (see here).

Copy link
Copy Markdown
Collaborator

@nifleisch nifleisch left a comment

Choose a reason for hiding this comment

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

I love the new tutorial, it feels very complete. Through it I learned about the amazing segmind/Segmind-Vega model that we probably should use more often for tutorials as it looks stunning!
Two minor things:

  • At the beginning of the tutorial in section 1 there is a typo "howwever"
  • In the last part you use both the throughput and the latency metric, which felt a bit redundant to me because throuput ~ 1 / latency. Instead I would have preferred a fidelity measure. (feel free to ignore this suggestion)

@davidberenstein1957 davidberenstein1957 merged commit 0d6e97d into main Jun 24, 2025
6 checks passed
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.

[DOC] Update end to end tutorial of using flux

3 participants