CogACT (Cognition-Action) is a 7B Vision-Language-Action (VLA) policy that combines:
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.
torch==2.9.0 (CPU build is fine for the wrapper; NPU compute uses torch_npu)torch_npu==2.9.0.post1transformers==4.57.6numpytimm (transitive, required by PranticVision for SigLIP/DINOv2)pip install -r requirements.txt# Already prepared at /data/dl/cogact-base/checkpoints/CogACT-Base.pt
ls -lh /data/dl/cogact-base/checkpoints/CogACT-Base.pt # 30.5 GB# 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 4Outputs 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).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 chunkSame 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).
| Metric | Value | Threshold | Result |
|---|---|---|---|
| cosine similarity (cos_sim) | 0.9568 | > 0.95 | PASS |
| max absolute error | 1.0156 | (lower = better) | — |
| mean absolute error | 0.2289 | (lower = better) | — |
| sign-agreement rate (>0.05) | 93.27% | > 90% | PASS |
| L2 relative error | 0.2980 | (lower = better) | — |
| NPU / CPU elapsed time ratio | 0.9374 | (lower = better) | — |
Additional measurements:
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).