Float4
For conceptual model usage and type mapping, see:
- class pyrogue.Float4(bitSize)[source]
Model class for 4-bit E2M1 floating point numbers (NVIDIA Blackwell FP4).
- Parameters:
bitSize (
int) – Number of bits being represented. Must be 8 (stored in 1-byte word).args (Any)
kwargs (Any)
- Return type:
Any
Notes
Format: 1 sign bit, 2 exponent bits, 1 mantissa bit (E2M1). Bias = 1. No infinity representation. No NaN representation. All 16 bit patterns are finite values or zero. Only 8 distinct magnitudes: 0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0. Maximum representable value is 6.0. Stored in lower 4 bits of a uint8_t byte. Supported by NVIDIA Blackwell GPUs.
- toBytes(value)[source]
Convert float to 1-byte E2M1 encoding (4 active bits in uint8).
NaN and infinity inputs are clamped to max finite value (+/-6.0) since E2M1 has no NaN or infinity encodings.
- fromBytes(ba)[source]
Decode 1-byte E2M1 encoding to float.
All 16 bit patterns decode to finite values or zero (no NaN/Inf).