Skip to content

Read the dtype from text_config in convert_ggml_to_int8.py - #2946

Merged
kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/ggml-int8-text-config-dtype
Oct 22, 2026
Merged

kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/ggml-int8-text-config-dtype

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Bug fix

convert_ggml_to_int8.py (#2903) read the scale dtype from the top-level dtype / torch_dtype of config.json. Multimodal configs such as GLM-5.3-Flash's keep it only in text_config, so converting a GGML export of GLM-5.3-Flash failed with KeyError: 'torch_dtype'. The converter now falls back to text_config.

Usage

Unchanged:

python convert_ggml_to_int8.py <ggml_dir> <int8_dir>

Testing

  • New test_dtype_is_read_from_text_config in tests/examples/hf_ptq/test_convert_ggml_to_int8.py moves the tiny export's dtype into text_config and converts it. It fails on main with KeyError: 'torch_dtype' and passes with the fix. All 4 tests in the file pass locally (the new one runs in 0.2 s).
  • End to end with this patch: converted a GLM-5.3-Flash IQ2_S GGML export (122 GB → 350 GB INT8, 5.5 min) and served it on vLLM 0.31 at TP4 on GB300. Per-token NLL on GPQA and AA-LCR responses matches the BF16 fake-quant export within 0.0013 nats in every length bin.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: ✅
  • Did you update Changelog?: N/A (the converter is unreleased)
  • Did you get Claude approval on this PR?: ❌

Additional Information

Follow-up to #2903.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Int8 conversion now correctly handles exported models whose data type is specified within their text configuration, preserving the appropriate precision for converted weight scales. This prevents conversion from failing when the data type is not provided at the top level.

Multimodal configs such as GLM-5.3-Flash's keep dtype only in text_config,
so the converter failed with KeyError: 'torch_dtype'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97
kevalmorabia97 requested review from a team as code owners October 22, 2026 19:42
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between db4dc7a and abf9363.

📒 Files selected for processing: 2
  • examples/hf_ptq/convert_ggml_to_int8.py
  • tests/examples/hf_ptq/test_convert_ggml_to_int8.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📝 Walkthrough

The converter now checks dtype fields in text_config after top-level dtype fields when selecting the scale dtype. A new test verifies conversion when the dtype exists only in text_config.

Changes: GGML int8 dtype fallback

Layer / File(s) Summary
Scale dtype selection and conversion test
examples/hf_ptq/convert_ggml_to_int8.py, tests/examples/hf_ptq/test_convert_ggml_to_int8.py
The converter checks top-level dtype and torch_dtype, then text_config.dtype and text_config.torch_dtype. The test verifies that an export with dtype only in text_config converts its weight-scale tensor to bfloat16.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: cjluo-nv

Merge Risk: ⚪ Minimal · up to abf93

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: reading the dtype from text_config in convert_ggml_to_int8.py.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns Passed The pull request changes only examples/hf_ptq/convert_ggml_to_int8.py and its test. The added code contains no torch.load(..., weights_only=False), pickle-enabled NumPy loading, hardcoded `trust_r…
Full details: Security Anti-Patterns

Explanation

The pull request changes only examples/hf_ptq/convert_ggml_to_int8.py and its test. The added code contains no torch.load(..., weights_only=False), pickle-enabled NumPy loading, hardcoded trust_remote_code=True, eval, exec, or # nosec. It adds no dependency-file changes. No listed security anti-pattern is introduced.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@meenchen meenchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bot review (gpt-6.1-sol) — DM the bot to share feedback.

Approve: the fallback preserves top-level dtype precedence and fixes text-only dtype lookup, with a regression test checking the converted scale precision.

No action needed.

@kevalmorabia97
kevalmorabia97 enabled auto-merge (squash) October 22, 2026 19:50
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.67%. Comparing base (db4dc7a) to head (abf9363).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2946   +/-   ##
=======================================
  Coverage   79.67%   79.67%           
=======================================
  Files         659      659           
  Lines       74466    74466           
=======================================
  Hits        59331    59331           
  Misses      15135    15135           
Flag Coverage Δ
examples-gpt-oss 13.48% <ø> (-0.07%) ⬇️
examples-hf_ptq 23.43% <ø> (+<0.01%) ⬆️
examples-llm_distill 13.56% <ø> (-0.07%) ⬇️
examples-llm_eval 17.22% <ø> (-0.03%) ⬇️
examples-llm_qat 17.43% <ø> (-0.10%) ⬇️
examples-llm_sparsity 16.81% <ø> (-0.04%) ⬇️
examples-specdec_bench 13.26% <ø> (-0.06%) ⬇️
examples-speculative_decoding 17.48% <ø> (-0.08%) ⬇️
examples-vllm_serve 17.44% <ø> (-0.04%) ⬇️
unit 61.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kevalmorabia97
kevalmorabia97 merged commit 55b4fd9 into main Oct 22, 2026
41 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/ggml-int8-text-config-dtype branch October 22, 2026 20:13
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-22 20:14 UTC

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.

2 participants