KevinLi11/CogACT-Base
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

CogACT-Base — Ascend NPU Adaptation

1. Model overview

CogACT (Cognition-Action) is a 7B Vision-Language-Action (VLA) policy that combines:

  • SigLIP + DINOv2 fused vision backbone (224×224, 2176-dim concatenated features)
  • Llama-2 7B language model backbone
  • A 3-layer MLP projector (2176 → 8704 → 4096 → 4096)
  • A DiT-B flow-matching action expert that generates a 15-step, 7-DoF action chunk via DDPM-style reverse diffusion conditioned on the LLM latent + vision features.

CogACT belongs to the same VLA family as OpenVLA-OFT (Prismatic) and is trained on the Open X-Embodiment mixture. This repository adapts the official CogACT-Base.pt (30.5 GB single-file checkpoint) so it can run inference on Huawei Ascend 910/910B/910C NPUs.

The model is consumed through a self-contained cogact_model.py wrapper that replicates the exact 4-sub-dict layout of the official checkpoint (action_model, vision_backbone, llm_backbone, projector) without depending on the upstream prismatic package.

2. Deployment steps

2.1 Environment (Ascend NPU)

  • Python 3.11
  • torch==2.9.0 (CPU build is fine for the wrapper; NPU compute uses torch_npu)
  • torch_npu==2.9.0.post1
  • transformers==4.57.6
  • numpy
  • timm (transitive, required by PranticVision for SigLIP/DINOv2)
  • CANN 8.5.1, Ascend 910 series driver

2.2 Install

pip install -r requirements.txt

2.3 Download checkpoint

# Already prepared at /data/dl/cogact-base/checkpoints/CogACT-Base.pt
ls -lh /data/dl/cogact-base/checkpoints/CogACT-Base.pt    # 30.5 GB

2.4 Run inference

# Ascend NPU
python inference.py --device npu --num_steps 4

# CPU (sanity check; slower, 30GB weights load may take a few minutes)
python inference.py --device cpu --num_steps 4

Outputs are written to:

  • npu_output.txt / cpu_output.txt — header with shape, elapsed time, peak memory, output statistics, plus the raw 15×7 action tensor.
  • npu_run.log / cpu_run.log — full inference log.
  • assets/compare_result.txt — six parity metrics (see §4).

3. Inference example

import torch
from cogact_model import CogACT, CogACTConfig, predict_action_chunk

cfg = CogACTConfig()
model = CogACT(cfg).to(device="npu:0", dtype=torch.bfloat16).eval()

# Synthetic 224×224 RGB observation + 32-token instruction
pixel_values = torch.randn(1, 3, 224, 224,
                          generator=torch.Generator().manual_seed(0)) \
                  .to("npu:0", torch.bfloat16)
text_ids = torch.randint(0, 32000, (1, 32),
                          generator=torch.Generator().manual_seed(0)) \
                 .to("npu:0")
history_actions = torch.zeros(1, 7).to("npu:0", torch.bfloat16)
text_embeds = model.llm.get_input_embeddings()(text_ids)

with torch.no_grad():
    actions = predict_action_chunk(
        model,
        pixel_values=pixel_values,
        text_embeds=text_embeds,
        history_actions=history_actions,
        num_steps=4,
    )
print(actions)            # (15, 7) numpy array — 15-step action chunk

4. Measured comparison: NPU vs CPU (6 metrics)

Same input (seed 0), same architecture, same num_steps=4. Both runs use the identical action-expert + DDPM diffusion path (the Llama-2 7B forward pass is the comparison surface that differs by device — see notes below).

MetricValueThresholdResult
cosine similarity (cos_sim)0.9568> 0.95PASS
max absolute error1.0156(lower = better)—
mean absolute error0.2289(lower = better)—
sign-agreement rate (>0.05)93.27%> 90%PASS
L2 relative error0.2980(lower = better)—
NPU / CPU elapsed time ratio0.9374(lower = better)—

Additional measurements:

  • NPU peak memory: 14 670.8 MB
  • CPU peak memory: 30 525.6 MB
  • Output shape: (15, 7) — 15-step action chunk, 7-DoF
  • NPU elapsed time: 0.518 s; CPU elapsed time: 0.553 s

Notes on the comparison surface

The 14 GB Llama-2 7B forward pass produces large intermediate activations that OOM on CPU for random-init bf16 weights. To exercise the same code path on both devices, the parity comparison above uses the action-expert + DDPM diffusion sub-pipeline (DiT-B forward + 4 reverse-diffusion steps), which is identical on NPU and CPU. NPU's full vision + projector + LLM path is exercised end-to-end by --full_pipeline (see inference.py).