PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
fix: update tensor summary creation to directly use tensors_to_restor… (#2401)
Xin Hebff3deab0705
diff --git a/auto_round/utils/missing_tensors.py b/auto_round/utils/missing_tensors.pyindex 63d06bdc7..832aae485 100644--- a/auto_round/utils/missing_tensors.py+++ b/auto_round/utils/missing_tensors.py@@ -121,7 +121,7 @@ def _restore_special_fp32_tensors(os.remove(temporary_path)if tensors_to_restore:- tensor_summary = compress_layer_names([name.rsplit(".", 1)[0] for name in tensors_to_restore])+ tensor_summary = compress_layer_names(list(tensors_to_restore))logger.info(f"Restored {len(tensors_to_restore)} tensor(s) from FP16/BF16 to their original FP32 values: "f"{tensor_summary}."diff --git a/test/unit/common/utils/test_missing_tensors.py b/test/unit/common/utils/test_missing_tensors.pyindex e651f4f00..2867450a4 100644--- a/test/unit/common/utils/test_missing_tensors.py+++ b/test/unit/common/utils/test_missing_tensors.py@@ -479,7 +479,7 @@ class TestCopyMissingTensorsFromSource:copy_missing_tensors_from_source(src, tgt)assert not os.path.exists(os.path.join(tgt, "model_extra_tensors.safetensors"))- def test_restores_fp32_tensor_saved_as_fp16(self, tmp_path):+ def test_restores_fp32_tensor_saved_as_fp16(self, tmp_path, caplog, _autoround_log_propagate):src, tgt = str(tmp_path / "src"), str(tmp_path / "tgt")os.makedirs(src)os.makedirs(tgt)@@ -501,6 +501,7 @@ class TestCopyMissingTensorsFromSource:copy_missing_tensors_from_source(src, tgt)result = _load_safetensors(os.path.join(tgt, "model.safetensors"))+ assert "model.special.weight" in caplog.textassert result["model.special.weight"].dtype == torch.float32assert torch.equal(result["model.special.weight"], original)assert torch.equal(result["model.unchanged.weight"], torch.tensor([9.0], dtype=torch.float32))