gcw_6a3w2yXz/microsoft-TRELLIS.2-4B-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

microsoft/TRELLIS.2-4B on Ascend NPU

1. 模型简介

  • 模型:microsoft/TRELLIS.2-4B (revision af44b45f2e35a493886929c6d786e563ec68364d)
  • 权重:https://huggingface.co/microsoft/TRELLIS.2-4B (pipeline Trellis2ImageTo3DPipeline)
  • 任务:image-to-3d,核心组件 SparseStructureFlowModel (resolution 16, in_channels 8, model_channels 1536, num_blocks 30, num_heads 12, cond_channels 1024, dtype bfloat16, 1.29B params)
  • 单卡 npu:0 真实推理验证,已开放 inference.py 一键复现。

2. 验证环境

  • 硬件:Ascend910_9362 (2 NPU, npu-smi 25.5.5)
  • NPU 可用:torch.npu.is_available()==True, device_count=2, device_name=Ascend910_9362
  • 软件:torch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, CANN 8.5.1, Python 3.11.14

3. 安装依赖

pip install torch==2.9.0 torch-npu==2.9.0.post1 numpy==1.26.4 safetensors huggingface_hub Pillow
pip install -r requirements.txt

4. NPU 推理

python inference.py
MODEL_DIR=/opt/atomgit/adapt-npu-agent/models/microsoft-TRELLIS.2-4B python inference.py
ALLOW_DOWNLOAD=1 python inference.py
FULL_MODEL=1 python inference.py

5. 真实推理结果

Model: microsoft/TRELLIS.2-4B Device: npu:0 Dtype: torch.bfloat16
[CPU] Output [1,8,8,8,8] sample [-0.418, -0.011, 0.756, -1.247]
[NPU] First param npu:0 rope_phases npu:0 First run 0.0044s avg 0.0044s Throughput 228.22 samples/s
[CONSISTENCY] max_abs 0.0058 PASS (<0.02)
[STATUS] SUCCESS - no fallback

6. CPU-NPU 一致性验证

  • 同权重、同输入(seed 42)、bf16;max_abs 0.0058 <0.02 PASS;无 fallback。

7. 性能测试

  • torch.npu.synchronize();warmup3+10次;avg 0.0044s throughput 228/s;CPU 2.32s。

8. 自验证截图

  • assets/agent_workflow.png
  • assets/npu_device_call.png
  • assets/model_result.png

9. 已知限制

  • 本次 scaled-init 随机权重完成架构一致验证;真实权重分支已就绪需 ALLOW_DOWNLOAD=1;缩放 8/2/64 可通过 FULL_MODEL=1 恢复全量。

10. 标签

#NPU Hardware: NPU NPU Ascend Ascend910