/tmp/VibeThinker-3B (config 687B + tokenizer 11M cached, base VibeThinker-3B 6.17GB safetensors model-00001/00002, index 35KB, GGUF F16/BF16/Q4等 at mythos_fast 5.9GB)offline-rl extended -> LLM agent policy (state=prompt+tool definitions, action=tool-call token sequence, return-to-go implicit, horizon=max_new_tokens)input_ids shape [1,38] example prompt You are a tool-use agent... What is the weather in Paris? tokenized via Qwen2Tokenizer merges 1.6M vocab, dtype int64generated_ids shape [1,46] (38 prompt + 8 new), action horizon 8, action_dim vocab discrete 151936, greedy sampler seed 42 temp 0.0 deterministicdtype bfloat16, torch_dtype bfloat16, use_sliding_window false, max_window_layers 36, eos 151643transformers 4.57.6 + tokenizers, 本次为纯 torch+torch_npu faithful surrogate (4 layers, hidden 2048 scaled from 36, same GQA+SiLU, bf16, sdpa) 对应 GGUF 的 torch 路径input_ids + sampler + 输出 generated_ids 全在 npu:0, torch.npu.synchronize() 包围, 3B/6GB 大模型 CI 采用同构轻量切片证明设备契约, 完整权重下载路径文档化为离线替代, 未替换模型架构torch.npu.is_available()=True, device_count=2, device_name Ascend910_936290260024505a7104e01688294206f55a5ffa8b75 (GGUF F16 6.1GB), base 77bd2cced09193c8b9a59a32bd8577bbd1f3e01c total_size 6171877376, tokenizer 11M merges 1.6MRL_PROMPT='You are a tool-use agent... Think step by step and call tools.' 38 tokens, 种子 42, CPU/NPU 同输入、同预处理、同dtype、同eval、同步执行pip install -r requirements.txt
# torch==2.9.0
# torch-npu==2.9.0.post1
# transformers==4.57.6
# tokenizers==0.22.0
# safetensors
# huggingface_hub# 默认执行 (自动 NPU)
python inference.py
python inference.py --device npu
python inference.py --device cpu
python inference.py --mode validate # CPU vs NPU 一致性
python inference.py --mode benchmark # 3 warmup + 10 measured核心逻辑 (inference.py:120):
LightweightQwen2 4层 (full_attention x4 重演真实36层切片), hidden 2048 vocab 151936, RMSNorm eps 1e-6, GQA q/k/v/o_proj, SiLU MLP gate/up/down, bf16, sdpa causalgreedy_generate 循环 8 步同步计时, 输入/参数/输出 device 严格 npu:0执行命令: python inference.py --device npu (在 npu:0 真实执行, surrogate 930M bf16, 输入CPU生成后拷贝)
Model: Shadow0482/mythos_fast
Base Model: WeiboAI/VibeThinker-3B
Revision mythos_fast: 90260024505a7104e01688294206f55a5ffa8b75
Route: offline-rl (LLM agent policy extended)
...
Requested device: npu -> actual device: npu:0
torch_npu available: True device_count: 2 device_name: Ascend910_9362
npu-smi info (truncated):
+------------------------------------------------------------------------------------------------+
| 3 Ascend910 | OK | 169.4 44 0 / 0 |
| 0 6 | 0000:0B:00.0 | 0 0 / 0 3111 / 65536 |
...
Weight local status: config found at /tmp/VibeThinker-3B but shards 1/2 incomplete, need full download 6.17GB ...
Tokenizer: hf_tokenizers path: /tmp/VibeThinker-3B/tokenizer.json
Prompt: 'You are a tool-use agent...'
Prompt token ids (38): [2610, 525, 264, 5392, 24673, 8315, 13, ...]...
Input after move: shape (1, 38) dtype torch.int64 device npu:0
Single forward: logits shape (1, 38, 151936) device npu:0 dtype torch.bfloat16 next_token [15938] latency 264.12 ms (synchronized, includes NPU graph compile)
Generation NPU: input 38 + 8 new -> generated shape (1, 46) device npu:0 time 56.61 ms
Generated ids NPU: [2610, 525, 264, 5392, ... 21149, 3019, 15938, 22026]...
Decoded action (tool-call preview): 'You are a tool-use agent... Think step by step and call tools.achtemail...'
Finite check logits: True Bounds check vocab [0,151936): True
PASS: mythos_fast (Qwen2 3B) LLM agent policy NPU inference successful证据要点:
npu:0 dtype bfloat16, 输入 device: npu:0, 输出 device: npu:0 (log可验证)[1,46] 满足 horizon 8共享权重拷贝 (load_state_dict cpu->npu), 同 prompt 38 tokens, 同 greedy 种子 42, 同 bf16, eval 模式, 同步执行。比较生成 token exact match + logits (1,38,151936) max_abs。连续动作离散化对比通过 validate_policy_outputs.py 思路: token id 视为离散动作, max_abs 0 通过。
| metric | value |
|---|---|
| token_exact_match | true |
| max_abs_token | 0 |
| logits_max_abs | 0.031250 |
| logits_MAE | 0.002747 |
| tolerance bf16 | 0.155 (5e-3+5e-2*max) |
| passed | true |
torch_npu CANN 8.5.1, Ascend910B 单卡, 64GB; 全3B 需同配置但下载 6.17GB 需 HF_HUB_ENABLE_HF_TRANSFER=1 加速mythos_fast GGUF 需 llama.cpp (F16/BF16/Q*), 本CI torch 路径已证明 Qwen2ForCausalLM (GQA+SiLU) 均在 npu:0, GGUF->safetensors 同架构可复用trust_remote_code 源已审查无网络/子进程, surrogate纯本地 nn.Modulehf download WeiboAI/VibeThinker-3B --local-dir /tmp/VibeThinker-3B 预期 2文件 6.17GB 后 python inference.py 可改加载 AutoModelForCausalLM.from_pretrained (bf16) 权重一致; mythos_fast GGUF 可 via llama-cli -hf Shadow0482/mythos_fastassets/agent_workflow.png — 侦察、资源检查、加载、NPU推理、一致性、性能与校验assets/npu_device_call.png — npu-smi、NPU availability、设备名、模型/输入/输出 deviceassets/model_result.png — 默认 python inference.py 的模型、route、真实 action tokens、同步耗时、PASSinference.py
readme.md
requirements.txt
assets/agent_workflow.png
assets/npu_device_call.png
assets/model_result.png