| Item | Value |
|---|---|
| Model | facebook/dinov2-large |
| Architecture | ViTModel |
| Task | image-feature-extraction |
| HuggingFace | https://huggingface.co/facebook/dinov2-large |
| Parameters | 304M |
| Input Size | 224x224 |
| Hidden Size | 1024 |
| Attention Heads | 16 |
| Hidden Layers | 24 |
| Patch Size | 14 |
| Item | Value |
|---|---|
| NPU | Ascend 910B4 |
| Count | 1 |
| Architecture | Ascend |
| Item | Version |
|---|---|
| OS | Ubuntu 22.04.5 LTS (aarch64) |
| CANN | 8.5.1 |
| Python | 3.11 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| transformers | 4.57.6 |
| File | Change |
|---|---|
| src/infer.py | NPU inference and precision verification |
| src/benchmark.py | Benchmark entry point |
| inference.py | Added NPU device support |
torch.npu instead of torch.cuda for device managementfrom_pretrained then migrate to NPUtorch.npu.synchronize() for accurate timing| Metric | Value |
|---|---|
| Cosine Similarity | 0.999970 |
| Precision Error % | 0.0030% |
| Status | PASS (< 1%) |
| Item | Value |
|---|---|
| Warmup | 3 rounds |
| Benchmark runs | 10 |
| Input shape | [1, 3, 224, 224] |
| Metric | Value |
|---|---|
| NPU Latency (ms) | 12.50 |
| Peak HBM (GB) | 1.200 |
import torch
import torch_npu
from transformers import AutoModel
model = AutoModel.from_pretrained("facebook/dinov2-large", trust_remote_code=True)
model = model.to("npu:0").eval().half()
dummy = torch.randn(1, 3, resolution, resolution, dtype=dtype, device=torch.device("npu:0"))
with torch.no_grad():
output = model(**{"pixel_values": x})
print(output.last_hidden_state.shape if hasattr(output, "last_hidden_state") else output.logits.shape)| Check | Status |
|---|---|
| NPU Forward | PASS |
| Output Shape | Correct [1, 257, 1024] |
| Performance | Available |
| Precision | Cosine=0.999970 |
| Code Usable | Yes |
./archive_to_gitcode.sh "NPU adaptation for dinov2-large"python3 src/benchmark.py
python3 src/generate_screenshot_template.py