Skip to content

fix(torch_bin): read checkpoints that wrap the state dict and hold lists - #1174

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/torch-bin-wrapped-state-dict
Nov 2, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/torch-bin-wrapped-state-dict

Conversation

@KKTTSPJ

@KKTTSPJ KKTTSPJ commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

audiocpp_gguf cannot read the Irodori-TTS codec checkpoint weights.pth from
Aratako/Semantic-DACVAE-Japanese-32dim:

error: failed to open tensor source ...\weights.pth: torch .bin pickle uses an unsupported opcode: 93

The file is a training checkpoint saved as {"state_dict": OrderedDict, "metadata": {...}}, and its
metadata holds two lists. The reader in src/framework/assets/torch_bin.cpp has no list opcodes
(93 is EMPTY_LIST), and without them it would then take the outer dict as the state dict. Today the
.pth has to go through tests/irodori_tts/convert_dacvae_pth_to_safetensors.py, which needs PyTorch.

This PR:

  • adds EMPTY_LIST, APPEND and APPENDS (a List value, built like the existing tuples and dicts);
  • when the top-level dict has a dict under "state_dict", reads the tensors from that dict, which is
    what convert_dacvae_pth_to_safetensors.py does (payload["state_dict"]).

Checkpoints that are a plain state dict, or a single tensor, are read as before.

Checks

  • New case in tests/unittests/test_torch_bin_storage_offset.cpp: a checkpoint shaped like that one
    (wrapped state dict with two views of one storage, metadata with an APPENDS list and an APPEND
    list) yields exactly its 2 tensors with the values torch.load returns. The existing cases still pass.

  • The real file: audiocpp_gguf --type orig from weights.pth and from the safetensors that
    convert_dacvae_pth_to_safetensors.py writes:

    Tensors weights.pth (this PR) weights.safetensors
    Count 317 317
    Name, shape, type and data identical identical
  • Irodori-TTS v4 Large Q4_K converted with --input codec_weights=weights.pth, compared with the same
    conversion from the safetensors: all 1708 tensors (model and codec) are identical, and the model
    loads and generates speech.

  • Without the change, the new unit test fails with the same unsupported opcode: 93 error.

Why

This lets a Windows user without Python build the Irodori-TTS v4 Large GGUF, which is not published
(the Gemma Terms of Use apply to its text encoder), from the two original Hugging Face repositories
with audiocpp_gguf alone.

🤖 Generated with Claude Code

Semantic-DACVAE's weights.pth (the Irodori-TTS codec) is saved as
{"state_dict": OrderedDict, "metadata": {...}}, and its metadata holds two
lists. The reader stopped at EMPTY_LIST and would then have treated the
outer dict as the state dict. It now builds lists (EMPTY_LIST, APPEND,
APPENDS) and, when the top-level dict has a dict under "state_dict", reads
the tensors from it, as tests/irodori_tts/convert_dacvae_pth_to_safetensors.py
does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@0xShug0

0xShug0 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Will test tomorrow.

@0xShug0
0xShug0 merged commit 06c1373 into 0xShug0:main Nov 2, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

@KKTTSPJ Merged. Thanks!

@KKTTSPJ
KKTTSPJ deleted the pr/torch-bin-wrapped-state-dict branch November 3, 2026 00:47
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