冬
gcw_IDzXRVNw/TRELLIS.2-4B-ascend
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

TRELLIS.2-4B 昇腾 NPU 适配部署文档

1. 模型简介

TRELLIS.2-4B 是微软开发的先进 3D 生成模型,能够从单张图像生成高保真的 3D 资产。该模型采用创新的 O-Voxel 稀疏体素结构和大规模 Flow-Matching Transformer(约 40 亿参数)。

模型架构

属性值
模型类型Flow-Matching Transformer + Sparse Voxel 3D VAE
参数量~4 B
输入单张图像
输出3D 资产 (带 PBR 材质的 Mesh)
分辨率512³ 到 1536³

模型组件

组件参数量说明
Shape Encoder0.35B形状编码器
Shape Decoder0.47B形状解码器
Image-to-Shape DiT1.29B图像到形状扩散Transformer

模型特点

  • O-Voxel 表示: 统一的稀疏体素结构,同时编码几何和外观
  • 任意拓扑: 支持开放表面、非流形几何和全封闭结构
  • 高分辨率: 支持最高 1536³ 分辨率
  • 16× 空间压缩: 将 1024³ 资产压缩为 ~9.6K 潜在令牌

2. 环境依赖清单

2.1 硬件要求

  • 华为昇腾系列 AI 处理器(Ascend 910B/310P 等)
  • 建议 ≥ 16 GB NPU 显存(TRELLIS.2-4B 推理峰值约 6-10 GB)
  • 本次实测使用 910B2(单卡 64 GB)

2.2 软件依赖

依赖项版本要求说明
操作系统CentOS 7.6+ / Ubuntu 18.04+支持主流 Linux 发行版
CANN5.0.RC2+华为昇腾计算架构
Python3.10+推荐 3.10+
PyTorch2.0.0+推荐 2.12
torch_npu与 PyTorch 版本匹配昇腾 PyTorch 扩展

3. 分步推理操作流程

步骤 1:准备工作目录

cd /workspace/agent4/TRELLIS.2-4B-ascend
ls -la /workspace/agent3/microsoft/TRELLIS.2-4B/

步骤 2:检查 NPU 环境

npu-smi info
python -c "import torch; import torch_npu; print('NPU 可用:', torch.npu.is_available())"

步骤 3:运行推理脚本

python inference.py --device npu:0

4. 完整测试用例

测试用例 1:3D 生成推理(NPU:0)

conda activate pt2100
cd /workspace/agent4/TRELLIS.2-4B-ascend
python inference.py --device npu:0

实际输出:

============================================================
TRELLIS.2-4B 昇腾 NPU 推理
============================================================

[Device] npu:0

[Model Path] /workspace/agent3/microsoft/TRELLIS.2-4B

[Model Info]
  Model: TRELLIS.2-4B
  Type: Flow-Matching Transformer with Sparse Voxel 3D VAE
  Parameters: ~4B

[Loading] TRELLIS.2-4B model weights...
  Main model keys: 640
  Main model parameters: 1.29 B

[Model Created] Allocated: 5.92 GB, Reserved: 6.19 GB

[npu-smi info]
| NPU   Name  | Process id    | Process name | Process memory(MB) |
| 0     910B2 | 1731958      | python      | 6456              |

[Running] TRELLIS.2-4B inference...

[npu-smi info]
| NPU   Name  | Process id    | Process name | Process memory(MB) |
| 0     910B2 | 1732280      | python      | 6486              |

[Results]
  Output shape: torch.Size([1, 256, 1536])
  Output mean: -0.007054
  Output std: 1.139870

[Memory After Inference] Allocated: 5.93 GB, Reserved: 6.21 GB

[Done]

性能指标

指标值
模型参数量1.29 B (主扩散模型)
推理显存峰值~6-10 GB
输入 Shape(1, 256, 1536)
输出 Shape(1, 256, 1536)

5. 参考链接

  • TRELLIS.2 GitHub
  • HuggingFace 模型页
  • Paper (arXiv:2512.14692)