Repository navigation
v0.18.0
Native TorchNeuron dispatch (Trn2/Trn3) alongside the PyTorch/XLA path (Trn1, maintenance); validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.0) — see trnsci/trnsci#35.
Headline performance: native "auto" routes to aten on the device, and the planner contraction-order fix takes the DF-MP2 AO→MO transform (mi,na,mnP->iaP, nb=256) from 70 to 1.16 ms (#49).
Changed
- Native dispatch thresholds are now measured (#41). They were measured
on trn2.3xlarge (SDK 2.33, NKI 0.7.0) withscripts/bench_native_einsum.py
andscripts/autotune_dispatch.py.- On device-resident operands, aten
torch.matmul/torch.bmmbeat the
NKI matmul and batched-matmul kernels at every size (128³ to 4096³, fp32
and bf16). The native pinned threshold now defaults tonever, so
device work runs as aten onneuron. - Host operands at or above
TRNTENSOR_MIN_NKI_FLOPS_NATIVE(now
500 M multiply-adds, previously a provisional 1 G) are offloaded to
aten on the device instead of to the NKI kernel. - Thresholds accept
never/inf. - The XLA path is unchanged.
- On device-resident operands, aten
- Native
"auto"runs the fused quantum primitives as aten. This covers
mp2_energyandao_to_mo_transform. On Trn2 the AO→MO kernel measured
6–20× slower than aten, and the MP2 kernel 1.0–1.5× slower.
set_backend("nki")still runs both kernels, and the XLA path is
unchanged. mp2_energyreference path is vectorized. Without NKI it now uses
aten ops chunked overiinstead of a nocc² Python loop. That is 10–40×
faster on device. On an Apple M-series CPU it is 3× faster at small sizes
and about even (±10%) atnocc=32, nvir=128, naux=512.ao_to_mo_transformreference path is now two explicit binary
contractions.
Fixed
- Greedy contraction path no longer starts with an outer product. For
example,einsum("mi,na,mnP->iaP")used to contractmi,nafirst,
building a 4-index intermediate. Pairs that share an index are now
preferred. scripts/autotune_dispatch.pynow reports M·K·N, the quantity dispatch
compares, where it used to report 2·M·K·N. On the native path it now
derives both thresholds: host vs device offload, and NKI vs aten on device.