swift-微调补充

1,安装nvitop

nvitop 可以实时看显卡占用占用情况

复制代码
pip install nvitop

nvitop -m auto

2,NewGELUActivation, PytorchGELUTanh, GELUActivation ImportError: cannot import name 'PytorchGELUTanh' from 'transformers.activations' (/mnt/workspace/ft_new/ft_qwen/lib/python3.11/site-packages/transformers/activations.py)

直接修改源码

bash 复制代码
vim /mnt/workspace/ft_new/ft_qwen/lib/python3.11/site-packages/awq/quantize/scale.py

找到第 12 行的导入代码:

python 复制代码
# 原错误代码
from transformers.activations import NewGELUActivation, PytorchGELUTanh, GELUActivation

修改为

python 复制代码
# 新代码(移除PytorchGELUTanh,用原生GELU替代)
import torch
import torch.nn as nn
# 定义兼容类
class PytorchGELUTanh(nn.Module):
    def forward(self, x):
        return torch.nn.functional.gelu(x, approximate='tanh')
# 给awq用的别名(兼容原代码逻辑)
NewGELUActivation = PytorchGELUTanh
GELUActivation = PytorchGELUTanh

3.ValueError: To serve at least one request with the models's max seq len (262144), (36.0 GiB KV cache is needed, which is larger than the available KV cache memory (12.16 GiB). Based on the available memory, the estimated maximum model length is 88544. Try increasing `gpu_memory_utilization` or decreasing `max_model_len` when initializing the engine.

注意需要加上下面参数进行部署

bash 复制代码
--vllm_max_model_len 70000

4,模型导出并上传魔搭社区

bash 复制代码
 swift export \
    --model output/v3-20260218-164346/checkpoint-75-merged \
    --push_to_hub true \
    --hub_model_id 'a80C51/llm-wayne-qwen3-4b-think-2507' \
    --hub_token 'ms-43994f9b-8b99-4fc6-852f-1f7d44513e16' \
    --use_hf false
相关推荐
DeepModel2 小时前
机器学习非线性降维:局部线性嵌入 LLE
人工智能·机器学习
lUie INGA2 小时前
rust web框架actix和axum比较
前端·人工智能·rust
新缸中之脑3 小时前
HDRI-Generator: 环境贴图生成AI
人工智能·贴图
网安情报局3 小时前
企业押注Agentic SOC:AI重塑安全运营新范式
人工智能·网络安全
夜幕下的ACM之路3 小时前
一、基础知识学习(Transformer + 上下文窗口 + Token 计算 + Embedding 向量)
人工智能·学习·transformer·embedding
东离与糖宝3 小时前
LangChain4j vs Spring AI:最新对比,Java企业级Agent开发
java·人工智能
私人珍藏库3 小时前
[Windows] 绘画工具 Krita v5.3.1
人工智能·windows·媒体·工具·软件·多功能
前端摸鱼匠3 小时前
【AI大模型春招面试题13】残差连接(Residual Connection)与层归一化(Layer Norm)在Transformer中的作用?
人工智能·深度学习·语言模型·面试·transformer·求职招聘
重生之我要成为代码大佬3 小时前
HuggingFace生态实战:从模型应用到高效微调
人工智能·python·大模型·huggingface·模型微调