guests read CPUID leaf 8000_001d even without TopologyExtensions

Aperta
#1,258 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start by reading the CPUID leaf handling for AmdTurin and AmdTurinV2, especially the 0x80000008 and 0x8000001D cache topology fields referenced in the issue. Compare those leaves with the proposed AmdTurinV3 behavior, then check the CPU platform specialization path; done means the new model reports the intended cache layout and handles TopologyExtensions as described.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug guest-os

we got a report from a customer that PyTorch <2.11 computes numerically incorrect results on amd_turin CPU platforms. PyTorch, as a refresher for people who haven't looked at any of this stuff in years (hi) uses https://github.com/uxlfoundation/oneDNN for hardware acceleration including (among other things) JITing SIMD'd kernels for the operations to be evaluated. oneDNN, then, uses https://github.com/herumi/xbyak both to learn information about the CPU that is being JIT'd to, and for actual code generation.

so, then, the problem at hand is older xbyak have an incomplete interpretation of CPUID leaves, where leaf 0x8000_001D is assumed to be meaningful even if TopologyExtensions is not set. somewhat funnily, that implementation cites ZenDNN extending its then-vendored-fork of xbyak which is where this ignoring TopologyExtensions stuff seems to have come up.

with a cleared TopologyExtensions and all-zero 8000_001D, the guest reads our zeroes as the cache topology instead of what we intended in https://github.com/oxidecomputer/propolis/issues/1152. then xbyak and forks conclude all the caches have size (0+1) * (0+1) * (0+1) * (0+1) times the number of cores sharing that cache which, you guessed it, is also 1 - well, numCores_[*] would be 0, then eax is 0, which where the "cores sharing cache" field is zero-based, so add 1 for the effective value. then with the knowledge that the L1 cache is "one byte", it seems like the jitted code in oneDNN ends up doing something wrong - I don't really understand the details here - and results in numerically incorrect results rather than an explicit failure. this seems like a bug in oneDNN which probably still exists, but probably is only reachable if you're doing "interesting" things around CPUID bits.

more recent xbyak has a reworked cache topology detection which is still interpreting the leaves we offer in AmdTurin/AmdTurinV2 incorrectly, but in a way that does not produce the same incorrect outputs. we offer an extended CPUID leaf limit of 0x80000021, which is above the 0x8000001D threshold in the source. taking this as truth, ignoring the non-presence of TopologyExtensions, xbyak tries to walk the 0x8000_001D subleaves, finds the first leaf reports a null cache, and returns with dataCacheLevels_ == 0 (and the array of sizes all zeroes). so when PyTorch 2.11 and later which produce correct results, it's because oneDNN per_core_cache_size() has a fallback for the case of "zero cache levels" which picks a normal cache size.

what we ought to do here is probably an AmdTurinV3 that repeats the cache layout in 8000_0008 into 8000_001D leaves, regardless of TopologyExtensions being set or not. then, when we're picking what CPUID leaves need specialization (propolis#1237 will get this configurable in the propolis-server API) we'll have to flip on the TopologyExtensions bit and fill in cores as appropriate.

the radius of affected software is kind of everything built on oneDNN/ZenDNN - there's PyTorch of course, TensorFlow, OpenVINO, and I'm sure a bunch of other related software (for example, software that links oneDNN as part of an end-user application, rather than in service of TensorFlow in a data pipeline or something). so this is pretty unfortunate.

Lingua principale
Rust
Stelle
326
Fork
49
Merge medio
1g 13h
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di oxidecomputer/propolis

Tutte le issue di oxidecomputer/propolis

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.