Fix: save_pretrained saves tokenizer weights, replace with safetensor…#266
Open
1321213430 wants to merge 1 commit intoshiyu-coder:masterfrom
Open
Fix: save_pretrained saves tokenizer weights, replace with safetensor…#2661321213430 wants to merge 1 commit intoshiyu-coder:masterfrom
1321213430 wants to merge 1 commit intoshiyu-coder:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue / 问题
When running
train_predictor.py, callingmodel.module.save_pretrained()saves tokenizer weights (encoder/decoder) instead of the trained Predictor model.transformer.0 ~ transformer.11运行
train_predictor.py时,调用model.module.save_pretrained()保存的并非训练后的预测模型,而是分词器(Tokenizer)权重(encoder/decoder)。transformer.0 ~ transformer.11Root Cause / 根本原因
The custom
Kronosmodel'ssave_pretrained()method incorrectly serializes tokenizer weights instead of the main model weights.自定义
Kronos模型的save_pretrained()方法存在错误,错误地序列化了分词器权重,而非主模型权重。Fix / 修复方案
Replace the broken
save_pretrained()with directsafetensorsstate_dict saving to ensure the full Predictor model weights are saved correctly.替换存在问题的
save_pretrained()方法,直接通过safetensors保存模型权重字典,确保完整、正确地保存预测模型权重。Changes / 修改内容
Add
safetensors.torchimportReplace model saving logic in
train_predictor.pyMinimal non-breaking change
新增
safetensors.torch导入语句替换
train_predictor.py中的模型保存逻辑最小化修改,无破坏性变更