{
  "suite": "courses/model-quantization/01-number-formats-outliers-and-roofline (ferrite v0.1)",
  "elapsed_sec": 130.78,
  "environment": {
    "gpu_name": "NVIDIA L4",
    "compute_capability": "sm_89",
    "total_vram_mib": 22563.1,
    "pytorch_version": "2.14.1+cu130",
    "transformers_version": "5.23.0",
    "python_version": "3.13.16"
  },
  "number_formats_and_sqnr": {
    "n_elements": 1048576,
    "nf4_vs_bnb_max_abs_diff": 1.2e-07,
    "uniform_6db_per_bit_curve": {
      "int2_sqnr_db": 6.022,
      "int3_sqnr_db": 15.558,
      "int4_sqnr_db": 22.925,
      "int6_sqnr_db": 35.842,
      "int8_sqnr_db": 48.098
    },
    "format_comparison": {
      "int8_per_tensor": {
        "effective_bpw": 8.0,
        "gaussian_sqnr_db": 39.439,
        "outlier_global_sqnr_db": 17.859,
        "outlier_normal_channels_sqnr_db": 5.361,
        "normal_channels_zero_collapse_rate": 0.6509
      },
      "fp8_e4m3_per_tensor": {
        "effective_bpw": 8.0,
        "gaussian_sqnr_db": 31.556,
        "outlier_global_sqnr_db": 31.572,
        "outlier_normal_channels_sqnr_db": 31.532,
        "normal_channels_zero_collapse_rate": 0.0004
      },
      "fp8_e5m2_per_tensor": {
        "effective_bpw": 8.0,
        "gaussian_sqnr_db": 25.576,
        "outlier_global_sqnr_db": 25.568,
        "outlier_normal_channels_sqnr_db": 25.556,
        "normal_channels_zero_collapse_rate": 0.0
      },
      "fp8_e4m3_g128": {
        "effective_bpw": 8.125,
        "gaussian_sqnr_db": 31.785,
        "outlier_global_sqnr_db": 44.176,
        "outlier_normal_channels_sqnr_db": 31.662,
        "normal_channels_zero_collapse_rate": 0.0001
      },
      "int4_per_tensor": {
        "effective_bpw": 4.0,
        "gaussian_sqnr_db": 14.269,
        "outlier_global_sqnr_db": 11.102,
        "outlier_normal_channels_sqnr_db": 0.0,
        "normal_channels_zero_collapse_rate": 1.0
      },
      "int4_sym_g128": {
        "effective_bpw": 4.125,
        "gaussian_sqnr_db": 18.632,
        "outlier_global_sqnr_db": 16.525,
        "outlier_normal_channels_sqnr_db": 4.01,
        "normal_channels_zero_collapse_rate": 0.5139
      },
      "int4_asym_g128": {
        "effective_bpw": 4.1562,
        "gaussian_sqnr_db": 19.956,
        "outlier_global_sqnr_db": 17.629,
        "outlier_normal_channels_sqnr_db": 5.245,
        "normal_channels_zero_collapse_rate": 0.4452
      },
      "nf4_dq_g64": {
        "effective_bpw": 4.127,
        "gaussian_sqnr_db": 20.733,
        "outlier_global_sqnr_db": 20.292,
        "outlier_normal_channels_sqnr_db": 7.781,
        "normal_channels_zero_collapse_rate": 0.26
      },
      "mxfp4_b32": {
        "effective_bpw": 4.25,
        "gaussian_sqnr_db": 18.53,
        "outlier_global_sqnr_db": 17.921,
        "outlier_normal_channels_sqnr_db": 9.937,
        "normal_channels_zero_collapse_rate": 0.196
      },
      "nvfp4_b16": {
        "effective_bpw": 4.5,
        "gaussian_sqnr_db": 20.447,
        "outlier_global_sqnr_db": 24.894,
        "outlier_normal_channels_sqnr_db": 13.363,
        "normal_channels_zero_collapse_rate": 0.1099
      }
    }
  },
  "qwen25_7b_outlier_and_rtn": {
    "model_id": "Qwen/Qwen2.5-7B-Instruct",
    "eval_corpus_sha256": "1331ea4337c3a518",
    "num_layers": 28,
    "peak_q_input_outlier": {
      "layer": 27,
      "amax": 107.0,
      "median_channel_max": 1.2812,
      "outlier_to_median_ratio": 83.51,
      "crest_factor_amax_over_rms": 77.34,
      "top4_channels": [
        2718,
        458,
        392,
        46
      ]
    },
    "peak_down_input_outlier": {
      "layer": 26,
      "amax": 5632.0,
      "median_channel_max": 4.125,
      "outlier_to_median_ratio": 1365.33,
      "crest_factor_amax_over_rms": 977.59
    },
    "deep_layer_top8_channel_jaccard": 0.5859,
    "sampled_layers_down_proj": [
      {
        "layer": 0,
        "amax": 12.125,
        "median_channel_max": 0.1602,
        "outlier_to_median_ratio": 75.71,
        "crest_factor_amax_over_rms": 226.58
      },
      {
        "layer": 1,
        "amax": 27.75,
        "median_channel_max": 0.0747,
        "outlier_to_median_ratio": 371.45,
        "crest_factor_amax_over_rms": 433.43
      },
      {
        "layer": 2,
        "amax": 38.0,
        "median_channel_max": 0.1631,
        "outlier_to_median_ratio": 233.01,
        "crest_factor_amax_over_rms": 490.75
      },
      {
        "layer": 14,
        "amax": 16.5,
        "median_channel_max": 0.5508,
        "outlier_to_median_ratio": 29.96,
        "crest_factor_amax_over_rms": 115.42
      },
      {
        "layer": 26,
        "amax": 5632.0,
        "median_channel_max": 4.125,
        "outlier_to_median_ratio": 1365.33,
        "crest_factor_amax_over_rms": 977.59
      },
      {
        "layer": 27,
        "amax": 500.0,
        "median_channel_max": 5.5938,
        "outlier_to_median_ratio": 89.39,
        "crest_factor_amax_over_rms": 162.23
      }
    ],
    "granularity_ppl_kl_table": {
      "bf16_baseline": {
        "valid_tokens": 277,
        "nll": 2.86535,
        "ppl": 17.5553,
        "kl_vs_bf16": 0.0,
        "top1_match_rate": 1.0
      },
      "w8_per_tensor_rtn": {
        "valid_tokens": 277,
        "nll": 2.89871,
        "ppl": 18.1508,
        "kl_vs_bf16": 0.128891,
        "top1_match_rate": 0.8339
      },
      "w4_per_tensor_rtn": {
        "valid_tokens": 277,
        "nll": 11.79706,
        "ppl": 132860.6612,
        "kl_vs_bf16": 9.842754,
        "top1_match_rate": 0.0
      },
      "w4_per_channel_rtn": {
        "valid_tokens": 277,
        "nll": 3.52384,
        "ppl": 33.9144,
        "kl_vs_bf16": 1.037166,
        "top1_match_rate": 0.5523
      },
      "w4_group128_sym_rtn": {
        "valid_tokens": 277,
        "nll": 2.86064,
        "ppl": 17.4727,
        "kl_vs_bf16": 0.184991,
        "top1_match_rate": 0.8087
      },
      "w4_nf4_g64": {
        "valid_tokens": 277,
        "nll": 2.91854,
        "ppl": 18.5143,
        "kl_vs_bf16": 0.098914,
        "top1_match_rate": 0.8664
      },
      "w8a8_per_tensor_int8": {
        "valid_tokens": 277,
        "nll": 3.80755,
        "ppl": 45.0402,
        "kl_vs_bf16": 1.072178,
        "top1_match_rate": 0.5632
      },
      "w8a8_pertoken_perchannel_int8": {
        "valid_tokens": 277,
        "nll": 2.79532,
        "ppl": 16.3679,
        "kl_vs_bf16": 0.089942,
        "top1_match_rate": 0.852
      },
      "w8a8_dynamic_fp8_e4m3": {
        "valid_tokens": 277,
        "nll": 2.9114,
        "ppl": 18.3826,
        "kl_vs_bf16": 0.017352,
        "top1_match_rate": 0.935
      }
    },
    "peak_vram_gib": 15.879
  },
  "roofline_w4a16_vs_fp8": {
    "layer_shape": {
      "k_in": 4096,
      "n_out": 14336,
      "bf16_weight_mib": 112.0
    },
    "fused_w4a16_backend": "torchao_int4_tinygemm",
    "w4a16_slower_than_bf16_crossover_m": 64,
    "batch_sweep": [
      {
        "batch_tokens_m": 1,
        "bf16_arithmetic_intensity_flop_per_byte": 1.0,
        "bf16_ms": 0.4528,
        "unfused_w4_to_bf16_ms": 6.02,
        "bnb_nf4_ms": 0.1214,
        "fused_w4a16_ms": 0.1149,
        "native_fp8_ms": 0.2725,
        "bf16_tflops": 0.26,
        "fused_w4a16_speedup_vs_bf16": 3.941,
        "native_fp8_speedup_vs_bf16": 1.662,
        "bnb_nf4_speedup_vs_bf16": 3.731,
        "unfused_speedup_vs_bf16": 0.075
      },
      {
        "batch_tokens_m": 4,
        "bf16_arithmetic_intensity_flop_per_byte": 3.99,
        "bf16_ms": 0.4726,
        "unfused_w4_to_bf16_ms": 6.125,
        "bnb_nf4_ms": 0.1955,
        "fused_w4a16_ms": 0.116,
        "native_fp8_ms": 0.2746,
        "bf16_tflops": 0.99,
        "fused_w4a16_speedup_vs_bf16": 4.074,
        "native_fp8_speedup_vs_bf16": 1.721,
        "bnb_nf4_speedup_vs_bf16": 2.417,
        "unfused_speedup_vs_bf16": 0.077
      },
      {
        "batch_tokens_m": 8,
        "bf16_arithmetic_intensity_flop_per_byte": 7.98,
        "bf16_ms": 0.479,
        "unfused_w4_to_bf16_ms": 6.1245,
        "bnb_nf4_ms": 0.229,
        "fused_w4a16_ms": 0.1246,
        "native_fp8_ms": 0.2733,
        "bf16_tflops": 1.96,
        "fused_w4a16_speedup_vs_bf16": 3.845,
        "native_fp8_speedup_vs_bf16": 1.753,
        "bnb_nf4_speedup_vs_bf16": 2.092,
        "unfused_speedup_vs_bf16": 0.078
      },
      {
        "batch_tokens_m": 16,
        "bf16_arithmetic_intensity_flop_per_byte": 15.92,
        "bf16_ms": 0.4799,
        "unfused_w4_to_bf16_ms": 6.1256,
        "bnb_nf4_ms": 0.2336,
        "fused_w4a16_ms": 0.2295,
        "native_fp8_ms": 0.2698,
        "bf16_tflops": 3.92,
        "fused_w4a16_speedup_vs_bf16": 2.091,
        "native_fp8_speedup_vs_bf16": 1.779,
        "bnb_nf4_speedup_vs_bf16": 2.054,
        "unfused_speedup_vs_bf16": 0.078
      },
      {
        "batch_tokens_m": 32,
        "bf16_arithmetic_intensity_flop_per_byte": 31.68,
        "bf16_ms": 0.5228,
        "unfused_w4_to_bf16_ms": 6.1263,
        "bnb_nf4_ms": 0.2409,
        "fused_w4a16_ms": 0.4506,
        "native_fp8_ms": 0.2743,
        "bf16_tflops": 7.19,
        "fused_w4a16_speedup_vs_bf16": 1.16,
        "native_fp8_speedup_vs_bf16": 1.906,
        "bnb_nf4_speedup_vs_bf16": 2.17,
        "unfused_speedup_vs_bf16": 0.085
      },
      {
        "batch_tokens_m": 64,
        "bf16_arithmetic_intensity_flop_per_byte": 62.74,
        "bf16_ms": 0.5298,
        "unfused_w4_to_bf16_ms": 6.1397,
        "bnb_nf4_ms": 0.2984,
        "fused_w4a16_ms": 0.9729,
        "native_fp8_ms": 0.2824,
        "bf16_tflops": 14.19,
        "fused_w4a16_speedup_vs_bf16": 0.545,
        "native_fp8_speedup_vs_bf16": 1.876,
        "bnb_nf4_speedup_vs_bf16": 1.775,
        "unfused_speedup_vs_bf16": 0.086
      },
      {
        "batch_tokens_m": 128,
        "bf16_arithmetic_intensity_flop_per_byte": 123.06,
        "bf16_ms": 0.5414,
        "unfused_w4_to_bf16_ms": 6.1339,
        "bnb_nf4_ms": 0.3721,
        "fused_w4a16_ms": 1.8612,
        "native_fp8_ms": 0.2993,
        "bf16_tflops": 27.77,
        "fused_w4a16_speedup_vs_bf16": 0.291,
        "native_fp8_speedup_vs_bf16": 1.809,
        "bnb_nf4_speedup_vs_bf16": 1.455,
        "unfused_speedup_vs_bf16": 0.088
      },
      {
        "batch_tokens_m": 256,
        "bf16_arithmetic_intensity_flop_per_byte": 236.96,
        "bf16_ms": 0.6364,
        "unfused_w4_to_bf16_ms": 6.2634,
        "bnb_nf4_ms": 0.8735,
        "fused_w4a16_ms": 3.5164,
        "native_fp8_ms": 0.3338,
        "bf16_tflops": 47.24,
        "fused_w4a16_speedup_vs_bf16": 0.181,
        "native_fp8_speedup_vs_bf16": 1.906,
        "bnb_nf4_speedup_vs_bf16": 0.729,
        "unfused_speedup_vs_bf16": 0.102
      },
      {
        "batch_tokens_m": 512,
        "bf16_arithmetic_intensity_flop_per_byte": 441.11,
        "bf16_ms": 1.292,
        "unfused_w4_to_bf16_ms": 6.4372,
        "bnb_nf4_ms": 1.9241,
        "fused_w4a16_ms": 6.941,
        "native_fp8_ms": 0.4943,
        "bf16_tflops": 46.54,
        "fused_w4a16_speedup_vs_bf16": 0.186,
        "native_fp8_speedup_vs_bf16": 2.614,
        "bnb_nf4_speedup_vs_bf16": 0.672,
        "unfused_speedup_vs_bf16": 0.201
      },
      {
        "batch_tokens_m": 2048,
        "bf16_arithmetic_intensity_flop_per_byte": 1246.61,
        "bf16_ms": 4.4915,
        "unfused_w4_to_bf16_ms": 9.0686,
        "bnb_nf4_ms": 4.938,
        "fused_w4a16_ms": 27.8738,
        "native_fp8_ms": 2.7739,
        "bf16_tflops": 53.55,
        "fused_w4a16_speedup_vs_bf16": 0.161,
        "native_fp8_speedup_vs_bf16": 1.619,
        "bnb_nf4_speedup_vs_bf16": 0.91,
        "unfused_speedup_vs_bf16": 0.495
      }
    ]
  }
}
