Repository navigation
Kaggle GPU harness: an all-[N/A] listing is cannot attribute, not no GPU - #10472
Conversation
…no GPU" Split out of #10282, where it was incidental: it is a GPU attribution fix in the test harness and touches no installer code. nvidia-smi --query-compute-apps lists every CUDA process but reports [N/A] for used_gpu_memory on Windows (WDDM) and on unified-memory parts such as the GB10. The harness read a listing it could not attribute as an empty listing, and concluded the model was on the CPU. It also lists a --ngl 0 server, because a CUDA build creates a context whether or not anything is offloaded, so a listing alone is not proof of offload either. count_listed_pids answers how many processes were LISTED, separately from how much memory could be attributed to them, so the three states stay distinct: nothing on the card, cannot attribute, and attributed. When attribution is unavailable the caller falls back to the device-wide delta, which does move on those parts: measured on a GB10, +140 MiB for a bare context and +428 MiB with a 270M model offloaded. Also scopes the samples to the visible card, stops the server before the CLI baseline regardless of SKIP_UI, and stops treating a shared card's total as this process's usage. 30 new tests. The one failure in test_studio_gpu_harness.py on a host that has nvidia-smi is present on main too.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
An all-[N/A] compute-apps listing means nvidia-smi cannot attribute memory, not that the card is idle, which is how WDDM and unified-memory parts report. That is a GPU attribution fix in the test harness and touches no installer code, so it reviews better on its own: #10472. These files go back to main exactly.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: deb7bca298
ℹ️ 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".
| ordinary single-payload run has an empty listing and keeps the fallback it needs, which | ||
| is the whole point of the fallback on parts that report [N/A] for everything. | ||
| """ | ||
| return bool(apps_before) or bool(listed_before) |
There was a problem hiding this comment.
Account for co-tenants that start during the measurement
Under --studio-concurrent, another admitted GPU leg can begin after the before-snapshot, but this helper declares the card unshared solely from apps_before/listed_before. If that leg allocates more than 200 MiB while the CLI server falls back to CPU on an all-[N/A] device, the new process and device-wide growth are treated as belonging to the server and cli_run_gpu_failure() returns success. The fallback needs to associate the new PID with the CLI process (or otherwise reject newly detected co-tenancy), rather than assuming an initially empty card remains exclusive for the whole launch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one.
The gap is real but it is not this PR's, and it is not in the path described. appeared/grew on main already sums every pid that showed up during the window, a leg that started after the before-snapshot included; the new fallback inherits that scope rather than widening it.
The path the item names needs two things at once: a card that reports [N/A] for every process, and --studio-concurrent. --studio-concurrent only reaches the harness from .github/scripts/kaggle_t4_ci/build_kernel.py:1761, i.e. the Kaggle two-T4 Linux lane, where nvidia-smi attributes used_gpu_memory per process normally. So apps_after is populated there and neither the apps_after is None branch nor the appeared_unattributed branch runs at all. The all-[N/A] listing is Windows WDDM and unified-memory parts, which have no concurrent lane.
Associating the new pid with the CLI process would be the right shape if the two ever met, but it is not reachable today and it is not what this change touched.
| if not selector: | ||
| # An empty CUDA_VISIBLE_DEVICES means no card is visible, not every card. | ||
| return None | ||
| return [cmd[0], "-i", selector, *cmd[1:]] |
There was a problem hiding this comment.
Map CUDA ordinals before passing them to nvidia-smi
On a heterogeneous multi-GPU host with an explicit CUDA_DEVICE_ORDER=FASTEST_FIRST, a numeric CUDA_VISIBLE_DEVICES entry is a CUDA ordinal, while nvidia-smi -i uses PCI-order physical indices. The repository documents this mismatch and preserves explicit ordering overrides in studio/backend/utils/hardware/hardware.py:45-56, and its existing SMI probes refuse numeric masks in this state at lines 2319-2342. Passing the selector through unchanged can therefore sample a different card from the one running the server, producing either a false CPU failure or evidence from an unrelated GPU; translate the ordinal to a stable UUID/PCI ID or decline the scoped sample when the index spaces do not match.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one either.
The value is not a CUDA ordinal here. build_kernel.py sets CUDA_VISIBLE_DEVICES from range(N_GPU), and N_GPU = len(GPUS) where GPUS is nvidia-smi's own --query-gpu row list (kaggle_t4_ci/build_kernel.py:713-721). It is an nvidia-smi row index on the way in, so handing it back to nvidia-smi -i is the identity, not a translation.
Nor is the reading new. visible_device_indices() and gpu_inventory() already slice nvidia-smi's rows by exactly that variable; visible_device_selector() gives -i what those two are already indexing with, and if it were wrong they would have been wrong first.
The trigger is also absent: the lanes are two identical T4s, where every ordering is the same set, and a single-GPU GB10. Nothing in the harness sets CUDA_DEVICE_ORDER.
On the citation: run_studio_gpu.py:2319-2342 is the Cloudflare tunnel driver, not an SMI probe. The real precedent is _cuda_order_matches_smi() at studio/backend/utils/hardware/hardware.py:2392, and it guards a different index space -- torch ordinals against SMI rows inside the backend, where FASTEST_FIRST genuinely applies because torch is the one enumerating.
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Merged main in to refresh CI: the red legs on this PR were from a run on 9 September, before main's own formatter and env-restore guards were fixed, so they said nothing about this branch. @codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…GPU (unslothai#10472) * Kaggle GPU harness: an all-[N/A] listing is "cannot attribute", not "no GPU" Split out of unslothai#10282, where it was incidental: it is a GPU attribution fix in the test harness and touches no installer code. nvidia-smi --query-compute-apps lists every CUDA process but reports [N/A] for used_gpu_memory on Windows (WDDM) and on unified-memory parts such as the GB10. The harness read a listing it could not attribute as an empty listing, and concluded the model was on the CPU. It also lists a --ngl 0 server, because a CUDA build creates a context whether or not anything is offloaded, so a listing alone is not proof of offload either. count_listed_pids answers how many processes were LISTED, separately from how much memory could be attributed to them, so the three states stay distinct: nothing on the card, cannot attribute, and attributed. When attribution is unavailable the caller falls back to the device-wide delta, which does move on those parts: measured on a GB10, +140 MiB for a bare context and +428 MiB with a 270M model offloaded. Also scopes the samples to the visible card, stops the server before the CLI baseline regardless of SKIP_UI, and stops treating a shared card's total as this process's usage. 30 new tests. The one failure in test_studio_gpu_harness.py on a host that has nvidia-smi is present on main too. * Wait for the card to settle between stopping the server and the CLI baseline * Exclude every pre-launch pid, and stop the device total overruling an attributed one * Require the device total to hold still for two intervals before calling it settled --------- Co-authored-by: oobabooga <[email protected]> Co-authored-by: oobabooga <[email protected]> Co-authored-by: danielhanchen <[email protected]>
What this is
A GPU attribution fix in the Kaggle test harness, split out of #10282 where it was incidental. It touches no installer code and is reviewable on its own.
The problem
The harness decides whether a model is actually on the GPU by reading
nvidia-smi --query-compute-apps. That query lists every CUDA process, but it reports[N/A]forused_gpu_memoryon Windows under WDDM, and on unified-memory parts such as the GB10.The harness treated a listing it could not attribute as an empty listing, and concluded the model was running on the CPU. That is a false negative on an entire class of hardware.
The converse is also true and was also being assumed away: a
--ngl 0server appears in that listing, because a CUDA build creates a context whether or not anything is offloaded. So the presence of a row is not proof of offload either.Three states were being collapsed into two:
[N/A]The fix
count_listed_pidsanswers how many processes were listed, separately from how much memory could be attributed to them, so the middle row stops being read as the top one.When attribution is unavailable the caller falls back to the device-wide delta, which does move on these parts. Measured on a GB10:
so the delta distinguishes the two cases the attributed figure cannot.
Also in here:
SKIP_UI, so the baseline is not measured against a still-running serverTests
30 new tests, covering the header and junk rows in the CSV, a mixed listing where some rows attribute and some do not, an all-unattributed listing reading as "cannot enumerate", the visible-card scoping, and the server-stop ordering.
tests/kaggle/test_studio_gpu_harness.pyandtest_studio_cli_run.py: 189 passed here against 159 on main. The single failure,test_a_box_without_nvidia_smi_reports_no_gpu_rather_than_crashing, fails identically on main on any host that has nvidia-smi installed.