1. 问题描述
A同学训完一阶段浮点模型P_model_float,将模型提供给B同学,B同学固定P_model_float权重后(用一阶段浮点输出),分别用不同数据分开去训练二阶段prediction、planning两个分支,最后拼到一起成 float_model_all 提供给C同学用于量化部署。

C同学使用P_model_float在Data1上进行calib/qat,生成qat达标模型P_model_qat,然后冻结P_model_qat模型权重与scale,用P_model_out_qat与Data2/Data3分别去单独calib/qat对应head。
P_model_qat在Data1上指标达标,在Data2上 P_model_qat + prediction_float-calib的obstacle指标,相比于 P_model_float-calib + prediction_float-calib 在Data2上的要差2个点。
说明P_model_qat得到的权重虽然在Data1上指标满足,但泛化性不如P_model_float,本质是stage1 data和stage2 data数据分布不同,stage1 data校准scale不适用于state2 data。
此时可以将Data2加入到Data1中进行calib(不使用Data2数据 进行qat 一阶段的 P_model),让calib得到的scale更合理,避免一阶段模型P_model在Data2上产生截断误差,eval评测 P_model指标时,需要将Data1_eval和Data2_eval都评测,让一阶段P_model_qat在Data1和Data2指标都接近float,增强一阶段P_model_qat的泛化性(接近P_model_float)。
2. 推荐解决方案
问题描述章节的处理方案肯定不是推荐的链路,因为一阶段P_model_qat后,模型的权重 P_model_qat-weight 会发生变化,此时去接二阶段模型,交接处是存在匹配误差的。

2.1 方案推荐1
使用P_model_qat的float输出,结合Data2,finetune float prediction head,让prediction float head权重结合一阶段qat输出在Data2上效果更优,然后再进行二阶段prediction_float_new的calib/qat。
2.2 方案推荐2
一阶段P_model_float -> P_model_calib/qat -> 用P_model_qat_out 去训练prediction_float -> prediction_calib/qat,可以减少训练资源浪费,且调优更简单。
3. 代码实践
要求代码做好模块化管理
一阶段已经qat好,二阶段基于一阶段qat后的结果进行的float_finetune(float_train)
一阶段已经qat好,加载 stage2float 权重,仅calib stage2 head
一阶段已经qat好,stage2 calib后,仅qat stage2 head
debug分析:stage1_qat_stage2_float vs stage1_qat_stage2_calib
