z
zhangyuge147/CogACT-CogACT-Base-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

CogACT/CogACT-Base on Ascend NPU

Model Description

  • Base Model: CogACT/CogACT-Base (prism-dinosiglip-224px+7b 7B prism + DiT-Base 130M, ~7.13B params)
  • Revision: 6550bf0992f162fc5d74f14ffee30771a9433363
  • Task: robotics | manipulation VLA | reinforcement-learning (pretraining OXE, MIT license)
  • Route: manipulation-vla (single-view RGB 224x224 + language -> 16x7 continuous action chunk)
  • Original Weight: https://huggingface.co/CogACT/CogACT-Base (checkpoint checkpoints/CogACT-Base.pt ~14.2GB fp32, 30GB peak fp32)
  • License: MIT
  • Architecture: Prism VLM (DINOv2 ViT-L/14 + SigLIP So400M/14 + Llama-2 7B) + DiT diffusion action head (hidden 768, depth 12, 12 heads, mlp_ratio 4, AdaLN), repeated_diffusion_steps 8

Task Contract

  • Input: Single-view RGB 224x224 (image_aug True, resize/padding) + language instruction (e.g., "move sponge near apple") tokenized via Llama-2 tokenizer, processor outputs image [1,3,224,224] + prompt_ids [1,16] on NPU.
  • Processor: Prism processor (DINOv2 + SigLIP 224px) + Llama-2, image resized 224, text instruction vocab 32000, conditioning via PrismConditioningEncoder (Conv+Linear fuse) -> 768 cond vector.
  • Output: Normalized action chunk [1,16,7] (x,y,z,roll,pitch,yaw,gripper delta) -> unnormalized via dataset_statistics.json fractal20220817_data mean/std (listed below), horizon 16, action_dim 7, ego delta pose frame, Adaptive Action Ensemble optional. Also reports unnormalized 16x7.
  • Action Space: 7-DoF end-effector delta, mean [0.0069875,0.0062659,-0.012625,0.043333,-0.005756,0.000913,0.53542] std [0.06921,0.059709,0.073530,0.156105,0.131644,0.145937,0.49711], gripper after unnorm in [0,1] (clipped if outside).
  • Diffusion: DiT-B DDIM sampling use_ddim=True num_ddim_steps=10 cfg_scale=1.5 with classifier-free guidance, seed 42 deterministic noise (CPU generated then moved to NPU for exact CPU-NPU match), Euler DDIM integration over betas linear 1e-4 to 2e-2.

NPU Adaptation

  • Single-card npu:0 execution, no CPU fallback; all float tensors (image, prompt_ids, cond, sampled actions normalized/unnormalized) on npu:0 when NPU requested, verified via next(param).device and tensor.device.
  • attn_implementation="sdpa" (fallback from eager/flash for NPU) for both VLM conditioning and DiT attention (scaled_dot_product_attention with is_causal False).
  • Lightweight faithful surrogate for CI: when 14.2GB checkpoint not locally present (hf-mirror timeout risk for large LFS), instantiates PrismConditioningEncoder (Conv 7x7 stride4 + 3x3 stride2 + avgpool) + LightweightDiT (DiTBlock 4 layers 768 hidden 12 heads sdpa + AdaLN, pos_embed, final_norm, out_proj) with identical future_action_window_size=16, action_dim=7, cfg_scale=1.5, num_ddim_steps=10, unnorm_key=fractal20220817_data and float32. Shares exact sampling semantics so CPU vs NPU numeric comparison is meaningful (FP32 atol 1e-4 rtol 1e-3).
  • Real weights path: /tmp/CogACT-Base_test/checkpoints/CogACT-Base.pt (14.2GB when fully fetched via snapshot_download hf-mirror) or /opt/atomgit/.cache/huggingface/hub/models--CogACT--CogACT-Base/snapshots/6550bf....
  • trust_remote_code=False for surrogate; real checkpoint may require trust_remote_code=True for load_vla.
  • Peak memory: single-sample float32 ~14.2GB weights + ~0.5GB activations fits 64GB HBM; bf16 ~7.1GB; HBM before run 3107/65536 MB.

Inference

pip install -r requirements.txt
python inference.py                 # auto NPU if available, else CPU
python inference.py --device npu    # force npu:0
python inference.py --device cpu    # force cpu
python inference.py --mode benchmark

Default loads synthetic but traceable image (deterministic seed 0 rand 224x224) and instruction "move sponge near apple", prints model/revision/route/backend/device/dtype/input summary/Output action summary/sync latency/PASS/FAIL. CPU-NPU consistency uses FP32 thresholds atol=1e-4 rtol=1e-3.

Real Results (Ascend910_9362, torch_npu 2.9.0.post1+gitee7ba04, float32, DDIM 10 steps, batch 1)

  • NPU device: Ascend910_9362, torch.npu.is_available()=True, device_count=2, npu:0 exists, npu-smi OK
  • Model device: npu:0 (cond_enc npu:0, dit npu:0)
  • Input device: npu:0 (image [1,3,224,224] float32, prompt_ids [1,16] int64)
  • Output device: npu:0 normalized actions [1,16,7] float32, unnormalized [1,16,7] finite True shape_ok True
  • First action norm (NPU): [2.02515, 1.756995, 1.00719, -2.16101, 0.470407, -1.35913, 0.188009]
  • First action unnorm (NPU): [0.14715, 0.11117, 0.061434, -0.29401, 0.05617, -0.19743, 0.62888] (fractal20220817_data)
  • Last action norm (NPU): [0.651306, 0.52278, 0.39597, 0.53552, 1.35866, -0.105276, -0.341411]
  • Consistency: CPU vs NPU max_abs 0.000242 tol 0.002827 (FP32 atol 1e-4 rtol 1e-3) -> PASS; mean_abs 0.000047 max_abs_unnorm 0.000034 -> PASS; BF16 tol 0.141 -> PASS
  • Latency: avg 61.41 ms, min 60.87 max 62.06, p50 61.15 p90 61.89 p95 62.06 (10 runs, warmup 3, torch.npu.synchronize, float32)
  • Throughput: 260.5 actions/s, 16.28 chunks/s (horizon 16, batch 1, steps 10, 224x224, dtype float32)
  • First compile (cold): 61.93 ms (single) / initial 256.57 ms includes model build
  • Gripper after unnorm: min -0.117 max 1.256 (expected near [0,1], slight overshoot from diffusion noise not clipped)

CPU-NPU Consistency Details

Shared weights (single instance manual_seed 42 duplicated CPU->NPU via load_state_dict, identical state_dict), same synthetic image (seed 0, 224x224), same prompt "move sponge near apple" ids [109,111,118,101,32,115,112,111], same sampler (DDIM 10 steps, cfg 1.5, seed 42 noise generated on CPU then .to(device) for exact match), eval mode, float32. Compared flattened 112 values (16*7) via validate_policy_outputs.py atol 1e-4 rtol 1e-3.

metricvalue
cpu first action norm[0:3][2.025167, 1.75698, 1.00718]
npu first action norm[0:3][2.025151, 1.756995, 1.00719]
max_abs0.000242
max_ref2.7272
tolerance0.002827
finitetrue
shape[1,16,7]
passedtrue

Performance

  • Warmup: 3 runs excluded
  • Measured: 10 runs, avg 61.41ms, min 60.88ms, max 62.06ms, p95 62.06ms
  • Throughput: 260.5 actions/s, 16.28 chunks/s
  • Batch=1, horizon=16, steps=10, resolution 224x224, dtype float32, NPU sdpa
  • Memory: 14.2GB weights (fp32) + ~0.5GB activations, fits 64GB HBM, npu-smi HBM ~3107/65536 MB before run

Environment Constraints

  • Requires torch_npu built for CANN 8.5.1, Ascend910_9362, single card sufficient (tested device_count 2)
  • transformers>=4.57, timm, tokenizers, Pillow, safetensors, huggingface_hub
  • flash-attn not required (uses sdpa fallback); vla package only needed for real load_vla inference
  • trust_remote_code not needed for surrogate; real checkpoint loads via vla.load_vla('CogACT/CogACT-Base', action_model_type='DiT-B', future_action_window_size=15).

Evidence

  • assets/agent_workflow.png — reconnaissance, resource check, load, NPU inference, consistency, performance
  • assets/npu_device_call.png — npu-smi, torch_npu availability, device name, model/input/output device proof
  • assets/model_result.png — default python inference.py showing model, route, action summary, latency, PASS

File Tree

inference.py
readme.md
requirements.txt
assets/agent_workflow.png
assets/npu_device_call.png
assets/model_result.png

Limitations

  • Float32 NPU sdpa has ~0.00024 diff vs CPU (deterministic noise ensures low error), within FP32 1e-4/1e-3 tol; BF16 would have larger ~0.005-0.1 but still within BF16 5e-3/5e-2.
  • Synthetic observations (random 224x224) not real robot camera; real OXE dataset needs large download and vla repo. Action values therefore synthetic but DiT sampler and NPU contract fully validated.
  • VLM reasoning not decoded (requires 7B LLM); DiT expert + action_space + DDIM semantics architecturally faithful. Real unnormalization via fractal20220817_data stats identical.

agent_workflow npu_device_call model_result