gcw_mXoV1I2Z/mythos_fast
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

mythos_fast — 昇腾 NPU 适配 (Qwen2-3B · GGUF Q8_0)

本仓库为 HuggingFace 模型 Shadow0482/mythos_fast 提供昇腾 Ascend910 NPU (torch-npu) 推理适配。

  • 基础架构: Qwen2ForCausalLM (Qwen2-3B, 36 层, hidden 2048, 16 head / 2 KV head, vocab 151936)
  • 权重格式: GGUF Q8_0 (VibeThinker-3B.Q8_0.gguf),由 Unsloth 量化
  • 适配点: 用 gguf 包反量化 GGUF 张量重建 HF 状态字典;Qwen2 为 NeoX 风格 rope, GGUF 中的 q/k 权重已按 HF 布局存储(无需 llama.cpp 的 head 重排还原); 模型与输入全部迁移到 npu:0。

依赖

pip install -r requirements.txt

CLI 推理

python inference.py --img test_prompt.txt --max_new_tokens 160 --output_json result_cli.json

FastAPI 推理

python inference.py --serve --port 8001
curl -F "file=@api_test_input.txt" http://127.0.0.1:8001/predict

推理结果示例

CLI (What is the capital of France?):

The capital of France is Paris.

FastAPI (What is 2+2?):

4

文件说明

  • inference.py — 双模式推理入口(CLI + FastAPI),NPU 初始化 try-except
  • gguf_convert.py — GGUF(Q8_0) → HF state_dict 转换
  • requirements.txt — 依赖清单
  • assets/ — 适配验证证据截图(NPU 环境、CLI 推理、FastAPI 返回)