Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ignition/preparation/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def _parse_json(raw: bytes, source: str) -> dict:
return value


_DTYPE_BYTES = {"BF16": 2, "F32": 4, "F8_E4M3": 1, "F8_E8M0": 1,
"I8": 1, "U8": 1, "U16": 2, "I32": 4, "U32": 4, "I64": 8}
_DTYPE_BYTES = {"BF16": 2, "F16": 2, "F32": 4, "F8_E4M3": 1, "F8_E8M0": 1,
"I8": 1, "U8": 1, "I16": 2, "U16": 2, "I32": 4, "U32": 4, "I64": 8}


def _read_header(path: Path, shard: str) -> tuple[ShardMetadata, dict[str, TensorMetadata]]:
Expand Down
27 changes: 27 additions & 0 deletions tests/preparation/test_checkpoint_dtypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributors
# SPDX-License-Identifier: Apache-2.0

import json
import struct

from ignition.preparation.checkpoint import _read_header


def test_read_header_accepts_f16_and_i16(tmp_path):
"""EXL3 and FP16 safetensors checkpoints store F16 scales/Hadamards and I16 trellis weights."""
header = {
"layer.suh": {"dtype": "F16", "shape": [8], "data_offsets": [0, 16]},
"layer.trellis": {"dtype": "I16", "shape": [4, 4], "data_offsets": [16, 48]},
}
raw_header = json.dumps(header).encode("utf-8")
shard = tmp_path / "model.safetensors"
shard.write_bytes(struct.pack("<Q", len(raw_header)) + raw_header + b"\x00" * 48)

meta, tensors = _read_header(shard, "model.safetensors")
assert meta.path == "model.safetensors"
assert meta.tensor_count == 2
assert tensors["layer.suh"].dtype == "F16"
assert tensors["layer.suh"].nbytes == 16
assert tensors["layer.trellis"].dtype == "I16"
assert tensors["layer.trellis"].nbytes == 32