{
  "suite": "courses/model-quantization/06-qat-bitnet-and-multimodal-lora-quant (ferrite v0.6)",
  "elapsed_sec": 612.8,
  "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"
  },
  "scratch_lsq_qat_and_distill": {
    "lsq_fp64_gradient_verification": {
      "dw_fp64_max_abs_err": 0.0,
      "ds_fp64_max_abs_err": 4.440892098500626e-16,
      "region_frac_below_qn": 0.1562,
      "region_frac_inside": 0.6562,
      "region_frac_above_qp": 0.1875
    },
    "model_id": "Qwen/Qwen3-0.6B",
    "quant_spec": "W2g64 symmetric signed {-2, -1, 0, +1} across all 196 decoder projections",
    "peak_qat_vram_gib": 14.251,
    "regimes": {
      "bf16_teacher": {
        "heldout_ce": 3.7775,
        "heldout_ppl": 43.7081,
        "kl_vs_teacher_nats": 0.0,
        "top1_agreement_pct": 100.0
      },
      "w2g64_ptq_zero_shot": {
        "heldout_ce": 14.5299,
        "heldout_ppl": 2042922.5595,
        "kl_vs_teacher_nats": 12.005682,
        "top1_agreement_pct": 0.47,
        "replaced_linear_count": 196
      },
      "w2g64_ste_fixed_scale_hard_ce": {
        "heldout_ce": 9.9058,
        "heldout_ppl": 20046.2807,
        "kl_vs_teacher_nats": 9.031922,
        "top1_agreement_pct": 13.68,
        "replaced_linear_count": 196,
        "steps": 90,
        "loss_snapshots": [
          15.1252,
          1.321,
          0.2118,
          0.0897
        ],
        "mean_learned_step_size": 0.042379,
        "train_elapsed_sec": 35.17
      },
      "w2g64_lsq_learnable_scale_hard_ce": {
        "heldout_ce": 9.8948,
        "heldout_ppl": 19827.7994,
        "kl_vs_teacher_nats": 9.315741,
        "top1_agreement_pct": 12.26,
        "replaced_linear_count": 196,
        "steps": 90,
        "loss_snapshots": [
          15.1252,
          0.6167,
          0.3166,
          0.1809
        ],
        "mean_learned_step_size": 0.042376,
        "train_elapsed_sec": 41.23
      },
      "w2g64_lsq_forward_kl_distill_t2": {
        "heldout_ce": 6.1137,
        "heldout_ppl": 452.0149,
        "kl_vs_teacher_nats": 3.665954,
        "top1_agreement_pct": 22.64,
        "replaced_linear_count": 196,
        "steps": 90,
        "loss_snapshots": [
          15.7866,
          3.019,
          0.9924,
          0.6536
        ],
        "mean_learned_step_size": 0.042366,
        "train_elapsed_sec": 46.63
      },
      "w2g64_lsq_reverse_kl_distill_t2": {
        "heldout_ce": 5.4056,
        "heldout_ppl": 222.6421,
        "kl_vs_teacher_nats": 3.048506,
        "top1_agreement_pct": 26.89,
        "replaced_linear_count": 196,
        "steps": 90,
        "loss_snapshots": [
          11.8644,
          3.2231,
          1.2688,
          0.7864
        ],
        "mean_learned_step_size": 0.042362,
        "train_elapsed_sec": 46.86
      }
    }
  },
  "scratch_bitnet_and_loftq": {
    "radix3_1p60bpw_codec": {
      "trit_mismatch_count": 0,
      "physical_bits_per_weight": 1.6,
      "theoretical_log2_3_bits": 1.585,
      "compression_vs_bf16_x": 10.0
    },
    "bitnet_b158_mlp_ablation": {
      "replaced_mlp_projections": 84,
      "ptq_zero_shot": {
        "heldout_ce": 14.5644,
        "heldout_ppl": 2114617.4099,
        "kl_vs_teacher_nats": 11.399907,
        "top1_agreement_pct": 1.89
      },
      "qat_90steps_kl_distill": {
        "heldout_ce": 6.1395,
        "heldout_ppl": 463.8093,
        "kl_vs_teacher_nats": 3.667817,
        "top1_agreement_pct": 25.47
      },
      "ternary_exact_zero_sparsity_pct": 31.34,
      "train_elapsed_sec": 38.34
    },
    "loftq_real_layer_convergence": {
      "nf4": {
        "trace_t0_to_t5": [
          {
            "iter": 0,
            "frob_err": 3.96113,
            "act_out_mse": 0.002636378165334463
          },
          {
            "iter": 1,
            "frob_err": 3.79074,
            "act_out_mse": 0.0023987903259694576
          },
          {
            "iter": 2,
            "frob_err": 3.65798,
            "act_out_mse": 0.0022401181049644947
          },
          {
            "iter": 3,
            "frob_err": 3.58801,
            "act_out_mse": 0.0021685915999114513
          },
          {
            "iter": 4,
            "frob_err": 3.5434,
            "act_out_mse": 0.00210872245952487
          },
          {
            "iter": 5,
            "frob_err": 3.51129,
            "act_out_mse": 0.0020692567341029644
          }
        ],
        "mse_reduction_t5_over_zero_init_x": 1.27,
        "mse_reduction_t5_over_single_svd_x": 1.159
      },
      "int3": {
        "trace_t0_to_t5": [
          {
            "iter": 0,
            "frob_err": 9.11005,
            "act_out_mse": 0.014229791238904
          },
          {
            "iter": 1,
            "frob_err": 8.71067,
            "act_out_mse": 0.012976898811757565
          },
          {
            "iter": 2,
            "frob_err": 8.40462,
            "act_out_mse": 0.01220684964209795
          },
          {
            "iter": 3,
            "frob_err": 8.24662,
            "act_out_mse": 0.011843226850032806
          },
          {
            "iter": 4,
            "frob_err": 8.14599,
            "act_out_mse": 0.01150431390851736
          },
          {
            "iter": 5,
            "frob_err": 8.07622,
            "act_out_mse": 0.011263073422014713
          }
        ],
        "mse_reduction_t5_over_zero_init_x": 1.26,
        "mse_reduction_t5_over_single_svd_x": 1.152
      },
      "int2": {
        "trace_t0_to_t5": [
          {
            "iter": 0,
            "frob_err": 18.42052,
            "act_out_mse": 0.05689425393939018
          },
          {
            "iter": 1,
            "frob_err": 17.55593,
            "act_out_mse": 0.05213524401187897
          },
          {
            "iter": 2,
            "frob_err": 16.86044,
            "act_out_mse": 0.048158399760723114
          },
          {
            "iter": 3,
            "frob_err": 16.5834,
            "act_out_mse": 0.04692067578434944
          },
          {
            "iter": 4,
            "frob_err": 16.44373,
            "act_out_mse": 0.04663246124982834
          },
          {
            "iter": 5,
            "frob_err": 16.36725,
            "act_out_mse": 0.04643472284078598
          }
        ],
        "mse_reduction_t5_over_zero_init_x": 1.23,
        "mse_reduction_t5_over_single_svd_x": 1.123
      }
    },
    "qlora_2bit_r32_comparison": {
      "standard_zero_init_qlora": {
        "init_elapsed_sec": 0.09,
        "train_60steps_sec": 14.15,
        "step0_before_finetune": {
          "heldout_ce": 18.136,
          "heldout_ppl": 75227852.8879,
          "kl_vs_teacher_nats": 15.927619,
          "top1_agreement_pct": 0.0
        },
        "step60_after_finetune": {
          "heldout_ce": 9.01,
          "heldout_ppl": 8184.2109,
          "kl_vs_teacher_nats": 7.077729,
          "top1_agreement_pct": 15.09
        }
      },
      "loftq_5iter_init_qlora": {
        "init_elapsed_sec": 4.56,
        "train_60steps_sec": 13.91,
        "step0_before_finetune": {
          "heldout_ce": 11.5945,
          "heldout_ppl": 108503.5028,
          "kl_vs_teacher_nats": 8.667741,
          "top1_agreement_pct": 3.77
        },
        "step60_after_finetune": {
          "heldout_ce": 7.3736,
          "heldout_ppl": 1593.4242,
          "kl_vs_teacher_nats": 6.216106,
          "top1_agreement_pct": 19.81
        }
      }
    }
  },
  "finetuned_llm_vlm_and_jev_arena": {
    "lora_export_guardrail": {
      "model_id": "Qwen/Qwen3-4B",
      "sft_55steps_sec": 17.83,
      "unfinetuned_base_bf16": {
        "xml_schema_pass": "0/8",
        "xml_schema_pass_pct": 0.0,
        "kl_vs_merged_bf16_nats": 0.0,
        "sample_outputs": [
          "Thought Process:\nThe user wants to quantize the Qwen3-14B model to AWQ 4-bit with a g",
          "Thought: The user wants to compress the checkpoint of a model called coder-7b using t"
        ]
      },
      "merged_bf16_gold": {
        "xml_schema_pass": "8/8",
        "xml_schema_pass_pct": 100.0,
        "kl_vs_merged_bf16_nats": 0.0,
        "sample_outputs": [
          "<ferrite_op action=\"quantize\" target=\"qwen3-14b\" method=\"awq\" bits=\"4\" group=\"128\" />",
          "<ferrite_op action=\"quantize\" target=\"coder-7b\" method=\"gptq\" bits=\"3\" group=\"64\" />"
        ]
      },
      "anti_pattern_double_quant_w3g64": {
        "xml_schema_pass": "0/8",
        "xml_schema_pass_pct": 0.0,
        "kl_vs_merged_bf16_nats": 5.479079,
        "sample_outputs": [
          "...\nOkay, the user is asking to quantize the model to 4 bits, specifically the 4-bit ",
          "Okay, the user is asking to compress a checkpoint using the GPTQ method, specifically"
        ]
      },
      "clean_merge_prose_mismatch_awq_w3g64": {
        "xml_schema_pass": "7/8",
        "xml_schema_pass_pct": 87.5,
        "kl_vs_merged_bf16_nats": 1.468721,
        "sample_outputs": [
          "<ferrite_op action=\"quantize\" target=\"qwen3-14b\" method=\"awq\" bits=\"4\" group=\"128\" />",
          "<ferrite_op action=\"quantize\" target=\"coder-7b\" method=\"gptq\" bits=\"3\" group=\"64\" />"
        ]
      },
      "clean_merge_domain_calib_awq_w3g64": {
        "xml_schema_pass": "6/8",
        "xml_schema_pass_pct": 75.0,
        "kl_vs_merged_bf16_nats": 1.334545,
        "sample_outputs": [
          "<ferrite_op ... />",
          "<ferrite_op ... />"
        ]
      },
      "clean_merge_domain_calib_awq_w4g128": {
        "xml_schema_pass": "8/8",
        "xml_schema_pass_pct": 100.0,
        "kl_vs_merged_bf16_nats": 0.525902,
        "sample_outputs": [
          "<ferrite_op action=\"quantize\" target=\"qwen3-14b\" method=\"awq\" bits=\"4\" group=\"128\" />",
          "<ferrite_op action=\"quantize\" target=\"coder-7b\" method=\"gptq\" bits=\"3\" group=\"64\" />"
        ]
      }
    },
    "jev_judge_recalibration": {
      "dataset_sha256_16": "1d3deb0f926bd0a9",
      "calib_size": 40,
      "test_size": 80,
      "t_bf16_star": 0.1226,
      "bf16_uncalibrated_t1": {
        "nll": 0.04152,
        "brier": 0.00556,
        "ece_10bin": 0.03837,
        "accuracy_pct": 100.0
      },
      "bf16_temp_calibrated": {
        "nll": 0.0,
        "brier": 0.0,
        "ece_10bin": 0.0,
        "accuracy_pct": 100.0
      },
      "w3g128_rtn": {
        "logit_margin_mae_vs_bf16": 3.3096,
        "logit_margin_mean_bias_shift": 2.531,
        "gate_p0p70_flip_rate_stale_pct": 50.0,
        "gate_p0p70_flip_rate_recal_pct": 6.25,
        "uncalibrated_t1": {
          "nll": 0.95825,
          "brier": 0.33901,
          "ece_10bin": 0.40194,
          "accuracy_pct": 50.0
        },
        "stale_prequant_t_bf16": {
          "nll": 5.53352,
          "brier": 0.49731,
          "ece_10bin": 0.4986,
          "accuracy_pct": 50.0
        },
        "recalibrated_1param_temp": {
          "t_quant_star": 4.0187,
          "nll": 0.60682,
          "brier": 0.2134,
          "ece_10bin": 0.40874,
          "accuracy_pct": 50.0
        },
        "recalibrated_2param_platt": {
          "t_quant_star": 0.05,
          "b_quant_star": -3.5681,
          "nll": 0.22494,
          "brier": 0.04112,
          "ece_10bin": 0.0488,
          "accuracy_pct": 95.0
        }
      },
      "w4g128_rtn": {
        "logit_margin_mae_vs_bf16": 0.8002,
        "logit_margin_mean_bias_shift": 0.0966,
        "gate_p0p70_flip_rate_stale_pct": 0.0,
        "gate_p0p70_flip_rate_recal_pct": 0.0,
        "uncalibrated_t1": {
          "nll": 0.04957,
          "brier": 0.0079,
          "ece_10bin": 0.04481,
          "accuracy_pct": 100.0
        },
        "stale_prequant_t_bf16": {
          "nll": 0.00016,
          "brier": 0.0,
          "ece_10bin": 0.00016,
          "accuracy_pct": 100.0
        },
        "recalibrated_1param_temp": {
          "t_quant_star": 0.05,
          "nll": 0.0,
          "brier": 0.0,
          "ece_10bin": 0.0,
          "accuracy_pct": 100.0
        },
        "recalibrated_2param_platt": {
          "t_quant_star": 0.1546,
          "b_quant_star": -1.6906,
          "nll": 0.0,
          "brier": 0.0,
          "ece_10bin": 0.0,
          "accuracy_pct": 100.0
        }
      }
    },
    "vlm_sensitive_bridge_whitelist": {
      "model_id": "Qwen/Qwen2.5-VL-3B-Instruct",
      "rendered_cards_sha256_16": "9ae3bf70208d5c05",
      "vision_linear_params_m": 666.66,
      "llm_linear_params_m": 2774.53,
      "weight_footprint_bf16_gib": 6.994,
      "weight_footprint_whitelist_w4_gib": 3.198,
      "weight_footprint_blind_w4_gib": 2.286,
      "variants": {
        "vlm_bf16_baseline": {
          "visual_merger_sqnr_db": 99.0,
          "visual_merger_cosine": 1.0,
          "first_answer_token_kl_nats": 0.0,
          "invoice_exact_ocr_pass": "8/8",
          "invoice_exact_ocr_pct": 100.0,
          "sample_predictions": [
            "ID=INV-8421; TOTAL=$12,480.00",
            "ID=INV-9037; TOTAL=$6,920.50"
          ]
        },
        "vlm_blind_all_w3g64_rtn": {
          "visual_merger_sqnr_db": 4.55,
          "visual_merger_cosine": 0.84091,
          "first_answer_token_kl_nats": 16.313938,
          "invoice_exact_ocr_pass": "0/8",
          "invoice_exact_ocr_pct": 0.0,
          "sample_predictions": [
            "\\\"\\\"\\\"\\\"\\n\\\"\\\"\\\"</\\\"\\\"\\\"\\\"\\n\\n\\\"\\\"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n",
            "\\\"\\\"\\\"\\\"\\n\\\"\\\"\\\"</\\\"\\\"\\\"\\\"\\n\\n\\\"\\\"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n"
          ]
        },
        "vlm_ablation_quant_visual_only_w3g64": {
          "visual_merger_sqnr_db": 4.55,
          "visual_merger_cosine": 0.84091,
          "first_answer_token_kl_nats": 1.7e-05,
          "invoice_exact_ocr_pass": "8/8",
          "invoice_exact_ocr_pct": 100.0,
          "sample_predictions": [
            "ID=INV-8421; TOTAL=$12,480.00",
            "ID=INV-9037; TOTAL=$6,920.50"
          ]
        },
        "vlm_whitelist_visual_bf16_llm_w3g64_awq": {
          "visual_merger_sqnr_db": 99.0,
          "visual_merger_cosine": 1.0,
          "first_answer_token_kl_nats": 0.092605,
          "invoice_exact_ocr_pass": "5/8",
          "invoice_exact_ocr_pct": 62.5,
          "sample_predictions": [
            "ID=INV-8421; TOTAL=$12,480.00",
            "ID=INV-9037; TOTAL=6,920.50"
          ]
        },
        "vlm_whitelist_visual_bf16_llm_w4g128_awq": {
          "visual_merger_sqnr_db": 99.0,
          "visual_merger_cosine": 1.0,
          "first_answer_token_kl_nats": 0.000185,
          "invoice_exact_ocr_pass": "8/8",
          "invoice_exact_ocr_pct": 100.0,
          "sample_predictions": [
            "ID=INV-8421; TOTAL=$12,480.00",
            "ID=INV-9037; TOTAL=$6,920.50"
          ]
        }
      }
    },
    "peak_arena_vram_gib": 14.251,
    "arena_elapsed_sec": 246.49
  }
}
