More...
Classes
Attributes
Detailed Description
SGFP4 wire-format constants — single source of truth.
Every magic number used by the SGFP4 exporter and reference decoder is
named here exactly once, mirroring the SuperGenius coding standard's rule
against unnamed constants (std. §4.5). Names follow the Python/PEP 8
UPPER_CASE convention, which plays the role that k-prefixed compile-time
constants play in the C++ standard.
All values are normative, taken from "SGFP4: Adaptive Dual-Mode
Macroblock Quantization with GPU-Friendly Unpacking and Verifiable
Decode Semantics" (arXiv v2), sections 3.2, 4.2, 4.3, 6.1, 6.2.
Attributes Documentation
variable MACROBLOCK_SIZE
int MACROBLOCK_SIZE = 64;
variable PAYLOAD_BYTES
int PAYLOAD_BYTES = 2048;
variable PAYLOAD_U32
int PAYLOAD_U32 = PAYLOAD_BYTES // 4;
variable ALIGNMENT
variable UINT32_BYTES
variable UINT32_BITS
variable FP4_BITS_PER_CODE
int FP4_BITS_PER_CODE = 4;
variable FP4_CODES_PER_WORD
int FP4_CODES_PER_WORD = UINT32_BITS // FP4_BITS_PER_CODE;
variable FP4_NIBBLE_MASK
int FP4_NIBBLE_MASK = 0xF;
variable FP4_SIGN_THRESHOLD
int FP4_SIGN_THRESHOLD = 8;
variable FP4_CODE_BIAS
variable T158_BITS_PER_CODE
int T158_BITS_PER_CODE = 2;
variable T158_CODES_PER_WORD
int T158_CODES_PER_WORD = UINT32_BITS // T158_BITS_PER_CODE;
variable T158_SYMBOL_MASK
int T158_SYMBOL_MASK = 0x3;
variable T158_SYMBOL_POS
variable T158_SYMBOL_NEG
variable T158_RESERVED_WORD_START
int T158_RESERVED_WORD_START = 256;
variable OFFSET_FLAG_MASK
int OFFSET_FLAG_MASK = 0xF;
variable OFFSET_MODE_MASK
int OFFSET_MODE_MASK = 0x1;
variable OFFSET_RESERVED_MASK
int OFFSET_RESERVED_MASK = 0xC;
variable HALF_SHIFT
variable HALF_MASK
variable FP16_MAX
float FP16_MAX = 65504.0;
variable LEAF_FLAG_MASK
int LEAF_FLAG_MASK = 0xF;
variable LEAF_MODE_MASK
int LEAF_MODE_MASK = 0x1;
variable LEAF_RESERVED_MASK
int LEAF_RESERVED_MASK = 0xE;
variable BETA_TRUNC_MASK
int BETA_TRUNC_MASK = 0xFFF0;
int HEADER_CLEAR_FLAGS_MASK = 0xFFFFFFF0;
variable SGFP4_MAGIC
str SGFP4_MAGIC = b"SGF4";
variable SGFP4_VERSION_V2
int SGFP4_VERSION_V2 = 0x02;
int V2_FIXED_HEADER_BYTES = 16;
int V2_HEADER_PAD_BYTES = 7;
int SB_HEADER_LAYOUT_MASK = 0x7;
int SB_HEADER_RESERVED_SHIFT = 3;
variable SPLIT_MAP_BYTES
int SPLIT_MAP_BYTES = 12;
variable SPLIT_MAP_WORDS
variable SPLIT_MAP_MAX_BITS
int SPLIT_MAP_MAX_BITS = 85;
variable MIN_LEAF_SIZE
Updated on 2026-07-25 at 22:56:57 +0000