Skip to content

Add model_free_ptq example for glm 4.6 block fp8#2343

Open
mgoin wants to merge 2 commits intomainfrom
glm-4.6-block-fp8-example
Open

Add model_free_ptq example for glm 4.6 block fp8#2343
mgoin wants to merge 2 commits intomainfrom
glm-4.6-block-fp8-example

Conversation

@mgoin
Copy link
Member

@mgoin mgoin commented Feb 10, 2026

SUMMARY:

Adapt the Kimi K2 example for GLM 4.6

TEST PLAN:

python glm_4.6_fp8_block.py 
2026-02-10T17:33:24.378844+0000 | model_free_ptq | INFO - Copying .gitattributes GLM-4.6-FP8-BLOCK/.gitattributes
2026-02-10T17:33:24.379164+0000 | model_free_ptq | INFO - Copying README.md GLM-4.6-FP8-BLOCK/README.md
2026-02-10T17:33:24.379269+0000 | model_free_ptq | INFO - Copying chat_template.jinja GLM-4.6-FP8-BLOCK/chat_template.jinja
2026-02-10T17:33:24.379335+0000 | model_free_ptq | INFO - Copying config.json GLM-4.6-FP8-BLOCK/config.json
2026-02-10T17:33:24.379392+0000 | model_free_ptq | INFO - Copying generation_config.json GLM-4.6-FP8-BLOCK/generation_config.json
2026-02-10T17:33:24.379574+0000 | model_free_ptq | INFO - Copying model.safetensors.index.json GLM-4.6-FP8-BLOCK/model.safetensors.index.json
2026-02-10T17:33:24.381495+0000 | model_free_ptq | INFO - Copying tokenizer.json GLM-4.6-FP8-BLOCK/tokenizer.json
2026-02-10T17:33:24.388708+0000 | model_free_ptq | INFO - Copying tokenizer_config.json GLM-4.6-FP8-BLOCK/tokenizer_config.json
Quantizing: 100%|███████████████████████████████████████████████████████████████████████████████████| 93/93 [04:37<00:00,  2.98s/it]

Checkpoint uploaded to: https://huggingface.co/mgoin/GLM-4.6-FP8-BLOCK

Signed-off-by: mgoin <mgoin64@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mgoin, 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 example script that showcases the application of model-free post-training quantization (PTQ) using the FP8-Block scheme to the GLM-4.6 model. The primary goal is to provide a clear demonstration of how to quantize this specific model, including the configuration for ignoring certain layers, thereby enabling users to achieve efficient model compression.

Highlights

  • New Example Script: Introduced glm_4.6_fp8_block.py to demonstrate model-free post-training quantization (PTQ) for the GLM-4.6 model.
  • FP8-Block Quantization: The example applies the FP8-Block quantization scheme to the zai-org/GLM-4.6 model, saving the quantized model using compressed-tensors.
  • Selective Quantization: Configured the quantization process to ignore specific layers such as gate, lm_head, and model.embed_tokens for improved performance or quality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • examples/model_free_ptq/glm_4.6_fp8_block.py
    • Added a new script to demonstrate FP8-Block quantization for the GLM-4.6 model.
    • Configured model_free_ptq to quantize zai-org/GLM-4.6 and save the output.
    • Specified layers to be ignored during the quantization process.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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.

@github-actions
Copy link

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

@mergify mergify bot added the documentation Improvements or additions to documentation label Feb 10, 2026
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 a new example script for model-free post-training quantization on the GLM-4.6 model using an FP8 block scheme. The changes are clear and follow the pattern of existing examples. I've suggested a small improvement to make the save directory path construction more robust and readable by using os.path.basename.

Comment on lines +1 to +2
from llmcompressor import model_free_ptq

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To support using os.path.basename for parsing the model path, please import the os module. It's good practice to group standard library imports first, followed by third-party imports.

Suggested change
from llmcompressor import model_free_ptq
import os
from llmcompressor import model_free_ptq

from llmcompressor import model_free_ptq

MODEL_ID = "zai-org/GLM-4.6"
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-BLOCK"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and robustness when parsing the model path, it's recommended to use os.path.basename to extract the model name. This avoids manual string splitting and is generally safer for handling paths.

Suggested change
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-BLOCK"
SAVE_DIR = os.path.basename(MODEL_ID.rstrip("/")) + "-FP8-BLOCK"

@dsikka
Copy link
Collaborator

dsikka commented Feb 10, 2026

FYI - we have an example already https://github.com/vllm-project/llm-compressor/blob/main/examples/quantizing_moe/glm4_7_example.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants