模型名称: qcw2333/YingLong_110m
模型链接: HuggingFace
模型描述: YingLong 是一个基于 U-Net 架构的 GPT 时间序列预测模型,使用 Patch 编码 + Haar 小波变换 + GQA (Grouped Query Attention) + RoPE (Rotary Position Embedding) 进行多变量时间序列的概率预测(分位数输出)。
模型架构: U-Net GPT (自定义架构)
参数规模: 120.5M
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| numpy | >= 1.24.0 | 数值计算 |
| safetensors | >= 0.4.0 | 安全张量格式加载 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
NPU 硬件: Ascend 910B2C (2 卡)
安装命令:
pip install torch>=2.1.0 torch-npu>=2.1.0 numpy>=1.24.0 safetensors>=0.4.0# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"模型文件已包含在交付目录中:
qcw2333_YingLong_110m/
├── inference.py # 推理脚本
├── npu_model.py # NPU 兼容模型实现
├── model_config/
│ ├── model_config.py # 模型配置
│ └── model.safetensors # 预训练权重 (230MB)
├── README.md # 本文档
└── requirements.txt # 依赖清单# 基本推理(使用合成时间序列)
cd qcw2333_YingLong_110m
python3 inference.py --model-path ./model_config
# 指定输入数据
python3 inference.py --model-path ./model_config \
--input-data "1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0"
# 从文件读取输入
python3 inference.py --model-path ./model_config --input-data input.txt
# 基准测试
python3 inference.py --model-path ./model_config --benchmark --num-samples 10| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --input-data | str | None | 输入时间序列 (逗号分隔) |
| --input-file | str | None | 输入时间序列文件路径 |
| --benchmark | flag | False | 运行性能基准测试 |
| --num-samples | int | 10 | 基准测试样本数 |
| --device | str | npu | 推理设备 (npu/cpu) |
| --seed | int | 42 | 随机种子 |
[模型] qcw2333/YingLong_110m
[设备] Ascend910_9362 (npu:0)
[输入] 1D 时间序列, seq_len=8224, patch_size=32
[输出] predictions: (1, 206, 32, 99), dtype=bfloat16
[耗时] 343.6ms
[状态] SUCCESS[基准测试] 10次推理统计:
平均: 311.2ms
最小: 298.2ms
最大: 356.7ms
标准差: 18.4ms
P50: 307.1ms
P99: 356.7ms运行命令:
python3 inference.py --model-path ./model_config --seed 42输出:
[输入] 时间序列长度: 8224
前10个值: ['0.0497', '-0.0062', '0.0801', '0.1752', '0.0071', '0.0148', '0.2038', '0.1302', '0.0141', '0.1230']
[推理] 开始推理...
推理耗时: 343.6ms
[输出] 预测结果:
Predictions shape: torch.Size([1, 206, 32, 99])
Raw values shape: torch.Size([1, 206, 32])
Prediction range: [-0.4883, 0.5000]
Prediction mean: -0.0879
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./model_config --benchmark --num-samples 10输出:
[基准测试] 10 次推理 (seq_len=8224):
推理 1/10: 356.7ms, output_shape=[1, 206, 32, 99]
推理 2/10: 298.2ms, output_shape=[1, 206, 32, 99]
...
统计结果:
平均: 311.2ms
最小: 298.2ms
最大: 356.7ms
标准差: 18.4ms
P50: 307.1ms
P99: 356.7ms
[状态] SUCCESS


模型来源: qcw2333/YingLong_110m (HuggingFace 预训练权重)
评测说明: 该模型为预训练时间序列预测模型,权重直接加载使用。模型输出 99 个分位数 (1%-99%) 的概率预测,使用 Quantile Loss 训练。
评测命令:
python3 inference.py --model-path ./model_config --seed 42输出:
Prediction range: [-0.4883, 0.5000]
Prediction mean: -0.0879模型参数匹配验证:
| 指标 | 结果 | 说明 |
|---|---|---|
| 参数量 | 120.5M | 与模型配置一致 |
| 权重加载 | 全部匹配 | SwiGLU 权重正确映射 |
| 前向传播 | PASS | NPU 算子兼容 |
| 输出数值范围 | [-0.49, 0.50] | 合理分位数预测范围 |
| NaN/Inf | 无 | 数值稳定性良好 |
原模型使用以下 CUDA-only 依赖,已替换为 NPU 兼容实现:
| 原依赖 | NPU 替换方案 |
|---|---|
| flash_attn (CUDA) | PyTorch native scaled_dot_product_attention |
| xformers.ops.SwiGLU | 手写 SwiGLU (silu(gate) * up) |
| dropout_layer_norm (CUDA) | nn.RMSNorm (PyTorch native) |
| rotary_emb (CUDA kernel) | 纯 PyTorch RoPE 实现 |