torchnative
Guide가이드

Accelerators and NPUs가속기와 NPU

Eager devices dispatch op by op; an NPU takes a whole graph. torchnative keeps the two apart by type.

eager 장치는 op 하나씩 디스패치하고, NPU 는 그래프를 통째로 받습니다. torchnative 는 둘을 타입으로 구분합니다.

Ask what is available무엇이 가능한지 묻기

from torchnative import device

device.mps      # eager: Metal through candle
device.vulkan   # eager: our own shaders
device.npu      # compiled target: resolves to this host's NPU, or refuses

Every availability answer names the probe that produced it. npu resolves per host (Apple Neural Engine, Intel NPU, Qualcomm Hexagon) and never resolves to the CPU. Because it is a compiled target, torch.empty(2, 2, device=device.npu) cannot be spelled.

모든 가용성 답은 그것을 낸 프로브의 이름을 댑니다. npu 는 호스트마다(Apple Neural Engine, Intel NPU, Qualcomm Hexagon) 달리 해석되고, CPU 로 해석되는 일은 없습니다. 컴파일 대상이므로 torch.empty(2, 2, device=device.npu) 는 쓸 수 없습니다.

Move a model, keep the model모델을 옮겨도 모델은 그대로

model.to(device.npu)
report = model.torchnative_offload   # what was lowered, and what stayed on the CPU

.to() lowers the eligible leaves in place and returns the same nn.Module, so generate() and backward() still work. A partial offload raises a UserWarning naming what stayed behind, and lowering nothing is a refusal, not a success.

.to() 는 가능한 잎을 제자리에서 낮추고 같은 nn.Module 을 돌려주므로 generate() 와 backward() 가 그대로 됩니다. 일부만 옮겨지면 남은 것의 이름을 담은 UserWarning 이 뜨고, 아무것도 못 옮기면 성공이 아니라 거부입니다.

Where each back end stands백엔드별 현황

Back end백엔드State상태
Metal (mps)agrees computes on the real GPU; ops that would read back to the host refuse by name실제 GPU 에서 계산; 호스트로 되읽는 op 은 이름으로 거부
Vulkanagrees thirty-one ops in SPIR-V; a pretrained BERT forwards with no host readbackSPIR-V 로 31 개 op; 사전학습 BERT 가 호스트 되읽기 없이 forward
CoreML · ANEreaches a float16 graph runs on the Neural Enginefloat16 그래프가 Neural Engine 에서 실행
Intel NPU · OpenVINOwired tested against a faked device; no Intel NPU has run it가짜 장치로만 시험; 실제 Intel NPU 에서 돈 적 없음
QNN · NNAPIpartial executes on CPU reference drivers; no NPU yetCPU 참조 드라이버에서 실행; NPU 는 아직
CUDAbuilds? wired; never compiled or run배선만; 컴파일도 실행도 된 적 없음