Skip to content

iter_weight_files silently loads 0 weights when the index points shards into a subdirectory #818

Closed

Description

@chrisqianz

Before you start

  • I have read the FAQ and my problem is not answered there.
  • I have read the Roadmap and this is not already planned there.
  • I have searched existing issues and found no duplicate.
  • I am on the latest release, or on a freshly rebuilt main when building from source.

What happened

iter_weight_files() (python/freetoken/models/loader.py) only globs *.safetensors at the top level of the model folder. Checkpoints that keep a root model.safetensors.index.json whose weight_map points the shards into a subdirectory (e.g. tensors/model-00000-of-00021.safetensors) are silently loaded as zero weight files: the dense-weight scan finishes instantly (0it), and the run dies much later with a confusing unrelated error instead of a clear message.

nvidia/Qwen3.8-Flash-Next-FP4-Local ships exactly this layout (tensors/ subdirectory + root index).

Proposed fix (in our fork, tested): when the top-level glob comes back empty, resolve the shard list from the root index's weight_map (sorted, deduplicated, relative to the folder) before giving up.

How did you install FreeToken

build from source

FreeToken version

0.2.0

OS

Ubuntu

OS details

22.04.5 LTS

GPU and driver

RTX 5090 D 32GB, driver 595.84

CPU and system RAM

Intel Core Ultra 7 265K, 125GB

Checkpoint

nvidia/Qwen3.8-Flash-Next-FP4-Local

Command

ft serve --model ~/models/NVIDIA-Qwen3.8-Flash-Next-FP4-Local/ --moe-strategy offload --moe-cache-auto

Full log

Loading weights: 0it [00:00, ?it/s]
... (much later, during model construction)
KeyError: 'model.layers.0.linear_attn.in_proj_qkvz.weight_scale_inv'

(The KeyError is a separate gap of this checkpoint, tracked in the FP4-Local issue; it is listed only to show where the silent zero-weight scan eventually surfaces.)

Anything else

Reproduction without a GPU: point iter_weight_files() at any folder that contains only model.safetensors.index.json with weight_map values like tensors/model-00000-of-00001.safetensors plus that subdirectory; the function returns []. Unit tests for the fix are in tests/models/test_models_loader.py of the follow-up PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions