guests read CPUID leaf 8000_001d even without TopologyExtensions

Abierto
#1,258 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
326
Forks
49
Merge medio
1 d 13 h
PR fusionados (30 d)
10

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de oxidecomputer/propolis

Todos los issues de oxidecomputer/propolis

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.