guests read CPUID leaf 8000_001d even without TopologyExtensions

未关闭
#1,258 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Rust
星标
326
派生
49
平均合并
1 天 13 小时
30 天内合并 PR
10

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oxidecomputer/propolis 的其他 Issue

查看 oxidecomputer/propolis 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。