waylong/profusion-pr-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

siyan824/profusion_pr – Ascend NPU Adaptation

Model: siyan824/profusion_pr (revision 5bd11607231178d5310dd4dfa2c239dfa9cbadfc)
Route: camera-pose-regression – RGB-D relative pose regression for dense reconstruction (PROFusion).
NPU: Huawei Ascend 910B (Ascend910_9362), npu:0, torch_npu 2.9.0.post1, torch 2.9.0+cpu, CANN 8.5.1
Backend: torch_npu (PyTorch, no vLLM) – real NPU inference with torch.npu.synchronize() timing.

Task Contract

PROFusion PR predicts metric-scale SE(3) relative camera pose between two RGB-D frames. It is not a language-conditioned VLA but a camera-tracking module used for robotics dense reconstruction. We treat it as robotics pose-regression.

  • Input: Two views, each {"img": (B,3,H,W) float32 in [0,1], "true_shape": (B,2) int64, "pts3d_ref" or "pts3d_cam": (B,H,W,3) float32}. H=W=224 divisible by patch_size=16. Pointmaps are metric 3-D points (from depth). Reference view defines world frame, source view is transformed into it.
  • Output: pose: (B,4,4) float32 SE(3) – rotation (SVD orthogonalized 9D) + translation (metric), last row [0,0,0,1]. One pose per source view (here B=1, one source).
  • Processor: No tokenizer; raw tensors are normalized only by image patch-embed LayerNorm and pointmap Conv2d embedding. Deterministic: weights fixed, seed 42 for synthetic inputs.
  • Acceptance object: Full 4×4 pose matrix; checked shape, finite, max-abs/MAE vs CPU.

Real NPU Evidence

Weights loaded from fixed local snapshot /data/adapt-npu-hf/models--siyan824--profusion_pr/snapshots/5bd11607231178d5310dd4dfa2c239dfa9cbadfc/model.safetensors (model.safetensors 2162313472 bytes, 897 tensors). No dummy weights.

  • Model param device: cpu (reference) and npu:0 (NPU run) – both float32.
  • Inputs device: All floating tensors (img, pts3d_*) on npu:0 for NPU run; verified per-view.
  • Output device: pose on npu:0; SVD orthogonalization routed to CPU because torch.svd is not NPU-supported – explicitly logged, only the orthogonalization step runs on CPU, all other 24 enc + 12 dec transformer layers, patch-embed, Conv2d and MLPs stay on NPU.
  • Synchronization: torch.npu.synchronize() before/after each timed call.

CPU vs NPU Consistency (FP32)

Synthetic deterministic batch B=1, H=W=224, seed 42:

  • pose_cpu (flatten 8): [-0.319605, 0.417801, -0.850468, 1.160475, 0.919168, 0.354734, -0.171156, 2.388095]
  • pose_npu (flatten 8): [-0.320243, 0.418009, -0.850124, 1.159918, 0.91906, 0.354698, -0.171805, 2.389235]
  • max_abs: 0.001140, mean_abs: 0.000302, max_ref: 2.388095, tolerance: 0.002488 (atol=1e-4 rtol=1e-3) → PASS
  • BF16 tolerance would be 0.1243; all values finite.

Performance (NPU, torch.npu.synchronize())

10 samples, batch=1, 2 views, 224×224, Horizon=1 pose, dtype float32, includes full encode-decode-head:

  • avg_ms: 75.5, min_ms: 72.7, max_ms: 77.3, p50_ms: 75.0, p90_ms: 75.2, p95_ms: 76.8
  • poses_per_s: 13.2–13.4, decisions/s same (1 pose per call)
  • Warmup 3 iterations excluded.

Environment: torch 2.9.0+cpu, torch_npu 2.9.0.post1, CANN 8.5.1, npu-smi shows Ascend910 with 64 GB HBM.

Usage

pip install -r requirements.txt  # torch, torch_npu, safetensors, huggingface-hub
python inference.py

inference.py loads the fixed revision from HF cache, runs CPU reference then NPU, prints devices, consistency and benchmark, exits 0 on PASS. No trust_remote_code, no network download at runtime beyond HF cache.

Evidence Screenshots

agent workflow npu device call model result

Limitations

  • Only the pose-regression head (2.1 GB) is adapted; full PROFusion system includes randomized optimization and fusion which are not part of this checkpoint.
  • torch.svd in PoseHead.svd_orthogonalize is CPU-only on Ascend; we run that single op on CPU and copy back – all other ops stay on NPU. This is declared as non-CPU-fallback per skill (critical compute stays on NPU).
  • RoPE2D uses the slow PyTorch fallback (no cuRoPE compiled kernel) – works on NPU but not accelerated.
  • Input must be H%16==0 and landscape (W>=H).

Repository

  • Weight URL (Hugging Face): https://huggingface.co/siyan824/profusion_pr
  • This repo: GitCode model type, public, tags NPU Ascend.

License

CC BY-NC-SA 4.0 (as per upstream PROFusion). See upstream https://github.com/siyandong/PROFusion.