Skip to content

[Bug] AMD: GPU utilization on Windows is missing on comma-decimal locales (de-DE, fr-FR) because Get-Counter values are formatted with the host culture - #17520

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
LeoBorcherding:studio/rocm-windows-gpu-util-locale
Nov 14, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
LeoBorcherding:studio/rocm-windows-gpu-util-locale

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

On AMD Windows, Unsloth Studio reads GPU utilization from the GPU Engine performance counters through PowerShell. The value was printed with -f, which formats with the host culture, so on de-DE, fr-FR and other comma-decimal locales each sample came out as 12,5. Python's float() rejects that, every 3D engine sample was skipped, and GPU utilization showed as missing.

The counter value is now formatted with ToString([cultureinfo]::InvariantCulture), in both the shared display read and the standalone read. It's the same fix the NPU load reader in #17508 uses. Infinite, NaN and negative samples are still dropped.

Tests

test_rocm_windows_gpu_util_locale.py uses a fake PowerShell that prints comma decimals unless the script asks for the invariant culture. It covers the combined and standalone paths, filtering by adapter, comma output being skipped rather than misread, and invariant Infinity/NaN being dropped. 4 of its 6 tests fail without the fix.

Tested on Windows 11, Ryzen 9 9950X + 2x R9700: the new tests plus the existing test_rocm_windows_* suite (151 passed), and the real counter scripts run under PowerShell 5.1 with the thread culture forced to de-DE (the old format printed 12,5; the new one printed 12.5 and returned a utilization). Not run on a Windows install whose system locale is de-DE.

…t locale

Get-Counter values were formatted with -f, which uses the host culture,
so de-DE and other comma-decimal hosts printed 12,5 and every 3D engine
sample failed float(). GPU utilization on AMD Windows came back missing.
The counter value is now formatted with the invariant culture in both the
combined display read and the standalone one.
@danielhanchen danielhanchen self-assigned this Nov 13, 2026
danielhanchen added a commit that referenced this pull request Nov 13, 2026
…s since unsloth_zoo #2474 (#17686)

## Summary

The Studio MLX `dispatch` job fails on every PR it runs for (seen on the
staging run for #17520 and on #17666), because it installs the current
unsloth_zoo:

```
studio/backend/tests/test_mlx_inference_backend.py::test_the_stub_answers_every_helper_zoo_imports_from_inference
E   AssertionError: zoo imports ['_QSA_TRIM_HELD', '_ast_fingerprint', '_bindings_intact', '_resolved_bindings', '_verify_with_lazy_replay'] from mlx.inference and the stub cannot answer them
studio/backend/tests/test_mlx_inference_backend.py::test_the_stub_accepts_every_call_zoo_makes_to_an_inference_helper
E   AttributeError: _resolved_bindings
```

unslothai/unsloth-zoo#2474 (faster Qwen3.8 Flash Next decode) added a
head replay and a lazy verify to `unsloth_zoo/mlx/speculative.py`, which
import five private names from `mlx.inference`. The zoo change is
correct. This test file stands in for `unsloth_zoo.mlx.inference` with a
stub module, and these two tests exist to fail when zoo starts importing
something the stub cannot answer. That is what happened, so the stub
needs the new names.

Reproduced with zoo main on `PYTHONPATH`: both tests fail on main.

## Change

`studio/backend/tests/test_mlx_inference_backend.py`:

- `_QSA_TRIM_HELD` joins `PLAIN_HELPERS` as an empty list (no QSA cache
trims are held), next to `_FIRST_USE_WORK` and the other private names
zoo's speculative.py reads.
- `_ast_fingerprint`, `_bindings_intact`, `_resolved_bindings` and
`_verify_with_lazy_replay` join `NEUTRAL_PLAIN_HELPERS` as one
`_no_replay` stub that accepts any call and returns `None`. Their zoo
bodies need Metal and a QSA cache, so, like `_unless_failed_buffer`,
they get a do-nothing answer. Putting them in `PLAIN_HELPERS` would not
work, because that table's entries must copy zoo's bodies exactly
(`test_each_plain_helper_stub_matches_zoos_body`).

Test-only change. Extra names in the stub do not affect an older
unsloth_zoo.

## Testing

Linux, zoo main on `PYTHONPATH`, the stub and helper tests (`-k "stub or
plain_helper or unknown_zoo_helper"`):

- main: 2 failed, 10 passed, 1 skipped
- this branch: 12 passed, 1 skipped (the skip needs `mlx_lm`)
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T21:07:05.384199Z 707300a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 707300ac44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 9a37eb0 into unslothai:main Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants