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
相关推荐
阿里云云原生12 小时前
可用性从 99.9% 跃升至 99.995%:畅捷通如何用 AI 重塑运维底座?
运维·网络·人工智能
ZhengEnCi12 小时前
MoE(Mixture of Experts,混合专家模型)深度解析:从路由机制到专家专业化的迷思
人工智能
shxjnpl12 小时前
Qwen3-ASR 从 PyTorch 迁移到 vLLM:一次信创环境下的推理路径改造实录
人工智能·pytorch·vllm
阿童木写作13 小时前
Python实现Temu图片批量翻译自动化教程
运维·人工智能·python·自动化
冬奇Lab14 小时前
代码库知识库系列(06):把调用图编码进 Embedding——结构增强有效,但不够
人工智能
冬奇Lab14 小时前
开源项目第175期:Buzz — Jack Dorsey 的 Block 用 Nostr 重新定义团队协作,AI Agent 拥有自己的加密身份
人工智能·开源·资讯
AI分享猿14 小时前
游戏原画与建筑灵感:AI图像生成如何服务前期设计
人工智能·游戏
字节跳动视频云技术团队14 小时前
为什么 AI 视频,需要“懂生成”的画质增强
人工智能
后端小肥肠15 小时前
我做了个能一键搭建个人工作台的 Skill,已开源
人工智能·aigc·agent