laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augregconvnext_base_w (timm ConvNeXt-Base vision + Transformer text width 640, 12 layers, heads 10, embed_dim 640, image_size 256)vision_cfg: timm_model_name=convnext_base, timm_pool="", timm_proj=linear, image_size=256 ; text_cfg: vocab_size 49408, context_length 77, width 640, heads 10, layers 12 ; embed_dim 640 ; preprocess mean [0.48145466,0.4578275,0.40821073] std [0.26862954,0.26130258,0.27577711]open_clip_model.safetensors (717 MB) + open_clip_pytorch_model.bin (717 MB), 1.337 GiB 合计, 实际加载 safetensors via open_clipfloat32 (原始权重 float32, 单卡 Ascend910B 实测)open_clip_torch create_model_and_transforms('convnext_base_w', pretrained=local) + open_clip.get_tokenizer, 不依赖运行时下载npu-smi 25.5.5, Health OK, Power ~160W, Temp 43-44°Ctorch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, CANN 8.5.1, open_clip_torch 3.3.0, timm 1.0.28, Pillow, numpy, safetensorsnpu-smi info
python -c "import torch; import torch_npu; print(torch.npu.is_available()); print(torch.npu.get_device_name(0))"torch.npu.is_available()=True, device_name=Ascend910_9362, device_count=2, passed=true/opt/atomgit/.cache/huggingface/hub/models--laion--CLIP-convnext_base_w-laion2B-s13B-b82K-augreg/snapshots/f231e88547aac0dd86ad224432612fcf91aa4226pip install -r requirements.txt
# requirements 包含 torch, torch-npu, open_clip_torch, timm, torchvision, Pillow, numpy, safetensors, huggingface_hub, ftfy, regex, tqdm
# 已在环境中安装 torch-npu 与 CANN, 无需手动设置代理或 HF_ENDPOINT (已配置 hf-mirror)默认命令 (真实 NPU):
python inference.py
# 或显式指定本地权重目录
python inference.py --model-dir /opt/atomgit/.cache/huggingface/hub/models--laion--CLIP-convnext_base_w-laion2B-s13B-b82K-augreg/snapshots/f231e88547aac0dd86ad224432612fcf91aa4226其他模式:
python inference.py --mode validate # 完整验证 (含 CPU-NPU 一致性)
python inference.py --mode benchmark # 性能测试 (预热3次, 测试10次, torch.npu.synchronize 计时)输入契约 (固定可复现):
a photo of a cata photo of a doga red squarea photo of a birda photo of a carnpu:0, dtype float32, batch 1以下为本次在 npu:0 上 python inference.py 的真实输出 (首轮含编译):
Model: laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg
Task: zero-shot image classification / image-text retrieval (dual-encoder CLIP ConvNeXt)
Device: npu:0 torch="2.9.0+cpu" torch_npu="2.9.0.post1" NPU name="Ascend910_9362"
Requested dtype: torch.float32 batch_size="1" image_size="256"
Input: 1×3×256×256 synthetic red-square image + 5 texts
Output contract:
image_embeds: (1, 640) dtype="torch.float32" device="npu:0"
text_embeds: (5, 640) dtype="torch.float32" device="npu:0"
logits (similarity): (1, 5) dtype="torch.float32"
Inference latency (single, synchronized): 130.36 ms (first run includes NPU compilation)
Similarity (logits) raw scores (CLIP):
[0] a photo of a cat logit="26.8776" softmax="0.0000"
[1] a photo of a dog logit="25.8744" softmax="0.0000"
[2] a red square logit="37.6738" softmax="1.0000"
[3] a photo of a bird logit="26.2200" softmax="0.0000"
[4] a photo of a car logit="25.8334" softmax="0.0000"
Ranking (desc by logit):
Rank 1: [2] a red square logit="37.6738" prob="1.0000"
Rank 2: [0] a photo of a cat logit="26.8776" prob="0.0000"
Rank 3: [3] a photo of a bird logit="26.2200" prob="0.0000"
Rank 4: [1] a photo of a dog logit="25.8744" prob="0.0000"
Rank 5: [4] a photo of a car logit="25.8334" prob="0.0000"
Top-1: "a red square"
Note: CLIP uses softmax over candidates (not SigLIP sigmoid).说明:
logit_scale.exp() (100.0) 乘以归一化 embedding 点积得到 logits, 并对候选集合做 softmax 得到分布a red square 强相关, Top-1 正确且置信度 1.0, 排序完整记录可复现npu:0 真实执行, 设备与 dtype 已验证 (param device="npu:0)"相同权重、相同输入、相同预处理分别在 CPU 与 NPU 上运行, 报告:
image_embeds cosine: 0.999984
text_embeds cosine mean: 0.999997 min: 0.999996 per-text: ['0.999999', '0.999999', '0.999996', '0.999997', '0.999996']
logits max_abs_err: 0.035534 mean_abs_err: 0.015661
Top-1 CPU: [2] a red square NPU: [2] a red square (一致)
Ranking CPU: [2, 0, 3, 1, 4] NPU: [2, 0, 3, 1, 4] Top3 overlap: 3/3阈值与判定 (float32):
结论: [PASS] CPU-NPU consistency within tolerance
验证方法为单样本 smoke consistency (固定合成样例), 非完整数据集评测, 已在 inference.py 默认流程中自动执行。
计时区间前后均调用 torch.npu.synchronize(), 预热 3 次, 正式测试 10 次, batch 1, 256x256, 5 texts, float32, npu:0:
Full end-to-end: avg=24.16ms min=23.50ms max=24.72ms p50=24.37ms p90=24.48ms p95=24.60ms
Image encoder: avg=15.64ms min=15.59ms max=15.73ms
Text encoder (5 texts): avg=7.76ms min=7.34ms max=8.14ms
Similarity: avg=0.76ms
Throughput: 41.39 inferences/s (batch 1, 256x256, 5 texts, dtype torch.float32, device npu:0)
NPU memory used: 1202.3 MB / 62740 MB
First run (cold, with compilation): 130.36 ms
Stable (warm): ~23.50ms (min) to 24.16ms (avg)说明:
复现:
python inference.py --mode benchmarkassets/agent_workflow.png — 阶段日志 (下载、侦察、加载、NPU推理、验证、性能)assets/npu_device_call.png — npu-smi info、torch.npu.is_available()、设备名、模型参数设备与 dtypeassets/model_result.png — python inference.py 完整输出、任务结果、计时与 PASS/FAIL图片由 scripts/render_xterm_evidence.mjs 从本次真实日志渲染 (--style raw), 提示符为 atomgit@pod-a94f8701860f4700b161b00e290de466:~$, 不代表实际主机名。
Hardware: NPU, NPU, Ascend, Ascend910, CLIP, ConvNeXt, open_clip, vision, dual-encoder, zero-shot
laion-CLIP-convnext_base_w-laion2B-s13B-b82K-augreg-NPU/
├── inference.py
├── readme.md
├── requirements.txt
└── assets/
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png# 环境检查
npu-smi info
python -c "import torch; import torch_npu; print(torch.npu.is_available()); print(torch.npu.get_device_name(0))"
# 默认推理 (NPU)
python inference.py
# 验证 (含 CPU-NPU 一致性)
python inference.py --mode validate
# 性能
python inference.py --mode benchmark