Skip to content

Inkling 2 merged save: read and write the config and index as utf-8 - #19135

Merged
danielhanchen merged 1 commit into
mainfrom
ci/inkling2-save-utf8
Nov 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/inkling2-save-utf8

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

tests/test_runtime_text_encoding.py::test_shipping_code_names_an_encoding is red on main in Repo tests (CPU, rest), for example on #19122 and #19127:

4 text read/write call sites in shipping code let the operator's locale decide the encoding
  'unsloth/models/inkling2.py:364: open()'
  'unsloth/models/inkling2.py:532: open()'
  'unsloth/models/inkling2.py:537: open()'
  'unsloth/models/inkling2.py:545: open()'

Cause

The guard is right; the new code is wrong.

#19016 (Inkling 2 merged 16-bit save and GGUF export) added four text-mode open() calls with no encoding:

  • reading model.safetensors.index.json (index_path);
  • writing the merged index;
  • reading config.json;
  • writing config.json.

On Windows, Python uses the locale code page there. A config or index with a non-ASCII byte then fails to load, or is written in a codec the next reader does not expect. The guard has been in the repo since October; the lines all come from c69ffd79be.

Fix

Pass encoding = "utf-8" on all four calls in unsloth/models/inkling2.py. Nothing else changes: the JSON written is the same on a UTF-8 host.

Verification

  • tests/test_runtime_text_encoding.py: 9 passed (main: 1 failed, listing exactly these four sites).
  • tests/test_inkling2_support.py on transformers 5.24.0, including the merged-save tests: 42 passed.

test_shipping_code_names_an_encoding is red on main in the CPU rest
shard: #19016 opened config.json and model.safetensors.index.json in text
mode without an encoding, so on a non-UTF-8 Windows locale a config with
a non-ASCII byte fails to load or is written in the locale's codec. Pass
encoding = "utf-8" on all four calls.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T19:19:29.381120Z 29b62db Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 29b62dba8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

1 participant