quantize::fp4_exporter¶
Classes¶
| Name | |
|---|---|
| class | quantize::fp4_exporter::FP4Exporter |
Attributes¶
Detailed Description¶
FP4 Ultra binary exporter — SGFP4 v1 (fixed 64x64) and v2 (adaptive quadtree).
Container layout v1: headers[B] | offsets[B] | codes_blob[B*2048]
Container layout v2: magic[4] | version[1] | num_superblocks[4] | pad[7] |
superblock_offsets[B] | superblock_data[0..B-1]
v1 (fixed, backward compatible):
- 64x64 macroblocks
- Fixed 2048-byte payload per block
- FP4_AFFINE (mode 0): 4-bit signed codes, 8 per uint32
- T158_AFFINE (mode 1): ternary as 2-bit symbols, 16 per uint32
v2 (adaptive, SGFP4 v2):
- Variable block sizes 4x4..64x64 selected by quadtree + Laplacian error
- Layout enum per superblock (0-5) identifies block structure
- Variable payloads scale with block area
- Dual-mode per-block: FP4_AFFINE vs T158_AFFINE via error comparison
- 4-byte magic header (b'SGF4') + version byte (0x02) for format detection
- Superblock offset table for paging
- 16-byte payload alignment per block
- Manifest generation via ManifestBuilder
Attributes Documentation¶
variable MODE_FP4_AFFINE¶
variable MODE_T158_AFFINE¶
variable LAYOUT_UNIFORM_64¶
variable LAYOUT_UNIFORM_32¶
variable LAYOUT_UNIFORM_16¶
variable LAYOUT_UNIFORM_8¶
variable LAYOUT_MIXED¶
variable LAYOUT_FULL_4x4¶
variable DEFAULT_V2_THRESHOLDS¶
dict DEFAULT_V2_THRESHOLDS = {
64: {"max_mse": 0.01, "max_relative": 0.05},
32: {"max_mse": 0.005, "max_relative": 0.03},
16: {"max_mse": 0.002, "max_relative": 0.02},
8: {"max_mse": 0.001, "max_relative": 0.01},
4: {"max_mse": 0.0005, "max_relative": 0.005},
};
variable parser¶
parser = argparse.ArgumentParser(
description="Export specialist weights to FP4 Ultra format (v1 or v2)"
);
variable required¶
variable True¶
variable help¶
variable action¶
variable args¶
variable project_root¶
variable exporter¶
variable dummy_weights¶
variable output_dir¶
variable bin_path¶
variable stats¶
variable adaptive¶
variable manifest¶
dict manifest = {
"model_name": args.niche,
"niche": args.niche,
"base_model_ref": "",
"adapter_ref": "",
"quantization_params": {"format": "fp4_ultra"},
"encoder_version": "0.1.0",
"timestamp_utc": "",
};
variable f¶
variable indent¶
Updated on 2026-07-25 at 22:56:57 +0000