code wiki / (root) / nx_f32_cvt.nx

nx_f32_cvt.nx

buildroot/runtime/nx_f32_cvt.nx

11950 B304 linesdepth 3pulls 4 transitivereach 286 importersview sourcekind librarytopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_cvt.nx -- IEEE 754 binary32 conversions (bits-up). L4.5 brick that bridges the L1 fixed-point substrate (Q10/Q14) and the L2 f16 layer into L4 f32. All conversions are clean-room from the IEEE 754-2019 spec; no libm, no compiler-builtin lowerings. Operations in v1: nx_f16_to_f32(raw_f16) -> raw_f32 widening with subnormal- to-normal renormalization nx_i32_to_f32(value_i32) -> raw_f32 small-int (round-to- nearest-even for >24 bits) nx_q10_to_f32(value_q10) -> raw_f32 Q10 (* 1024) into f32 nx_q14_to_f32(value_q14) -> raw_f32 Q14 (* 16384) into f32 Composes with nx_f32_mul / nx_f32_add / nx_f32_sub / nx_f32_div / nx_f32_sqrt (all shipped previously in this L4 tower) to produce a real-model dequant pipeline emitting IEEE 754 outputs that can be bit-exact compared against ggml's reference dequant. Reference: IEEE 754-2019 binary16 / binary32 layouts; standard widening + signed-int-to-float algorithms. No code borrowed. genealogy_id: ieee754_2019_widening + signed_int_to_float_canonical lineage_id: substrate_f32_cvt_v1

dependencies 4 imports · 149 importers

nx_syscalls.nx nx_tier.nx nx_f16.nx nx_f32.nx nx_f32_cvt.nx _autograd_authored.nx _tensor_grad_authored.nx nx_autograd.nx nx_autograd_tensor.nx nx_batchscale_kat.nx nx_coco_oks.nx nx_coco_oks_gate.nx nx_conv_bwd_stride_gate.nx nx_embed_train.nx nx_exp_ab.nx

diagram shows first 10 each side; +0 more imports, +139 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nxnx_f16.nxnx_f32.nx

imported by: _autograd_authored.nx_tensor_grad_authored.nxnx_autograd.nxnx_autograd_tensor.nxnx_batchscale_kat.nxnx_coco_oks.nxnx_coco_oks_gate.nxnx_conv_bwd_stride_gate.nxnx_embed_train.nxnx_exp_ab.nxnx_exploop_test.nxnx_f16_kat.nxnx_f32_adaln.nxnx_f32_attention.nxnx_f32_bn_fold_gate.nxnx_f32_conv2d.nxnx_f32_conv2d_backward_fast_gate.nxnx_f32_conv2d_backward_gate.nxnx_f32_conv2d_fast_gate.nxnx_f32_conv2d_grouped_gate.nxnx_f32_conv_train_gate.nxnx_f32_conv_transpose2d_gate.nxnx_f32_cvt_test.nxnx_f32_dit_block_linear.nxnx_f32_dit_block_simd.nxnx_f32_dit_block_tiny.nxnx_f32_exp.nxnx_f32_exp_test.nxnx_f32_ffn_path_gate.nxnx_f32_gelu.nxnx_f32_gelu_gate.nxnx_f32_gqa_attention.nxnx_f32_groupnorm.nxnx_f32_image_to_bmp.nxnx_f32_layernorm.nxnx_f32_layernorm_lib_gate.nxnx_f32_linear_attention.nxnx_f32_linear_simd.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm_serve.nxnx_f32_log.nxnx_f32_log_test.nxnx_f32_lora_linear.nxnx_f32_maxpool2d_gate.nxnx_f32_parity.nxnx_f32_q4k_matmul.nxnx_f32_qwen_encoder.nxnx_f32_qwen_layer.nxnx_f32_rectflow_denoise.nxnx_f32_resblock.nxnx_f32_rmsnorm.nxnx_f32_rmsnorm_test.nxnx_f32_rope.nxnx_f32_rope_test.nxnx_f32_sampler.nxnx_f32_sincos.nxnx_f32_sincos_test.nxnx_f32_train_ops.nxnx_f32_upsample.nxnx_f32_upsample_bilinear.nxnx_f32_upsample_bilinear_gate.nxnx_f32_vae_decode_tiny.nxnx_f32prim_test.nxnx_f32x8_dot_bench.nxnx_f32x8_probe.nxnx_f32x8_range_gate.nxnx_fft_f32.nxnx_flashattn_scale.nxnx_gguf_load_f32.nxnx_hifigan_verify.nxnx_i8dot32_kat.nxnx_i8dot32a_kat.nxnx_i8dot_ab.nxnx_i8fma32_kat.nxnx_linear_attn_bench.nxnx_matmul_t_pool_gate.nxnx_matmul_tile_kat.nxnx_moe_gate.nxnx_nofloat_qwen_rope_h2h_gate.nxnx_paged_kv_gate.nxnx_pose_backprop_gate.nxnx_pose_cnn_gate.nxnx_pose_distill_gate.nxnx_pose_preprocess.nxnx_pose_student_distill.nxnx_q4k_fused_fidelity_gate.nxnx_q4k_fused_vs_x4_gate.nxnx_q4k_ggml_kat.nxnx_q4k_linear.nxnx_q4k_linear_hp.nxnx_q4k_real_gemm.nxnx_q4k_speed_bench.nxnx_q4k_to_f32.nxnx_q4k_to_f32_test.nxnx_q5_0_fused_dot_gate.nxnx_q5_0_threaded_gate.nxnx_q5_0_to_f32.nxnx_q5_k_ggml_kat.nxnx_q5_k_to_f32.nxnx_q5k_dot_row_col.nx +49 more (shown cap 100 declared)

structs

none

consts

30const NX_MAGIC_8388608: i64 = 8388608
31const NX_MAGIC_8388607: i64 = 8388607
207const NX_Q10_SAT: i64 = 4611686018427387904 // 2^62, headroom for the Q34 accumulate

functions

48func nx_f16_to_f32(raw: i64) -> i64
107func nx_i32_to_f32(value: i64) -> i64
169func nx_q10_to_f32(q10: i64) -> i64
209func nx_f32_to_q10(f32bits: i64) -> i64
called by 1: main
245func nx_q20_to_f32(q20: i64) -> i64
257func nx_f32_to_q20(f32bits: i64) -> i64
called by 1: _fq4m_pack_q10
282func nx_q24_to_f32(q24: i64) -> i64
called by 1: fq4m_rows_i8simd calls 1: nx_i32_to_f32
296func nx_q14_to_f32(q14: i64) -> i64