msit对DeepSeek-R1-0528模型进行int4量化未使用全部卡
收藏回复举报
msit对DeepSeek-R1-0528模型进行int4量化未使用全部卡
t('forum.solved') 已解决
发表于2025-11-03 14:28:22
0 查看

swr.cn-south-1.myhuaweicloud.com/ascendhub/mindie:2.1.RC2-800I-A2-py311-openeuler24.03-lts

修改msit/msmodelslim/example/DeepSeek/quant_deepseek_w4a8.py

model = AutoModelForCausalLM.from_pretrained(pretrained_model_name_or_path=model_path,添加:

max_memory={0: "50GiB", 1: "50GiB", 2: "50GiB", 3: "50GiB",4: "50GiB", 5: "50GiB",6: "50GiB", 7: "50GiB","cpu": "1500GiB"},

也未起作用,只用到一张卡

量化命令:

msmodelslim quant \
 --model_path /ai/models/DeepSeek-R1-0528 \
 --save_path /data/models \
 --model_type DeepSeek-R1-0528 \
 --quant_type w4a8 \
 --trust_remote_code True

另外量化进行到半小时左右报类型错误:

File "/usr/local/lib/python3.11/site-packages/msmodelslim/core/runner/layer_wise_runner.py", line 72, in run                                                                           [0/1910]
    self.generated_schedule(process_unit, data_recorder)                                                                                                                                         
  File "/usr/local/lib64/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context                                                                                     
    return func(*args, **kwargs)                                                                                                                                                                 
           ^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                 
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/core/runner/generated_runner.py", line 200, in generated_schedule                                                                    
    if not unit.make_progress():                                                                                                                                                                 
           ^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                  
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/core/runner/generated_runner.py", line 99, in make_progress                                                                          
    self.processor.process(batch_request)                                                                                                                                                        
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/quant/processor/base.py", line 116, in process                                                                                       
    super().process(request)                                                                                                                                                                     
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/core/base/processor.py", line 43, in process                                                                                         
    self._run_forward_if_need(request)                                                                                                                                                           
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/core/base/processor.py", line 75, in _run_forward_if_need                                                                            
    output = request.module(*args, **kwargs)                                                                                                                                                     
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                     
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl                                                                                  
    return self._call_impl(*args, **kwargs)                                                                                                                                                      
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                      
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl                                                                                          
    result = forward_call(*args, **kwargs)                                                                                                                                                       
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                       
  File "/root/.cache/huggingface/modules/transformers_modules/DeepSeek-R1-0528/modeling_deepseek.py", line 1202, in forward                                                                      
    hidden_states, self_attn_weights, present_key_value = self.self_attn(                                                                                                                        
                                                          ^^^^^^^^^^^^^^^                                                                                                                        
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl                                                                                  
    return self._call_impl(*args, **kwargs)                                                                                                                                                      
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                      
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl                                                                                          
    return forward_call(*args, **kwargs)                                                                                                                                                         
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                         
  File "/root/.cache/huggingface/modules/transformers_modules/DeepSeek-R1-0528/modeling_deepseek.py", line 769, in forward                                                                       
    q = self.q_b_proj(self.q_a_layernorm(self.q_a_proj(hidden_states)))                                                                                                                          
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                            
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl                                                                                  
    return self._call_impl(*args, **kwargs)                                                                                                                                                      
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                      
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl                                                                                          
    result = forward_call(*args, **kwargs)                                                                                                                                                       
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                       
  File "/usr/local/lib64/python3.11/site-packages/torch/nn/modules/linear.py", line 114, in forward                                                                                              
    return F.linear(input, self.weight, self.bias)                                                                                                                                               
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                               
RuntimeError: Float8_e4m3fn has not been supported                                                                                                                                               
[ERROR] 2025-11-03-14:18:22 (PID:574, Device:0, RankID:-1) ERR01007 OPS feature not supported                                                                                                    
                                                                                                                                                                                                 
The above exception was the direct cause of the following exception:                                                                                                                             
                                                                                                                                                                                                 
Traceback (most recent call last):                                                                                                                                                               
  File "/usr/local/bin/msmodelslim", line 8, in <module>                                                                                                                                         
    sys.exit(main())                                                                                                                                                                             
             ^^^^^^                                                                                                                                                                              
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/cli/__main__.py", line 76, in main                                                                                                   
    quant_main(args)                                                                                                                                                                             
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/cli/naive_quantization/__main__.py", line 50, in main                                                                                
    app.quant(                                                                                                                                                                                   
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/utils/logging.py", line 277, in wrapper                                                                                              
    return func(*args, **kwargs)                                                                                                                                                                 
           ^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                 
  File "/usr/local/lib/python3.11/site-packages/msmodelslim/utils/exception_decorator.py", line 170, in wrapper                                                                                  
    raise unexpected_error from e                                                                                                                                                                
msmodelslim.utils.exception.UnexpectedError: Code: 500, Message: Unexpected error.                                                                                                               
TIP: Please report this issue to the msModelSlim developers. Repository: https://gitcode.com/Ascend/msit Q&A: https://gitcode.com/Ascend/msit/blob/master/msmodelslim/docs/FAQ.md                
[ERROR] 2025-11-03-14:18:24 (PID:574, Device:0, RankID:-1) ERR99999 UNKNOWN application exception

我要发帖子