liuhongwei-2026/ChatTime-1-7B-Chat
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

ChatTime-1-7B-Chat on Ascend NPU

模型适配 · 多模态时序基础模型(时序 + 文本双模态)· 昇腾 NPU 服务化推理

Beta 版本头信息

{hardware NPU}

1. 简介

  • 模型来源: ChengsenWang/ChatTime-1-7B-Chat(AtomGit 镜像: https://ai.gitcode.com/hf_mirrors/ChengsenWang/ChatTime-1-7B-Chat)
  • 模型类型: ChatTime-1-7B-Chat —— ChatTime(AAAI 2025)提出的多模态时序基础模型。将时间序列"建模为一种外语",在统一的框架中同时处理时序数值与自然语言,支持零样本时序预测、上下文引导预测与时序问答等任务。本权重为在 100K 指令微调数据集(ChatTime-1-Finetune-100K)上由 ChatTime-1-7B-Base 微调得到的 Chat 版本。
  • 架构: 标准 Llama(LlamaForCausalLM)decoder-only Transformer,AutoModelForCausalLM + AutoTokenizer 原生加载,无自定义远程代码。
    • 32 层 · hidden 4096 · 32 头 (MHA) · intermediate 11008 · vocab 42001
    • max_position_embeddings 4096 · RMSNorm · SwiGLU · RoPE
  • 参数量: 6,820,343,808(6.82B ≈ 7B)
  • 权重格式: bf16 · 3 个 safetensors 分片(≈ 13.6 GB)
  • 输入/输出: 时序数值 token 与自然语言指令(双模态)→ 时序预测 / 文本回答
  • 适配状态: SUCCESS
  • 适配说明: 模型为标准 Llama 架构,vLLM-Ascend 原生支持,零代码改造。仅需注意两点:① NPU 显存被其他会话占用时启动会报 Free memory ... less than desired GPU memory utilization,用 --gpu-memory-utilization 0.5(或更低)并指定空闲设备即可;② 该 tokenizer(<unk>/</s>,Unsloth 版)未定义 chat template(transformers 4.44+ 拒绝 fallback 默认模板),因此服务化调用走 /v1/completions(文本补全)接口而非 /v1/chat/completions。

2. 验证环境

组件版本
torch2.9.0
torch-npu2.9.0.post1
transformers4.57.6
vLLM0.18.0
vLLM-Ascend0.18.0
CANN8.5.1
NPUAscend 910B (64GB HBM)
Python3.11.14

3. 模型权重

权重通过 hf-mirror 拉取至本地目录 /tmp/models/ChatTime-1-7B-Chat:

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="ChengsenWang/ChatTime-1-7B-Chat",
    local_dir="/tmp/models/ChatTime-1-7B-Chat",
    local_dir_use_symlinks=False,
)

目录内容:config.json + tokenizer.model + tokenizer_config.json + model-0000{1,2,3}-of-00003.safetensors(3 分片 ≈ 13.6 GB)。

4. 部署步骤

4.1 启动 vLLM-Ascend 服务

cd ChatTime-1-7B-Chat

# 方式一:直接运行(服务化推理,默认动作)
python inference.py --serve \
  --model /tmp/models/ChatTime-1-7B-Chat \
  --device 1 \                # 指定空闲 NPU(ASCEND_RT_VISIBLE_DEVICES)
  --gpu-mem-util 0.5 \        # HBM 利用率,多会话共用时调低
  --port 8000

# 方式二:等价的手动 vllm serve 命令
ASCEND_RT_VISIBLE_DEVICES=1 vllm serve /tmp/models/ChatTime-1-7B-Chat \
  --dtype bfloat16 \
  --tensor-parallel-size 1 \
  --max-model-len 4096 \
  --max-num-seqs 16 \
  --port 8000 \
  --enforce-eager \
  --gpu-memory-utilization 0.5

4.2 健康检查

curl -sf http://127.0.0.1:8000/v1/models
# {"object":"list","data":[{"id":"/tmp/models/ChatTime-1-7B-Chat","object":"model",...}]}

4.3 服务化推理(时序数值 token 输出)

python inference.py --test --port 8000
# 或直接 curl:
curl -s http://127.0.0.1:8000/v1/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"/tmp/models/ChatTime-1-7B-Chat","prompt":"### Instruction: <history series>Generate a future sequence.### Response:","temperature":0,"max_tokens":64}'

5. 验证结果

项目结果
模型架构LlamaForCausalLM(原生支持,零改造)
dummy 权重启动PASS(KV cache 36,224 tokens)
真实权重加载PASS(13.6 GB / 3 分片)
/v1/models 就绪PASS
真实权重推理PASS(生成时序数值 token)

6. 性能参考

指标数值
EngineCore init(profile + KV cache + warmup)~2.7 s
KV cache 容量36,224 tokens(max_model_len 4096 × 8.84 并发)

7. 备注 / 已知问题

  1. HBM 不足:ValueError: Free memory on device (X/Y GiB) on startup is less than desired GPU memory utilization (0.9, ...) → 降低 --gpu-memory-utilization(0.4~0.5),或先 kill 残留的 VLLMWorker_TP 进程释放显存。
  2. chat template 缺失:tokenizer 未定义 chat template,/v1/chat/completions 报 400;时序模型惯例走 /v1/completions 补全接口。
  3. NPU 设备选择:多会话共用机器时用 npu-smi info 确认空闲设备,通过 ASCEND_RT_VISIBLE_DEVICES 指定(本机 npu:0/npu:1 均为 Ascend 910B 64GB)。