Skip to content

Kaggle GPU harness: an all-[N/A] listing is cannot attribute, not no GPU - #10472

Merged
danielhanchen merged 6 commits into
mainfrom
kaggle-gpu-attribution
Sep 17, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
kaggle-gpu-attribution

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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] for used_gpu_memory on 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 0 server 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:

state listing attribution
nothing on the card empty n/a
cannot attribute rows present all [N/A]
attributed rows present figures present

The fix

count_listed_pids answers 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:

  • bare CUDA context: +140 MiB
  • 270M model offloaded: +428 MiB

so the delta distinguishes the two cases the attributed figure cannot.

Also in here:

  • samples are scoped to the visible card, rather than reading whichever device is first
  • the server is stopped before the CLI baseline regardless of SKIP_UI, so the baseline is not measured against a still-running server
  • a shared card's total is no longer treated as this process's usage

Tests

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.py and test_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.

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T13:43:21.825399Z d5a9a61 Manual request
🔒 Security Review ✅ Completed 2026-09-09T19:06:17.822611Z 206eecb 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.

danielhanchen added a commit that referenced this pull request Sep 8, 2026
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@oobabooga

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Provided git ref a7d44accd61e951610cfc3261bc73cc265cec16d does not exist
ℹ️ 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".

oobabooga pushed a commit to oobabooga/unsloth-test that referenced this pull request Sep 9, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: a7d44accd6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Provided git ref a7d44accd61e951610cfc3261bc73cc265cec16d does not exist
ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 206eecbb88

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 206eecbb88

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
oobabooga pushed a commit to oobabooga/unsloth-test that referenced this pull request Sep 9, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

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. tests/kaggle/test_studio_cli_run.py and tests/kaggle/test_studio_gpu_harness.py are 203 passed on the merge result.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: d5a9a612fc

ℹ️ 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 19ca592 into main Sep 17, 2026
0 of 21 checks passed
@danielhanchen
danielhanchen deleted the kaggle-gpu-attribution branch September 17, 2026 13:59
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…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]>
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.

3 participants