Skip to content

Conversation

@JyotinderSingh
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @JyotinderSingh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds a detailed guide to Keras's documentation, focusing on 8-bit integer quantization (INT8). The guide aims to educate users on how to leverage INT8 quantization to reduce model memory footprint and potentially speed up inference, while understanding the associated trade-offs. It provides clear explanations and practical code examples to help users implement post-training quantization effectively across various Keras models, including those from KerasHub.

Highlights

  • New Documentation: Introduced a comprehensive guide on 8-bit Integer Quantization (INT8) in Keras, covering its principles, benefits, and practical application.
  • Practical Examples: The guide includes code examples demonstrating how to quantize a minimal functional model, save and reload quantized models, and apply INT8 quantization to KerasHub models like Gemma3CausalLM, showcasing storage savings.
  • Multi-format Availability: The new guide is provided in Python script (.py), Jupyter Notebook (.ipynb), and rendered Markdown (.md) formats for broad accessibility and ease of use.
  • Guide Index Update: The main guides_master.py script has been updated to include the new 8-bit integer quantization guide in the official list of Keras guides.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @JyotinderSingh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new, detailed guide on 8-bit integer quantization (INT8) for Keras. The documentation provides a thorough explanation of what INT8 quantization is, how it works, its benefits, and potential trade-offs. It also offers practical code examples for quantizing custom Keras models and KerasHub models, demonstrating how to save and reload them, and showcasing the resulting memory footprint reduction. This addition aims to equip users with the knowledge and tools to optimize their Keras models for reduced size and improved inference performance.

Highlights

  • New Documentation Added: A comprehensive guide on 8-bit Integer Quantization (INT8) in Keras has been added, detailing its principles, benefits, and practical application.
  • Practical Quantization Examples: The guide includes step-by-step examples demonstrating how to quantize minimal functional Keras models and KerasHub models, along with methods for saving, reloading, and evaluating quantized models.
  • Storage Savings Demonstrated: The documentation illustrates the significant storage reduction achieved through INT8 quantization, using a Gemma3CausalLM model as an example.
  • Guide Integration: The new INT8 quantization guide has been integrated into the main Keras documentation structure, making it accessible via the guides master list.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds comprehensive documentation for 8-bit integer quantization in Keras. The guide is well-structured, covering the concept, a minimal example, saving/loading, and application to a KerasHub model. The code examples are clear and effectively demonstrate the quantization process and its benefits. I've added a few minor suggestions to improve consistency and clarity in the documentation.

Copy link
Contributor

@hertschuh hertschuh 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 PR!

Some small comments.

```
Full-precision output: Keras is a deep learning library for Python. It is a high-level API for neural networks. It is a Python library for deep learning

Quantized output: Keras is a deep learning library for Python. It is a high-level API for neural networks. It is a Python library for deep learning
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... is it actually really working :) How far do you have to go to see a difference?

Copy link
Collaborator Author

@JyotinderSingh JyotinderSingh Oct 15, 2025

Choose a reason for hiding this comment

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

Great catch! I looked a little deeper and turns out the graph wasn't being reset, which is why it was giving different outputs on reload. I've opened a fix for this in the following PR: keras-team/keras-hub#2436

I installed that change locally and regenerated the outputs for these docs as well. The outputs are now a little different after quantization, as expected.

@hertschuh hertschuh merged commit ee63423 into keras-team:master Oct 15, 2025
3 checks passed
@JyotinderSingh JyotinderSingh deleted the quantization-docs branch October 15, 2025 19:41
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.

3 participants