Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int8量化感知训练,保存的模型依然是fp32 #27

Open
jinmin527 opened this issue Aug 27, 2023 · 3 comments
Open

int8量化感知训练,保存的模型依然是fp32 #27

jinmin527 opened this issue Aug 27, 2023 · 3 comments

Comments

@jinmin527
Copy link

通过BMCook进行模型压缩,配置了quantization和distillation,训练的loss收敛的很好。但是保存模型的时候,发现保存的checkpoint文件并没有减少,分析发现线性层的参数还是fp32的。
另外bmtrain的优化器AdamOffloadOptimizer和AdamOptimizer也只支持参数保存为fp32和fp16,并没有实现参数保存为int8。

@jinmin527
Copy link
Author

是不是推理的时候,bminf将线程层转换成量化线性层,最终实现参数从fp16到int8,然后bminf计算也是int8

@zzy14
Copy link
Collaborator

zzy14 commented Aug 29, 2023

是不是推理的时候,bminf将线程层转换成量化线性层,最终实现参数从fp16到int8,然后bminf计算也是int8

是的,保存的精度没有变化,需要再面向bminf转换一下。

@zzdxjtu
Copy link

zzdxjtu commented Nov 9, 2023

@jinmin527 你好,想问问你是怎么量化保存的,我是在微调训练的get_model之后添加的BMQuant.quantize(model, quantization_config)进行量化,能够保存模型,但是加载该模型推理时报了ValueError: Missing some parameters in layer 1
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants