Repository navigation
Kaggle T4: let the Studio GPU payload share a card instead of waiting for the drain - #9596
danielhanchen wants to merge 33 commits into
Conversation
… for the drain The merged kernel runs Studio's GPU half only after every training leg has released its card. Measured on run 32626562583 that is a real cost: the makespan floor is Studio's own serial chain (258s install + 339s test = 597s), the legs have slack against it, and 184.2s of card idle is forced. --studio-concurrent gives Studio its own lane that admits itself through the SAME VRAM gate the legs use, so it can take a card while a small leg is still on it. Studio is priced at 2.2 GB; the small legs measure 0.70 GB and gptoss 12.78 GB against a 13.0 GB per-card budget, so the gate arithmetically forbids the one pairing that matters: 12.78 + 2.2 is 14.98, and a card shared with gptoss is how the contention came back as an OOM that read like a code failure. Also flips PREFETCH_REPOS to Qwen-first. Three of four legs plus Studio's training assertion want the small model and the first of them starts at t=0, so it is the fetch with no lead time in front of it; gpt-oss does not start until the second wave and has ~190s of window to use. The guard is driven with gptoss as the only leg so the placement is deterministic. An earlier version used all four and asserted on recorded overlaps, which was vacuous: the small legs finished while Studio was still building its venv, so no overlap was ever recorded and deleting the VRAM check left the test green.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a58bf58a6b
ℹ️ 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".
| "--studio-concurrent", | ||
| action = "store_true", |
There was a problem hiding this comment.
Pass the concurrency flag from the workflow
The new option defaults to false, but the sole production invocation in .github/workflows/kaggle-t4-notebook-ci.yml:796-806 still passes only --with-studio; a repo-wide search finds no other non-test caller of --studio-concurrent. Consequently every normal T4 CI build keeps AFTER_GPU_CONCURRENT false and Studio still waits for the full queue drain, so the commit's main scheduling change is never exercised or measured.
Useful? React with 👍 / 👎.
| try: | ||
| print("{DRIVER_SENTINEL}_AFTER_GPU_SHARED " + json.dumps( | ||
| {{"payload": AFTER_GPU, "gpu": chosen}}), flush=True) | ||
| run_one(AFTER_GPU, chosen, len(ORDER) + 1) |
There was a problem hiding this comment.
Isolate Studio's VRAM probe from co-scheduled legs
When concurrency is enabled, this deliberately runs Studio while another payload may be changing VRAM on the same card, but tests/kaggle/studio_gpu/run_studio_gpu.py:174-190 measures total device memory via nvidia-smi, and gpu_assert.py:327-335 accepts a sufficiently large device-wide increase as the only positive proof of GPU offload. A training leg allocating during Studio's before/after load window can therefore make a CPU fallback with no llama/process evidence pass, while a leg releasing memory can hide a valid load; the probe must be scoped to Studio's processes or disabled as verdict evidence while sharing.
Useful? React with 👍 / 👎.
…ore any worker sees it Run 32667451396 went green while doing three things wrong. The prefetch fetched unsloth/gpt-oss-20b. That is an MXFP4 checkpoint, sm_75 cannot read MXFP4, and unsloth redirects to -unsloth-bnb-4bit at load time, so 55.1 GB was downloaded that no leg ever opens while the leg fetched the real one for itself. The guard that should have caught this compared the list against the payload's DEFAULT_MODEL, which is the name asked for and not the one loaded, so it agreed with the bug. LOAD_REDIRECTS now records the redirect, the guard applies it, and a second assertion pins that the redirect being claimed is one the payload actually shows. The prefetch also had no allow_patterns, so Qwen3.5-2B-GGUF came down entire: 69.1 GB of every quant in the repo to serve the one UD-Q4_K_XL file Studio loads. The variant is read off argv next to the model names, for the same reason they are - a hardcoded quant would filter on the wrong one the moment a dispatch overrode it. The glob is loose at both ends because a split GGUF is named ...UD-Q4_K_XL-00001-of-00002.gguf. Together that is ~128 GB fetched to serve ~14 GB of weights on a 4-core box, and it shows up in the durations: the Studio install went 258s to 673.5s and the legs went 180-384s to 691-780s. Third, control and gptoss shared one card for 691s - 13.48 GB against a 13.0 GB budget. A seed's seat was taken inside its own worker, AFTER a 5s start stagger, so card 1 sat unreserved while a free worker looked at it, saw an empty card and put gptoss there. When the seed worker woke, _admit correctly refused and the caller discarded the answer. Seats are now taken before any worker thread exists. test_no_card_is_ever_asked_to_hold_more_than_it_has asserts that exact budget and passed throughout, because with default stub durations every leg finishes inside the 5s stagger and no overlap is ever recorded. The new guard picks durations that hold the window open instead. Prefetch order goes Qwen-first here too. Three legs and Studio's training assertion want the small model and the first of them starts at t=0, so it is the only fetch with no lead time in front of it.
…le/working Venvs moved to /tmp because co-scheduling made four torch-bearing venvs possible at once and four do not fit in the 19.5 GB /kaggle/working, which is also the shipped artifact. The fallback for a box with no writable /tmp says it keeps a one-leg-per-card run working, but MAX_LEGS_PER_CARD was a plain constant, so the fallback put the venvs back on the small partition and went on building two per card anyway. That is the exact configuration the comment above it says does not fit, and it would have surfaced as an install dying halfway through for reasons that look nothing like a full disk. The guard exercises the real branch rather than simulating it: the preferred root is pointed at a path whose parent is a regular file, so mkdir raises OSError exactly as it would on such a box. Rewriting the literal straight to WORK would only have tested an assignment. Found while accounting for disk on run 32667451396. Disk was never the binding constraint there - the 128 GB prefetch landed on the ~1 TB overlay, and the Studio payload's own two free-space readings bracket its share of it at 1093.5 GB down to 1013.7 GB. The cost was CPU and IO, not space. This is the one place where space could actually have bitten.
The flag has existed since the branch was opened, is threaded from the CLI all the way to AFTER_GPU_CONCURRENT, and had unit tests. The workflow never passed it, so on hardware it was dead code. That cost a run. 32674263571 was dispatched as the VARIANT of an A/B on exactly this behaviour: it built with AFTER_GPU_CONCURRENT False, ran the control's schedule, and the comparison was a configuration against itself. Nothing went red. AFTER_GPU_SHARED was simply absent from kernel.log, and an absent sentinel is not something a green tick reports. It is a dispatch input defaulting to false rather than the new shape. Sharing costs the property that Studio chooses its own card out of two, which the Studio builder keeps on purpose, so it has to be asked for. The run that asks prints a notice saying what coverage it gave up. The guard asserts the whole chain - input exists, defaults false, something converts it to the flag, the flag reaches the build command, and the spelling matches what the CLI defines. Dropping $STUDIO_CONCURRENT from the build command, flipping the default, and removing the input are all caught. Not useless, that run: two executions of the same schedule put run-to-run noise at 13.1s of ~1180s, 1.1%. Any scheduling claim now has to beat that.
…wheels once Two changes, and the first is a bug that predates the second. Every leg had its own venv and its own UNSLOTH_COMPILE_LOCATION, and that was assumed to be the whole story. It is not. torch and triton key their caches off $TMPDIR rather than off the interpreter: on torch 2.9.1 an unset TORCHINDUCTOR_CACHE_DIR resolves to tempfile.gettempdir()/torchinductor_$USER (torch/_inductor/runtime/cache_dir_utils.py:22) and the triton cache lands under that same directory. So four legs whose entire purpose is to install DIFFERENT transformers/TRL/peft versions and compile the same modules were sharing one /tmp/torchinductor_root. Each leg now gets its own TORCHINDUCTOR_CACHE_DIR, TRITON_CACHE_DIR and TMPDIR. Per-leg directories rather than TORCHINDUCTOR_FORCE_DISABLE_CACHES or TRITON_ALWAYS_COMPILE. Both exist and both work, but they force every leg to recompile from cold, which spends time on the critical path this kernel is being shortened along and makes the legs measure a machine no user has. Isolation is wanted here, not cache defeat. Second: every leg installs unsloth_zoo and unsloth from the same two pinned SHAs, and pip does not cache a VCS build, so run 32679427416 cloned and built both of them four times. Install was 149-191s per leg, the largest single phase of each and 41% of gpt-oss. They are built once now, before any leg starts. Synchronous, and that is the design. A background lane would lose the race it exists to win: the legs are admitted to their cards and start installing at t=0, so a wheel still building when they get there saves nothing. Studio's CPU lane starts first so its 345s overlaps the build. The spec list is DERIVED from the legs' own install groups, never declared again, so the wheel is main-plus-the-PR by construction rather than by a second copy of two SHAs that drifts silently -- a wheel built from the wrong ref installs perfectly and fails nothing. It is the INTERSECTION across legs: a spec only one leg carries is part of what that leg tests, and two legs pinning one package to different refs share nothing at all. A missing wheel falls back to the original git spec, so a failed build costs its own time and changes nothing about what is tested. Also adds per-group install timing. 'install took 191s' was all any artifact ever said, which cannot tell you which group cost it or whether this helped.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76a524c0cc
ℹ️ 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".
| # TMPDIR is set too, and it is the belt to the braces: anything else that | ||
| # resolves a cache through gettempdir() follows it without this file having | ||
| # to know the variable's name. | ||
| _leg_tmp = VENV_ROOT / ("tmp_" + pathlib.Path(name).stem) |
There was a problem hiding this comment.
Prune per-leg caches from the fallback work root
When creating /tmp/t4ci_venvs fails, VENV_ROOT falls back to /kaggle/working, so these new tmp_* directories—and the Torch/Triton caches placed inside them—land on the 19.5 GB artifact partition. Unlike venv_*, they are neither removed after each payload nor matched by the tail cell's prune patterns, so the fallback intended to keep the run working can still fill that partition and then ship potentially large compiler caches as evidence; delete each cache after its payload or include tmp_* in fallback cleanup.
Useful? React with 👍 / 👎.
… flag Two dispatches could not run side by side, which is why the last A/B compared a configuration against itself. The t4-smoke job used ONE concurrency group, and GitHub allows only one PENDING run per group -- so a second queued run cancels the first rather than queueing behind it. That killed run 32674255736. A Kaggle account allows 2 concurrent GPU sessions and this job takes one, so the cap has to be 2, and a group cannot express 'at most two'. Two explicit slots can: the input offers 1 or 2 and nothing else, so the account can never be asked for a third, and anything that is not a dispatch lands in slot 1, which is exactly the old behaviour for pushes and pull requests. The shared wheel build becomes an input, default off. Run 32689629906 measured it helping the leg that runs ALONE (gpt-oss install 191.2s -> 152.6s) and costing the three that run CONCURRENTLY (149-163s -> 319-334s) -- but that run changed the torch/triton cache layout at the same time, so neither effect is attributable to either change. Shipping it on by default would be a guess wearing a measurement's clothes. The anomaly worth recording, because it is what the next run has to explain: with git specs, three legs installing CONCURRENTLY cost 149-163s each, LESS than the 191.2s the same install cost gpt-oss running ALONE. Concurrent work being cheaper per unit than solitary work means the legs were sharing something -- pip caches a wheel built from a VCS URL under ~/.cache/pip, and HOME is shared across legs, so two of the three were very likely skipping the clone and build that the first paid for. If that is right, the build was already deduplicated and doing it up front bought nothing while adding 105.8s of serial time.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c48110c44
ℹ️ 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".
| # dispatches that name different slots genuinely run side by side. | ||
| # Everything that is not a dispatch has an empty input and lands in slot | ||
| # 1, which is exactly the old behaviour for pushes and pull requests. | ||
| group: kaggle-t4-account-notebook-${{ inputs.slot || '1' }} |
There was a problem hiding this comment.
Add the slot to workflow-level concurrency
When two workflow_dispatch runs target the same ref with different slot values—the advertised A/B scenario—they still share the workflow-level group ${{ github.workflow }}-${{ github.ref }} at lines 327-329. GitHub applies both workflow- and job-level concurrency, so one run remains queued (and additional pending runs can replace it) before this slot-specific group can enable parallelism. Include the slot in the workflow-level group or remove that outer serialization for dispatches.
Useful? React with 👍 / 👎.
| # dispatches that name different slots genuinely run side by side. | ||
| # Everything that is not a dispatch has an empty input and lands in slot | ||
| # 1, which is exactly the old behaviour for pushes and pull requests. | ||
| group: kaggle-t4-account-notebook-${{ inputs.slot || '1' }} |
There was a problem hiding this comment.
Coordinate the two slots with the Studio workflow
When slot 1 and slot 2 run on different refs while .github/workflows/kaggle-t4-studio-gpu-ci.yml is active, all three jobs belong to different concurrency groups and can attempt one kernel each against the documented two-session account cap. The gate/recheck is not an atomic reservation, and .github/scripts/kaggle_t4_ci/launch.py:578-579 immediately returns at_capacity rather than waiting or retrying, so a three-way race loses an experiment after setup. The slot arbitration needs to include the standalone Studio job or otherwise enforce the account-wide limit.
Useful? React with 👍 / 👎.
The job-level group already carried the slot, but the workflow-level one did not, so two dispatches meant to hold the account's two Kaggle session slots at once still shared a single queue position. GitHub keeps at most one PENDING run per group and discards the older one when a newer run queues, so the second dispatch cancelled the first before either started. That is what happened to run 32674255736. The guard now asserts the slot at both levels; reverting either one fails it.
Each leg currently spends 158-207s resolving its own install groups, and three of the four differ only in which transformers/TRL versions they end up with. An overlay expresses that difference directly: resolve the closure with pip --dry-run --report, filter out anything native, install the remainder --no-deps --target, and prepend it to the payload child's PYTHONPATH. Measured on a real T4 (kernel unsloth-probe-overlay-t4-r2-38ac4d): transformers==4.57.6 + trl~=0.22.0 resolves to three packages, 115.9 MB, installed in 10.0s, with transformers and trl imported from the overlay and torch still from the base. This is the mechanism Studio already ships as the .venv_t5_* sidecars in studio/backend/utils/transformers_version.py, with its stated limits: pure-Python only, and nothing may import the ambient copy first. The deny-list enforces the first; passing the path through the environment rather than editing sys.path enforces the second. No leg declares an overlay yet, so this is inert until one does. bitsandbytes is now asserted rather than assumed. It is in no dependency set this CI resolves - unsloth_zoo does not declare it at all, and git main unsloth declares only seven unconditional dependencies - so without the explicit install group a leg fails inside from_pretrained after the model download. Guards, each mutation-tested: building an overlay without exporting PYTHONPATH, dropping the deny-list so the overlay shadows torch, and removing bitsandbytes from BASE_INSTALL all turn the suite red.
Batched generation with left padding is the surface that has broken here most often and is covered by nothing: #3699 (left-padding plus caching produced incorrect output), #1066 (gibberish), #1456 (inconsistent for a self-trained model), #2138 (a release silently forced the tokenizer padding side to right during inference). After training, the payload now generates each prompt alone and then at batch sizes 2, 4 and 8, greedy throughout so any difference is padding or cache handling rather than sampling, and requires them to match. Two things are guarded that a naive version of this check would miss. Left padding only happens when prompts in a batch differ in length, so a batch of equal-length prompts agrees perfectly having never padded once. The record therefore carries the token lengths, the prompts are built with a deliberate spread, and a spread of one is itself a failure. The padding side is read twice, before and after generating, because the override in #2138 happened inside the inference path -- the value the payload sets is not evidence of the value that was used. Also failed: empty output at every batch size (agreement alone is not health, since a model emitting nothing agrees with itself), too few prompts to form the largest batch, and a missing record, which must not be indistinguishable from a passing one. That last rule caught its own fixture: _cycle() fabricates a healthy run and had no such record, so every simulated run went red. The fixture was corrected rather than the rule weakened.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc1d2faf86
ℹ️ 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".
| batched = batched_generation( | ||
| model, tokenizer, batch_prompts, max_new_tokens = args.max_new_tokens, | ||
| ) |
There was a problem hiding this comment.
Honor the batched-generation opt-out before running it
When a bisect or single-cycle debug run passes --no-check-batched-generation, this call still performs all 15 extra generation passes in every child cycle, and the parent does not propagate the opt-out to its child command; the flag only suppresses failure aggregation later. Consequently an incompatible or OOMing batched-generation path still aborts a run that explicitly disabled the check, and even healthy runs still pay its GPU-time cost. Gate construction/execution of this record on the option and pass the disabled setting to child cycles.
Useful? React with 👍 / 👎.
| # distinct slots being collapsed into a single queue position. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.slot || '1' }} |
There was a problem hiding this comment.
Reserve quota for both concurrent slots
When slot 1 and slot 2 are dispatched together with 24–28 GPU-hours remaining, this new group lets both gate jobs run concurrently, but each workflow invocation passes only --budget-hours 4 --reserve-hours 20 and gate.py independently checks remaining_hours >= budget + reserve. Neither check reserves the first run's remaining worst-case spend, so both can be approved and consume up to 8 hours, leaving as little as 16 hours despite the workflow's promised 20-hour reserve; the slot arbitration or quota calculation must account for the other active slot's outstanding budget.
Useful? React with 👍 / 👎.
…tched generation
Two Kaggle GRPO ladder probes failed four rungs each on the same FlashInfer
link, the second WITH VLLM_USE_FLASHINFER_SAMPLER=0 already set. That variable
was never wrong, it is just set at a layer that does not survive: unsloth_zoo's
patch_vllm assigns both vLLM knobs itself during model load,
vllm_utils.py:2494 VLLM_ATTENTION_BACKEND = "FLASHINFER"
vllm_utils.py:2502 VLLM_USE_FLASHINFER_SAMPLER = "1"
each behind `elif Version(vllm_version) >= Version("0.11.0")`, which the leg's
0.19.1 pin satisfies. The guard in front of them checks only that nvcc and ninja
exist; Kaggle has both, and what it lacks is the driver stub the compiled
objects then link against. UNSLOTH_VLLM_NO_FLASHINFER is read ahead of every
assignment and is the only one of the three that reaches vLLM, so the grpo leg
now carries it.
The Default leg then ran on a real T4. The overlay works under training, not
just inference: transformers 4.57.6 and trl 0.22.2 resolved from the overlay
against the image's untouched torch 2.10.0, 10 of 10 steps at 1.16 it/s. It
died after training on a NameError in batched_generation, where torch was used
without the function-local import every other torch user in that file has.
No CPU test caught that because all seven batched-generation guards feed the
rule a hand-written dict and never execute the code that produces one. The new
end-to-end test drives the real function with a stub tokenizer and model that
pad, generate and decode; removing the import reproduces the Kaggle NameError
on CPU in 0.05s. That stub immediately found a second bug in the same function:
`pad_token_id or eos_token_id` falls through whenever pad_token_id is 0, which
is an ordinary id, so batches were padded with end-of-sequence tokens.
The Default leg stays unwired until its batched-generation assertions have run
on hardware once and it has a reference band. Adding it also exposed two latent
test bugs: a partition assertion comparing two separately sorted lists, which
held only while every unwired leg sorted after every wired one, and a payload
filename interpolated from the registry key rather than from leg.name.
…that was asked for Both questions the last round left open are now answered on hardware. GRPO. The FlashInfer failure needed the package gone, not another environment variable. Round 3 established that UNSLOTH_VLLM_NO_FLASHINFER=1 does reach the child and does stop the sampler build, and that the failure simply moves to the attention prefill kernels, which are chosen by VLLM_ATTENTION_BACKEND (already TRITON_ATTN, already confirmed inherited) and for which vLLM exposes no prefill-specific opt-out. Round 4 removed flashinfer-python and flashinfer-cubin after the vLLM install, in 3.9s, and the ladder passed at the FIRST rung. So legs gain an `uninstall` field, and the env vars are kept beside it rather than replaced: they are what stops unsloth reaching for FlashInfer at all, and an image that does ship the driver stub should still take the deliberate path. gpu_memory_utilization goes 0.5 to 0.95, the value originally asked for. The 0.5 came from Qwen3-4B probes and was never measured for the 0.6B this leg trains. Measured now on both platforms, each stopping at the first rung of a 0.95/0.8/0.6/0.5 ladder with three sleep/wake cycles: Colab (torch 2.11.0) peak reserved 11.76 GB, Kaggle (torch 2.10.0) 11.30 GB, both about 3 GB under the card. Kaggle also loads in 170.0s against Colab's 465.4s, because vllm 0.19.1 pins the torch Kaggle already has, which is the whole argument for that pin. Default. At max_steps 10 Qwen3-0.6B learns the canary but not to stop after it, emitting `__UNSLOTH__!!!__`. At 20 both repeats emit it exactly and the leg passes in full, with the batched-generation contract green on a T4: four distinct prompt lengths so padding really happened, left padding observed before and after generating, and batch 2, 4 and 8 all agreeing with batch 1. --no-require-canary would have made the check vacuous; the rule was right and simply tuned against a different model. The leg is wired, which takes MAX_LEGS_PER_KERNEL from 4 to 5. That number caps wall clock rather than cards, and its own comment asks for the arithmetic: the longest column today is about 8 minutes, so about 16 with Default added, against a 12 hour session kill. Three latent test bugs surfaced while doing this. Two assertions hardcoded the leg count that ALL_FOUR derived, so the name is now ALL_LEGS and both read the registry. A second site interpolated a payload filename from the registry key rather than leg.name, the same bug fixed in the harness last round, which `default` versus `Default` is the first pair to expose.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26f4bc7555
ℹ️ 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".
| _ov_rec.setdefault("active", False) | ||
| print(f"{DRIVER_SENTINEL}_OVERLAY " + json.dumps(_ov_rec), flush=True) |
There was a problem hiding this comment.
Fail the leg when its required overlay is inactive
When the overlay dry-run or target install fails or times out—for example during a transient package-index error—this path records active: false but still launches papermill without the overlay on PYTHONPATH. The newly wired Default leg can therefore train successfully against the base transformers/TRL versions and report green even though its purpose is to test transformers==4.57.6 with trl~=0.22.0; the resolved-version table is informational and does not affect the verdict. Treat an inactive declared overlay as a leg failure, or explicitly assert the requested versions in the payload.
Useful? React with 👍 / 👎.
| args = ( | ||
| "--model", | ||
| "unsloth/Qwen3-0.6B", |
There was a problem hiding this comment.
Prefetch the Default leg's overridden model
In the production --all-kernels path, this newly wired leg loads unsloth/Qwen3-0.6B, but PREFETCH_REPOS still contains only Qwen2.5 and gpt-oss. The guard in test_the_prefetch_list_matches_the_models_the_legs_actually_load misses this because it scans only each payload script's DEFAULT_MODEL, not per-leg --model overrides. Consequently the Default leg performs its model download on its own critical path while the prefetch lane warms unrelated repositories, adding avoidable runtime and distorting the scheduler A/B measurement this commit is intended to collect.
Useful? React with 👍 / 👎.
| capture_output=True, text=True, timeout=900) | ||
| _built = sorted(p.name for p in WHEEL_DIR.glob("*.whl")) |
There was a problem hiding this comment.
Discard partial wheels after a failed shared build
When a --shared-wheels dispatch builds one VCS requirement successfully but a later requirement fails, pip copies the successful wheel into the requested wheel directory before returning nonzero for the failed build. This code inventories that partial output regardless of _proc.returncode, and _localise subsequently substitutes every wheel it finds, so the supposedly graceful fallback actually runs a mixed configuration where some legs use shared wheels and other specs are rebuilt from Git. That makes the experimental arm's timing non-attributable despite the log saying the shared build failed; remove partial outputs on a nonzero result or expose the directory only after the whole command succeeds.
Useful? React with 👍 / 👎.
Both claims were mine and both were wrong in ways a reader would have acted on. The grpo leg's comment said the driver stub is "simply absent from this image" and "not fixable from here". The leg's own report disproves it: libcuda_shim reports needed true, applied true, real /usr/local/cuda/compat/libcuda.so, and run_grpo_t4.py:597 has symlinked that onto LIBRARY_PATH since #8440. The stub exists; flashinfer's own -L paths just do not include the directory holding it, and the leg supplies it. The hand-written ladder probes had no shim, which is the likeliest reason they hit the link error while the leg does not. The flashinfer uninstall stays, because removing it demonstrably breaks the leg, but it is now documented as earning its place for a reason still being established rather than for the link error. Removing it does not reproduce a link error at all. It fails with the intermittent illegal memory access that UNWIRED["grpo"] already documents, which has not recurred with the uninstall in place. That crash runs at roughly two failures in three, so a few clean runs is suggestive and not proof; the guard asserts only that the uninstall is present and reaches the payload, and its docstring now says so explicitly rather than implying a root cause. The MAX_LEGS_PER_KERNEL comment reasoned about serial per-card columns and estimated 16 minutes. The measured five-leg kernel is 792.2s, 13.2 minutes, and the intervals show why: legs do not queue one per card. The VRAM admission lets light legs co-tenant, so frontier and canary hold gpu0 for their whole lives at 0.7 GB each, while gptoss at 12.78 GB waits for an empty card and starts at 492.7s. Admission governs, not the card count and not a queue, and a fifth heavy leg would be a different question from a fifth light one.
…ion it sees
The grpo leg's dominant failure was never the crash. Three runs with the
flashinfer uninstall in place produced no illegal memory access at all, and two
of the three still went red with
reward_std was zero on every step ([0.0, 0.0, 0.0])
which reads like a broken generation path and was really a reward that had
stopped measuring anything.
reward_length was min(len(t), 200) / 200.0, under a docstring claiming it was
"SENSITIVE to a group's diversity". It was not. Kernels
unsloth-probe-grpo-rep2-b03be8 and -rep3-bc3828 recorded completions of 2534 to
3396 characters, an order of magnitude past the cap, so every completion scored
exactly 1.0 and every group tied. The cap was set below the range the model
actually occupies, so the one region the function discriminated in was the one
region the run never visited.
Replaced with len/(len+200), which is strictly increasing on the whole domain,
maps into (0, 1) and equals 0.5 at 200 characters, so it stays informative at
every length rather than only below a threshold. At the observed lengths it now
separates: 2534 and 3396 score 0.92685 and 0.94438.
Three guards, mutation-tested by restoring the cap. Two of them fail on it; the
important detail is that they assert discrimination at the lengths actually
recorded on hardware, because the old function passes any test written with
short completions, which is how it survived review in the first place. The third
guards the other direction: genuinely identical completions should still tie,
since that is degenerate generation and the leg is right to fail on it.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d12f8d267
ℹ️ 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".
| # both passing on the FIRST rung of a 0.95/0.8/0.6/0.5 ladder, ~3 GB | ||
| # under the 14.56 GB card. The old 0.5 came from the 4B probes and | ||
| # was never measured for this model. | ||
| "0.95", |
There was a problem hiding this comment.
Match GRPO utilization to the model actually loaded
When the grpo leg is run manually or eventually re-wired, it still loads run_grpo_t4.py's default unsloth/Qwen3-4B-Base because the leg supplies no --model. The justification here instead applies the successful 0.95 measurements from a 0.6B model, while the immediately preceding evidence records that this 4B payload already OOMed at 0.9 and required 0.5 to fit. Thus the new 0.95 value restores the known OOM configuration rather than the measured 0.6B result; either pass the measured model explicitly or retain a utilization validated with the 4B default.
Useful? React with 👍 / 👎.
Every leg is meant to export to GGUF and none has any export code, so this is
the module the rest will use. It is written against a probe on real hardware
rather than against the API's shape, because two things a natural
implementation gets wrong are silent.
The GGUF is not in the directory you pass. save_pretrained_gguf("/tmp/q8p", ...)
put the merged model.safetensors (1136.9 MB) in /tmp/q8p and the actual
qwen3-0.6b.Q8_0.gguf (609.8 MB) in the sibling /tmp/q8p_gguf. Code that globs
the directory it passed finds no .gguf, raises nothing, and reports a successful
export. find_ggufs searches both and records which one held the file, and the
failure message names the sibling so a reader does not have to already know.
install_llama_cpp returns a tuple of (llama-quantize, convert_hf_to_gguf.py),
not a path to a bin directory. An earlier probe treated it as one and reported
"0 binaries", which was the probe being wrong rather than the bundle being
empty. llama_cpp_facts derives the directory from the returned paths, so a
release that changes the layout surfaces as a missing binary instead of a wrong
path, and flags a source build separately: the failure to catch is not "kernel
missing" but "kernel built from source", which is silent, correct and many
minutes on 4 vCPUs.
Running the result does not use llama-cli. It hung for its entire budget twice,
600s and then 180s with stdin closed and -no-cnv, while 16 tokens from a 610 MB
Q8_0 on CPU is seconds of work. Whatever it waits for is not stdin, so run_gguf
uses binaries that cannot be interactive: llama-bench runs a fixed workload and
exits, llama-completion is one-shot, and the second is only tried when the first
is unavailable or failed.
A model that refuses the requested quantization is not a failure. gpt-oss
answers q8_0 with "Overriding to MXFP4 format" by design, so callers pass the
set of names they accept rather than this module assuming q8_0 is universal.
Ten guards. The sibling search is executed against a real directory pair rather
than a hand-written dict, since where the file is is the whole point, and it is
mutation-tested by narrowing the search back to the passed directory.
gguf_export.py existed but nothing called it. The Default leg now exports Q8_0 and runs the result, behind --export-gguf. Off by default, unlike the batched-generation check beside it. That one is pure compute on a model already in memory; this installs llama.cpp and merges the adapter, about 40s for a 0.6B on top of a 10-46s install, so a leg opts in rather than every payload paying for it. The export runs AFTER generation, deliberately. It merges the adapter into the base weights, so exporting first would leave the canary and batched-generation checks measuring a different model from the one training produced. The leg asserts two separate things, because a GGUF that exists and cannot be loaded is the vacuous pass this directory keeps being caught by. Measured end to end on kernel unsloth-probe-gguf-run-26c758: export 35.7s, a 609.8 MB qwen3-0.6b.Q8_0.gguf in the sibling directory, then llama-bench reporting 604.15 MiB and 596.05M params at pp8 68.85 t/s and tg8 23.22 t/s, and llama-completion returning coherent text. The run check is skipped when the export produced no file, since that already failed and would otherwise be reported twice under two descriptions. --gguf-accept takes a list because a model may legitimately override the request: gpt-oss answers q8_0 with "Overriding to MXFP4 format" by design. The payload file list gains gguf_export.py, and the guard asserting the carried files are byte-identical to the repo is updated with it rather than loosened.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8bc127396
ℹ️ 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".
| "--export-gguf", | ||
| dest = "export_gguf", | ||
| action = "store_true", | ||
| default = False, |
There was a problem hiding this comment.
Forward GGUF export options to child cycles
When the newly wired Default leg supplies --export-gguf, only the parent parses it; the fresh-process command assembled at lines 1658-1686 forwards neither this flag nor the quantization options. Each child therefore retains export_gguf=False and writes gguf_export: null, after which the parent unconditionally reports GGUF export was never run for every cycle, making the production Default leg fail even when training succeeds. Forward the export flag and its associated options into each child command.
Useful? React with 👍 / 👎.
| reference = "", | ||
| ), | ||
| "default": Leg( | ||
| vram_gb = 0.7, |
There was a problem hiding this comment.
Validate Default's declared VRAM before co-scheduling it
The newly scheduled Default leg is admitted beside another payload based on this 0.7 GB value, but test_the_declared_vram_matches_what_the_legs_reported only iterates entries in tests/kaggle/t4_smoke/measured_vram.json, which contains control, canary, frontier, and gptoss but no Default entry. Thus the safeguard never checks this new declaration, even though this leg adds batched inference and GGUF export beyond the workload measured by that older evidence; if its peak exceeds 0.7 GB, the scheduler can admit an unsafe co-tenant and attribute the resulting OOM to whichever payload allocates last. Add a hardware-measured Default peak to the evidence before using this value for admission.
Useful? React with 👍 / 👎.
…d the class The export never ran. Kernel unsloth-probe-default-gguf-637565 reported "GGUF export was never run" for both cycles while the driver log showed --export-gguf right there on the command line. Cycles run in fresh child processes and the parent rebuilds their argv from an explicit list of flags. --export-gguf was added to the parser and not to that list, so it was accepted, parsed, logged, and silently dropped before reaching the process that actually runs train_once. --check-batched-generation escaped the same fate only because it defaults to True, so the child received it without being told: luck, not design. Fixed by forwarding --gguf-quantization and --gguf-accept through the value loop and --export-gguf as its own append, since a store_true option cannot ride that loop -- "--export-gguf True" is not a thing. The more useful part is the guard, which covers the class rather than this instance: it scrapes every dest the parser defines, subtracts what the child command forwards, and fails on the difference. Anything legitimately parent-only goes in PARENT_ONLY_DESTS with a stated reason, which is how --pins is handled: its check reads the collected report in the parent at run_t4_smoke.py:1741, so no child needs it. A future flag added to the parser and forgotten in the argv now fails on CPU in a tenth of a second instead of after a Kaggle session. Two narrower guards pin the store_true handling and the two value flags, and both are mutation-tested by deleting the lines they cover. Worth noting what the same run DID establish, since it is otherwise buried: the Default leg at 20 steps trained to loss 0.0 by step 19, emitted the canary exactly, agreed across batch sizes 2, 4 and 8 with four distinct prompt lengths under left padding, and both cycles were bitwise identical.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3318ef6be7
ℹ️ 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".
|
|
||
| started = time.time() | ||
| try: | ||
| model.save_pretrained_gguf(save_dir, tokenizer, quantization_method = quantization) |
There was a problem hiding this comment.
Prune each cycle's GGUF artifacts after validation
When the new Default leg enables --export-gguf, the parent runs two fresh cycles, and each call here leaves both the measured ~1.1 GB merged model.safetensors under gguf_run* and the ~610 MB GGUF in its _gguf sibling. These paths are under /kaggle/working/t4_out_Default/cycle*, but the driver's cleanup patterns match neither tree, so every production run retains more than 3 GB of reconstructible output on Kaggle's artifact partition and in its output snapshot. Remove these files after recording/running the GGUF, or add both directory shapes to the driver cleanup.
Useful? React with 👍 / 👎.
| "prebuilt": PREBUILT_MARKER in (install_output or ""), | ||
| "source_build_markers": [m for m in SOURCE_BUILD_MARKERS if m in (install_output or "")], |
There was a problem hiding this comment.
Fail when llama.cpp falls back to a source build
When install_llama_cpp() compiles llama.cpp instead of selecting the prebuilt bundle, this records prebuilt=False and the source-build markers but no failure collector ever evaluates either field: export_failures() checks only export success, file size, and quantization. The Default leg therefore remains green after paying for a source build in each of its two fresh cycles, despite this module explicitly treating avoiding that many-minute compilation as the useful assertion. Convert these facts into a failure or warning that affects the verdict.
Useful? React with 👍 / 👎.
| if any(a.get("returncode") == 0 for a in attempts.values()): | ||
| return [] |
There was a problem hiding this comment.
Verify the exported GGUF retained the trained adapter
When GGUF conversion produces a valid file but accidentally omits the LoRA merge, this predicate still passes because it accepts any runner returning zero; in the normal bundle llama-bench succeeds first, so no generated text is even attempted, and neither runner is checked for the trained canary. The resulting untouched base-model GGUF has the expected size and quantization and loads successfully, making every new export assertion green while the exported artifact has lost the training this leg is meant to preserve. Run a completion using the canary prompt and assert the trained response before accepting the export.
Useful? React with 👍 / 👎.
Update: the leg set is rebuilt and verified on real T4sSince the last review this branch grew well past the scheduler A/B it started as. Everything below is measured on hardware, one Kaggle session per claim, not inferred. The Default leg, wired
The batched assertions encode regressions this repo has actually shipped: #3699, #1066, #1456 and #2138. #2138 is why the padding side is asserted as observed after generating rather than merely set. Why the overlayMeasured on The five-leg kernel
Makespan 792.2s, 13.2 minutes. Worth noting for anyone reading the scheduler: legs do not queue one per card. The VRAM admission lets light legs co-tenant, so frontier and canary hold gpu0 for their whole lives at 0.7 GB each, while gptoss at 12.78 GB waits for an empty card.
Two bugs this found in the harness itselfA flag the parent parses and the child never sees. Cycles run in fresh child processes and the parent rebuilds their argv from an explicit list. The guard added for it covers the class rather than the instance: it scrapes every dest the parser defines, subtracts what the child command forwards, and fails on the difference, with anything legitimately parent-only listed with a reason. It immediately found A reward that had stopped measuring anything. The GRPO leg's GRPO stays unwired, and the reason changed
The load difference is the whole argument for the The leg still hits the intermittent illegal memory access, 2 of 5 sessions on the current stack. An earlier reading here that removing FlashInfer fixed it is withdrawn: three clean runs looked convincing and the fourth crashed, and one in four against one in one is not a difference five sessions can establish. The FlashInfer uninstall stays because removing it demonstrably breaks the leg, not because it is a proven cure. UpstreamThree defects found here are fixed at source rather than worked around: #9678 (a save failure whose message names nothing, and an explicit Tests
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59cfc4153d
ℹ️ 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".
| frequency_penalty: float = Field( | ||
| 0.0, | ||
| ge = -2.0, | ||
| le = 2.0, | ||
| description = ( |
There was a problem hiding this comment.
Forward new sampling controls to external providers
When a /chat/completions request selects an external provider_id or provider_type, the newly accepted frequency_penalty and logit_bias values are silently ignored: _proxy_to_external_provider omits both from _provider_kwargs, and ExternalProviderClient.stream_chat_completion has no parameters for them. Consequently OpenAI-compatible external endpoints receive their defaults even when the client explicitly requests these controls, while the same request works as documented on local backends; forward them on compatible providers or reject them instead of accepting a no-op.
Useful? React with 👍 / 👎.
💡 Codex Reviewunsloth/.github/scripts/kaggle_prefetch.py Lines 144 to 146 in ad3c5f8 When either automatic attempt times out after importing unsloth/.github/scripts/kaggle_prefetch.py Lines 117 to 120 in ad3c5f8 With the standard Hugging Face cache layout, each downloaded file exists under unsloth/.github/scripts/kaggle_prefetch.py Lines 215 to 221 in ad3c5f8 When an earlier attempt times out after completing part of the repository, ℹ️ 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". |
Two things changed since this note was last written, and they point in opposite directions. The reward saturation fix is confirmed on hardware, twice, on two accounts: reward3-045dba and crashax-b-27d9e3 both recorded non-zero reward_std on every step with frac_reward_zero_std 0.0 throughout. Under the old min(len, 200) / 200.0 every completion at the observed lengths scored exactly 1.0 and every group tied. That blocker is closed. The crash rate got worse. This note said one in four, from a four-session window that happened to open on three clean runs. Four more sessions, run in parallel across two accounts, produced three more crashes. Pooled, it is nine sessions and four illegal memory accesses: 44%. So the reason this leg stays unwired has changed. It is no longer the reward function and no longer "we have not measured it" -- it is a coin-flip red in front of every PR for a fault no reader can act on. A nightly kernel is where this belongs, and that scheduling does not exist yet. Peak was 13.39-13.40GB of 14.56 in all nine, crashed and clean alike, so memory does not separate them, and it vanishes under --cuda-launch-blocking. It survives both the flashinfer uninstall and UNSLOTH_VLLM_NO_FLASHINFER=1. Nine sessions at a 44% reproduction rate is worth filing upstream.
# Conflicts: # tests/kaggle/test_t4_ci_transport.py
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. |
|
Closing this as absorbed into #9700, not as rejected. Everything here is landing; it is landing from one branch instead of four. Why
Line-level check of each PR's own payload against #9700's tree: 634/657 added lines for #9561, 1198/1236 for #9568, 2088/2135 for #9596. Every miss was read individually and each is a line #9700 edited further; no concept is absent ( The one thing that was not absorbed, and now is
Landing these separately would mean resolving the same 15 files twice from divergent copies, and the merge could silently reinstate the symlink-following The branch is not deleted, so nothing here is lost if #9700 has to be split back up. |
Stacked on #9568. Review that first; this branch is the A/B variant of its scheduler.
What the merged kernel does today
Run
32626562583verified the pipelining claims from #9561, and in doing so made the remaining cost visible. Studio's GPU half starts only after every training leg has released its card:597s is the makespan floor. The legs have slack against it, so the idle is not something better leg packing can remove. The only way to shorten the run is to stop making Studio wait for a drain it does not need.
What this does
--studio-concurrentgives the Studio payload its own lane that admits itself through the same VRAM gate the legs use, rather than through a barrier on the card queue. It takes a card as soon as one has room, which can be while a small leg is still resident on it.Measured VRAM, from the payload notebooks rather than assumed (
tests/kaggle/t4_smoke/measured_vram.json):Studio is priced at 2.2 GB. The per-card budget is 13.0 GB, which makes the gate forbid exactly the pairing that matters: 12.78 + 2.2 is 14.98. Studio can never land beside gpt-oss. The driver's own comment records why that case is worth an arithmetic guarantee rather than a convention - a card was shared once before and the contention came back as an OOM that read like a code failure.
Two small legs plus Studio is 0.70 + 0.70 + 2.2 = 3.6 GB, which is fine.
Prefetch order flipped to Qwen first
PREFETCH_REPOSbecomes("unsloth/Qwen2.5-0.5B-Instruct", "unsloth/gpt-oss-20b").#9568 put gpt-oss first, arguing margin on the bigger repo. That argument is weaker than the one against it. Three of the four legs and Studio's training assertion all want the small model, and the first of those legs starts at t=0 - it is the fetch with no lead time in front of it at all. gpt-oss does not start until the second wave and has roughly 190s of window to use. Fetching ~1 GB first delays the 12 GB fetch by a few seconds and removes the only download that nothing can hide.
What this costs, stated rather than buried
Sharing is not free and the repo has previously decided against it in writing:
kaggle_studio_ci/build_kernel.pykeeps both T4s visible because Studio's own device selection is part of what is under test. Pinning Studio to one card gives that up.run_studio_gpu.pyasserts against four wall-clock deadlines (health_deadline,load_timeout,train_deadlineat 1200s, an export deadline). A co-resident training job puts those under contention.That is why it ships behind a flag and gets dispatched as an A/B against #9568 rather than replacing it. The numbers from both runs decide which one stays.
Guard
test_studio_concurrent_takes_a_card_gptoss_is_not_ondrives the driver with gptoss as the only leg, so the placement is deterministic rather than a race between stub durations, and asserts Studio landed on the other card.The first version of this test was vacuous and is worth recording. It used all four legs and asserted on recorded same-card overlaps; the small legs finished while Studio was still building its venv, so no overlap was ever recorded, and deleting the VRAM check entirely left the test green. Mutating
_admit(g, AFTER_GPU)toTruenow fails it.pytest tests/kaggle/test_t4_ci_transport.pyis 78 passed.Verification
A green tick is not the evidence here. Both branches get dispatched at once (the account allows two concurrent sessions and the two workflows now hold separate concurrency groups), and the comparison is read from
kernel.log: per-payload start/end intervals, the gpu index each held, the per-repo prefetch records, and the makespan against the 1134.6s measured on32626562583.