add DeekSeek and Kimi-K2; support per-tensor and w4a8; support batch calibration in fp8 low_memory_run; support multiple nodes#29
Merged
Conversation
yghstill
reviewed
Aug 1, 2025
| }, | ||
| } | ||
|
|
||
| from transformers.models.deepseek_v3 import DeepseekV3Config |
| new_k = "model.norm.weight" | ||
| new_save_dict[new_k] = param | ||
| index_dict["weight_map"][new_k] = str(filename) | ||
| # safe_save(new_save_dict, os.path.join(save_model_path, filename)) # SAVE |
| json.dump(new_model_index, f, indent=2) | ||
|
|
||
|
|
||
| class PTQSaveTRTLLM(Deepseekv3HfPTQSave): |
Collaborator
There was a problem hiding this comment.
这个不是通用的save函数吧,如果只适用于DeepSeek,可以增加DeepSeek前缀
| def from_pretrained( | ||
| self, | ||
| model_path, | ||
| model_name="Qwen", |
Collaborator
There was a problem hiding this comment.
model_name这个参数不需要增加,from_pretrained如果和base model不一致,在Deepseek model下重写就行
| model_path, trust_remote_code=trust_remote_code | ||
| ) | ||
| # Load tokenizer | ||
| if config.model_type == "kimi_k2": |
Collaborator
There was a problem hiding this comment.
kimi-k2可以新注册一个模型,也写一个from_pretrained
| from .hunyuan_dense import HunyuanDense # noqa: F401 | ||
| from .hunyuan_moe import HunyuanMoE # noqa: F401 | ||
| from .llama import Llama # noqa: F401 | ||
| from .modeling_deepseek import DeepseekV3ForCausalLM # noqa: F401 |
Collaborator
There was a problem hiding this comment.
DeepseekV3ForCausalLM不对外暴露,这里可以删掉
| low_cpu_mem_usage: bool = field(default=True) | ||
| use_cache: bool = field(default=False) | ||
| cache_dir: Optional[str] = field(default=None) | ||
| load_type: str = field(default="bf16") |
Collaborator
There was a problem hiding this comment.
load_type字段看下是否能复用torch_dtype,Deepseek里加一个判断即可
| "int4_awq", | ||
| "int4_gptq", | ||
| "int8_dynamic", | ||
| "w4a8", |
| data_path: your/data/path | ||
| max_seq_length: 4096 | ||
| num_samples: 128 | ||
| batch_size: 1 |
…libration in fp8 low_memory_run
dawnranger
pushed a commit
to dawnranger/AngelSlim
that referenced
this pull request
Mar 11, 2026
…calibration in fp8 low_memory_run; support multiple nodes (Tencent#29)
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.
增加DeepSeek和Kimi-K2的per-tensor量化和w4a8量化,config目录名称deepseek_r1
支持权重以fp8和bf16的方式加载,使用load_type参数传入,可单卡、单机8卡、多机多卡校准
修改fp8的low_memory_run函数,支持batch校准