Repository navigation
Give Unsloth Studio its first CUDA coverage, on a Kaggle T4 - #8489
Conversation
The notebooks are written for a T4: sm_75, fp16 with a gradient scaler, xformers rather than flash-attention, 16GB. Nothing in CI runs on that card, so a regression that only appears there reaches users first. Adds a gated job that launches one Kaggle GPU session and runs the smoke payload once per T4. The account has a 60h weekly budget shared with other consumers, so the job is a deliberate minority consumer of it: paths filters (only 9.9% of a week's 444 main commits touch unsloth/), a ~10% sampling draw keyed on the run id so a re-run cannot reroll, a quota floor read live from Kaggle's own API, and a stand-down when the account already has a kernel in flight. Expected cost is 5-7 GPU-hours a week. Only a payload that ran on a T4 and disagreed with its assertions turns the check red. Throttling, the 2-kernel concurrency cap, a dead session or a download that would not complete are all warnings, because a free external service blocking merges would be ignored within a week. The payload asserts three things, worth different amounts. Two fresh processes must agree bitwise on per-step loss and grad_norm; that one is exact, and it is fresh processes because two in-process cycles disagreed from the first step while two processes agreed on all ten. Greedy decoding must emit the canary string exactly, which catches trained weights never reaching the generate call. Metrics must sit inside a band around a committed reference, which is a tolerance and never an equality, since fp16 reduction order moves with the driver and the libraries. Ten steps rather than three: under fp16 the scaler skips the first two overflowing steps, so a three-step run lands one real update and the canary never forms. The dataset is supplied as prompt/completion columns so the loss falls only on the answer.
Two launches on real Kaggle T4s died in the scaffolding before a training
step ran, both of them in generated code that nothing had ever parsed.
The dependency probe imported unsloth_zoo before unsloth. Zoo's __init__
ends with a find_spec("unsloth") guard and raised "Please install Unsloth
via pip install unsloth" on a session where unsloth was installed and
imported cleanly one entry later, so the payload aborted over a dependency
that was not missing. Probe unsloth first, and invalidate the import caches
after the pip installs that this interpreter did not see at startup.
The reference argument was generated as a shell fragment and spliced into
the middle of a Python list literal, with doubled braces that left ROOT
unsubstituted. The cell was a SyntaxError, and the workflow passes
--reference on every path, so no payload could ever have reported.
Verified locally by executing the regenerated run cell end to end: two
fresh processes, bitwise identical metrics, canary exact.
The concurrency check status-checked the twelve most recently run kernels, which is a sample rather than a search: a kernel that started three hours ago and is still running is missed the moment twelve newer ones have since run, and the push then fails at the account capacity cap and is reported as infra. Kaggle kills a notebook session at twelve hours, and the listing is sorted by last run time, which for an unfinished kernel is when it started (measured: a kernel pushed at 10:05:19Z lists as 10:05:19.297). So walking until the first entry older than that ceiling covers every kernel that can still be in flight, and stopping there is exhaustive rather than arbitrary. An hour of slack is added for clock skew. Two silent ways to read an unanswerable question as a green light are closed with it. Hitting the page cap now marks the survey incomplete, and a survey where no status could be read at all is unknown rather than idle. Both stand down, which is the cheap direction: the next commit draws again in minutes. On the live account this now costs three status calls instead of twelve.
The band comparison did its NaN handling by accident, and it got it wrong. Under fp16 the gradient scaler logs a NaN grad_norm on every step it skips, so a committed T4 reference genuinely contains NaN. Left to the arithmetic, abs(x - NaN) is NaN and NaN > tolerance is False, so those steps passed whatever they held, including the case the check exists for: a step that used to overflow and no longer does. Compare NaN to NaN as equal and NaN against a number as a deviation, and treat a field logged on one side only as a deviation too, since no tolerance covers a change in shape. The mapping from an out-of-band verdict to the failure list moves into reference_failures() so the path that turns the job red can be tested without a GPU. The references README now says plainly that no reference is committed, that one must not be borrowed from other hardware, and how to lift one out of a green run's evidence rather than spending a session on it. It also records a measurement: the absolute floor never engages on this trajectory. The smallest value on the ten-step curve is a loss of 0.1428 against a floor of 0.05, so the floor changes no verdict today and is kept for a configuration that does go lower.
A kernel that ends COMPLETE with no payload report is the hardest outcome to read: the summary has no metrics to show and the reason sits in an artifact nobody downloads. It is also the outcome both real T4 failures took. Kaggle returns the kernel log as a JSON array of stream records rather than as text, so the interesting line arrives split across dozens of them and reading the file directly shows a wall of JSON. Flatten it, filter to the driver and payload sentinels plus tracebacks, and fold the tail into the job summary. Checked against the evidence of a real failed run: the SyntaxError that killed it is now visible without leaving the summary.
The generated cells are now compiled on both the with-reference and without-reference paths, which is what would have caught a SyntaxError that instead cost a Kaggle session, and the dependency probe's module order is asserted. The in-flight survey gets a fake Kaggle client and the case that motivated it: one kernel still running behind forty newer finished ones, which a count-bounded scan misses and a time-bounded scan cannot. Also the window boundary, timezone-aware and missing timestamps, the page cap, and the difference between some statuses unreadable and all of them. The band check is now proved to fail rather than assumed to work: a perturbation half a band-width past the limit, a moved scaler skip pattern in both directions, a field that stopped being logged, and a length mismatch, each asserted through to the failure list. Three tests perturb the committed reference itself and skip, saying so, until one exists. 41 passed, 3 skipped.
Two of the three Kaggle sessions spent so far died on generated code that nothing had ever parsed. The compile check now builds all three paths the generator has, using the workflow's own argument list verbatim, including the one where a committed reference exists and is carried inline as a fourth file: that path becomes live the moment a green run supplies the file, and would otherwise first be exercised on Kaggle. Parsing alone is not enough. A template hole that substitutes to a bare identifier parses and then NameErrors, which costs the same session, so every cell is also checked in execution order for names nothing before it defines. Both checks were confirmed to go red: the first on the exact shell-fragment-in-a-list-literal defect that cost session three, the second on a run cell reading a name no cell binds. The carried sources are also decoded the way the kernel will decode them and compared byte for byte with the repo, so the T4 cannot quietly run something other than what is committed.
Kernel danielhanchen/unsloth-t4-ci-e3c6661f, terminal state COMPLETE, both payloads passing on their own Tesla T4 of one session. Two fresh processes agreed bitwise on all ten steps on both cards, max_abs_diff exactly 0.0 for loss and for grad_norm, and the two cards independently produced the same ten values as each other, so four processes agree rather than two. All four cycles emitted the canary exactly. The scaler skipped steps 1 to 3 every time, which is the behaviour the ten-step length exists to accommodate. The file is reports[0] of that run, copied whole by the recipe the README already documented, and nothing in it is from other hardware. One assumption the run contradicted, now recorded rather than repeated: the session had no xformers. unsloth installs --no-deps, unsloth_zoo does not carry xformers and the Kaggle image does not either, so the banner read Xformers = None and this trace is the fallback attention path. Adding xformers to the install would move these numbers and require a recapture. The floor's smallest observed value moves from 0.1428 to 0.0871, still above the 0.05 denominator floor, so the floor stays inert and the test that re-derives that keeps passing. The three tests that perturb the committed reference now run instead of skipping. 45 passed, 0 skipped.
The gate declines to launch whenever any kernel of the account is in flight, which is stricter than Kaggle's 2-kernel cap requires. That is the intended policy, so it is now a named constant with the tradeoff written next to it rather than an implicit property of the code, and a --allow-in-flight argument that cannot be raised to the cap itself. Default behaviour is unchanged. Also files the workflow under 'never' in ci-preempt.json: cancelling a run does not stop the Kaggle kernel it already pushed, and the orphan then bills quota to its own ceiling with nobody watching.
max_steps drops from 10 to 3. Measured consequence: under fp16 the gradient scaler starts at 65536 and skips every step it overflows on, and the committed reference shows steps 1, 2 and 3 all skipped, so a 3-step run of the old configuration applied zero optimizer updates. --init-loss-scale pins the scaler below the overflow point so those three steps are real updates, and optimisation_failures() fails a run whose every step was skipped rather than letting it report as training. The committed reference was captured at 10 steps and no longer describes the run. check_reference now reads the max_steps the reference records and refuses to compare across counts, as a failure with both counts named -- including when the reference does not say what it was captured at. A quiet pass there would be a green check comparing a run against a curve it has nothing to do with. The reference is therefore stale until one recapture run. The workflow gains skip_reference_band for exactly that dispatch, and the recipe is in references/README.md. Also brings the workflow onto the repo's conventions: pinned action SHAs matching the rest of CI, a workflow-level concurrency group that deliberately does not cancel in progress, a fork guard on the gate job, typed dispatch inputs and an artifact name without the run id.
The committed reference is the evidence: the fp16 scaler reports grad_norm NaN at steps 1, 2 and 3 and a finite value from step 4. It starts at 65536, halves on each overflow, and skips the step it overflowed on, so a 3-step run applies zero optimizer updates. Loss stays around 10, the canary never forms, and the band would compare three points of a curve that never moved. Shortening also saves nothing worth having: a launch costs about 0.08h and that is almost all pip install, not training. The step-count guard, the all-steps-skipped guard and --init-loss-scale all stay, since they are what makes a shorter run possible later and what stops a vacuous one reporting green. The pin is off by default so the committed reference keeps applying.
The workflow ran a single tiny SFT payload on both cards of one Kaggle
session and spent about 1.4 GPU-h a week doing it. The budget is now 40,
and the question asked of it is wider: catch regressions in trl,
transformers, accelerate, peft, bitsandbytes, torch and vllm, and catch
torch.compile falling over on sm_75.
Four legs now, two kernels of two T4s each, described once in
.github/scripts/kaggle_t4_ci/legs.py rather than restated in YAML:
control the existing tiny Qwen2.5-0.5B determinism run, pinned
canary the same run on the newest library set Unsloth's own
constraints allow
gptoss gpt-oss-20b LoRA, for torch.compile and the forced float32 path
grpo Qwen3-4B GRPO through a vLLM engine on the same card
control and canary are one instrument rather than two tests. Same payload,
same seed, same data, same step count, on the two cards of the same
session; the only difference between them is the installed versions. A red
canary beside a green control is a library release, and the job summary
already puts the two version sets side by side so the bisect is a diff
rather than an investigation. The reference band applies to the control
alone: two library sets do not produce one fp16 trajectory, so the canary
asserts what does not depend on versions instead.
The pins are evidence rather than preference. transformers and trl are the
pair the committed reference was captured with; peft, accelerate and
bitsandbytes come from probe kernels 8161ceb9 and 7ab727f1, two independent
T4 sessions that ran the identical base install and agreed. torch stays
unpinned and recorded, because it comes from the Kaggle image and replacing
it is the failure mode the grpo leg spent two probes on.
The gate now separates this workflow's own kernels from everybody else's.
It takes both of Kaggle's concurrency slots, and only when the account is
otherwise idle: one kernel belonging to anyone else still stands it down
entirely, which is the same policy as before stated at the right grain.
…eout Three probe sessions tried to run the Qwen3-4B GRPO leg on a T4 and none of them reached a training step. None of them failed for a reason to do with sm_75, memory or GRPO either: vllm==0.11.2 pins torch==2.9.0, so the leg has to replace the Kaggle image's torch, and that is what killed all three. With the image's site-packages visible, pip treats torch's pinned NVIDIA runtime packages as already satisfied by the copies belonging to 2.10, and the result is a torch that installs cleanly and cannot be imported -- libcusparseLt.so.0 first, then ncclCommWindowRegister once that one was named explicitly, identically on vllm 0.11.2 and 0.15.1. An isolated venv resolving the whole stack got further and then the session wedged. So the leg keeps its payload, its assertions and its install, and moves to legs.UNWIRED with the three kernel slugs and what each one measured. Wiring it now would make the check permanently red and spend the budget doing it. The second kernel keeps its spare T4, which costs nothing, and that is where the leg goes when the install works. The third probe also cost about an hour of quota teaching us that the push-time kernel timeout is not a budget control. Pushed with -t 5400, its own nbconvert crashed at t=406s and the session sat in RUNNING for over two hours -- past that ceiling and past the launcher's own deadline, because one status call had blocked with no socket timeout to bound it. Deleting the kernel by hand took the account's used-hours figure back down, which is the measurement that settles which control is real. The launcher now sets a socket timeout and deletes every kernel it pushed on every path out, and the workflow header says which of the three bounds is load-bearing. Sampling recomputed on the payload that actually ships: 40%, from measured per-kernel cost rather than the old estimate, with the note that wiring a fourth leg means recomputing it rather than editing one line.
Three probe sessions never reached a training step, and all three died the same way: vllm==0.11.2 pins torch==2.9.0, so the leg had to replace Kaggle's torch 2.10.0+cu128, and pip treats the image's NVIDIA runtime packages -- which belong to 2.10 -- as satisfying the new torch's pins. That imports as libcusparseLt.so.0 missing, then as libtorch_cuda.so undefined symbol ncclCommWindowRegister one package along, then as an isolated venv that spent an hour of quota resolving a CUDA stack and never produced payload output. None of that is a question about sm_75, memory or GRPO. It is one line: no vLLM release in the 0.11-0.16 range pins the torch the image ships. Releases 0.17.0 through 0.19.1 pin torch==2.10.0 exactly, so pin 0.19.1 and the leg replaces nothing, keeps system_site_packages, and installs like any other. Drop xformers with it. Its vLLM attention backend was deleted in 0.12.0, so it would be a package nothing selects. sm_75 has no FlashAttention and no FlashInfer, and the ladder in vllm/platforms/cuda.py falls through both to TRITON_ATTN; the leg names that in VLLM_ATTENTION_BACKEND so a release that reorders it goes red here rather than quietly selecting something else. 7.5 is still in CUDA_SUPPORTED_ARCHS at v0.19.1 and fp16 is a supported dtype below capability 8.0. Still unwired. Two things are static evidence rather than a run: whether 0.19.1 starts on sm_75 at all, and whether 8GB of 16-bit weights plus an engine plus a LoRA trainer fit in 14.56GB. UNWIRED says so in those words, and a test asserts the note still names the pin and still says what is unknown, so nobody wires this off prose that outlived its measurement. Also ports the vacuous-test fix from the stacked Studio branch: pre-commit.ci reformatting default=10 to default = 10 stopped the payload regex matching, so the step-count agreement check was comparing nothing.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e98eb5862f
ℹ️ 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".
| concurrency: | ||
| group: kaggle-t4-notebook-ci-account | ||
| cancel-in-progress: false |
There was a problem hiding this comment.
Serialize the gate before surveying Kaggle capacity
When either Kaggle CI workflow already has a kernel running, this workflow's gate job runs outside the shared concurrency group and gate.py::concurrency_verdict returns should_run=false after seeing the occupied account slots. The studio-gpu job therefore never reaches this concurrency block to queue, so sampled or manually forced runs are discarded rather than queued as the workflow comment promises; the shared serialization must cover the capacity survey as well as the launch job.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this. The gate standing down is the stated policy, not an accident: gate.py::concurrency_verdict says so in its own message ("standing down rather than queueing"), and the workflow's FAILURE SEMANTICS block declares "account busy" a SKIP that exits 0. The proposal is also worse than the status quo: moving the 10-minute gate job into kaggle-t4-notebook-ci-account (cancel-in-progress: false) would queue every eligible PR's gate behind a 120-minute launch, so a burst of PRs waits hours to learn it was not sampled. In the partial case the job-level group on studio-gpu still works: one notebook kernel in flight gives free = 2 - 0 - 1 = 1 >= --kernels 1, the gate passes, and the shared group serialises the push.
…ink it First probe on the re-solved install, kernel unsloth-t4-ci-e2d9ce9b. The install works: torch stayed at the image's 2.10.0+cu128, vllm 0.19.1 installed and imported, xformers was absent as intended, and the payload ran on a real Tesla T4 reporting capability 7.5 with TRITON_ATTN accepted. It reached engine construction, which is further than any earlier probe got by the whole width of the install. It died in flashinfer 0.6.6's JIT, and not for an sm_75 reason. All three .cu files compiled cleanly for -gencode=arch=compute_75,code=sm_75. The LINK failed: /usr/bin/ld: cannot find -lcuda -L/usr/local/cuda/lib64/stubs is already on the command line, so the image has no driver stub libcuda.so, only the runtime libcuda.so.1. Nothing about that is fixable from a payload. Set VLLM_USE_FLASHINFER_SAMPLER=0 so nothing JITs. The sampler has a native path, and skipping the build also saves a four-file nvcc compile inside a session billed by wall clock. UNWIRED records what the probe measured and narrows what is left to one question: whether the engine builds now.
Second probe, kernel unsloth-t4-ci-916d5986, failed identically to the first with VLLM_USE_FLASHINFER_SAMPLER=0 set. That is the informative part: the JIT is not reached only through the sampler, so switching off one consumer is whack-a-mole. The failure was never sm_75. Both sessions compiled all three .cu files cleanly for -gencode=arch=compute_75,code=sm_75 and died at the link: /usr/bin/ld: cannot find -lcuda -L/usr/local/cuda/lib64/stubs is already on the command line; the image ships no libcuda.so at all, only the versioned libcuda.so.1, and the linker will not resolve -lcuda against a soname. Normally the toolkit's driver stub fills that gap; this image has the directory and not the file. So symlink libcuda.so at the real driver in a scratch dir and put it on LIBRARY_PATH, which gcc and ld search for -l. No root, nothing written into /usr/local, and it fixes every flashinfer op rather than one. Linking against the real driver instead of a stub is correct here: the driver is present, which is the whole reason a stub would have substituted for it. Also widen the captured traceback to head AND tail. The last probe's 6000-char tail was entirely ninja's own output, so the Python frames naming the caller were exactly what got dropped. Probe 2 also measured the fit question the notebook raised: peak reserved 7.96GB of 14.56 with load_in_4bit false, so 16-bit weights are not what is short of room here.
Kernel unsloth-t4-ci-d0d480b6: the shim reported already_linkable and did nothing, and the link failed anyway. It had found libcuda.so in /usr/local/cuda/compat -- which is real, and which nothing passes with -L. The failing ninja line names /usr/local/cuda/lib64 and /usr/local/cuda/lib64/stubs, and those are the only two directories that can answer -lcuda. So the precondition now checks exactly those two, and compat becomes what it is actually good for: a symlink TARGET when ldconfig and ctypes both come up empty. A library the linker will not search for is not a library the linker can find. Two tests: one reproduces the compat-only machine and asserts the shim is built anyway, one pins the searched directory list, since widening it is precisely how the check went wrong.
The link shim works. Kernel unsloth-t4-ci-27b0dc2e reported libcuda_shim: needed true, applied true, searched [/usr/local/cuda/lib64, /usr/local/cuda/lib64/stubs], real /usr/local/cuda/compat/libcuda.so and flashinfer is gone from the failure entirely. Memory went from 7.96GB to 11.36GB of 14.56, which is the vLLM engine actually loading, and the run reached trainer.train() -> _run_epoch -> training_step. Both questions legs.UNWIRED was holding this leg for -- does vLLM start on sm_75, does it fit in 14.56GB -- are answered by that. It then failed on the payload's own gap: ValueError: Cannot use chat template functions because tokenizer.chat_template is not set unsloth/Qwen3-4B-Base is a base model and ships none. The notebook this leg comes from solves it with an SFT priming stage that installs a template before GRPO starts; this leg has no priming stage, so it sets a minimal ChatML template directly and records in the report which of the two worlds the run was in. The base model stays. GRPO on an instruct model would measure the instruct tuning as much as the run, and the payload's rewards are format-and-digit rewards a base model can move inside three steps. A test renders the template rather than matching it as a string: a template that does not render would trade a failure at step 1 for a failure at step 1 with a longer traceback.
Kernel unsloth-t4-ci-53efcc4e passed on a real Tesla T4. Step 2 logged reward_std 0.707 and grad_norm 0.772, peak 13.60GB of 14.56GB, three steps in 192s, and fast_generate returned coherent text. reward_std is the criterion rather than loss, because TRL's GRPO loss is ~0 by construction at num_iterations=1 and beta=0 and would pass on a run that learned nothing. The config in args is the one that fit, not the notebook's. Two probes with seq 2048, 4 generations, rank 32 and utilization 0.9 died in the backward at unsloth_zoo/gradient_checkpointing.py:1013, peaking at 15.97GB in 16-bit and 19.25GB in 4-bit. 4-bit alone is not the lever: it peaked HIGHER, because quantizing weights does nothing for activations while utilization 0.9 still hands vLLM ~13GB up front, and UNSLOTH_VLLM_STANDBY returns the weights during training but not the KV cache reservation. An earlier probe reported this as 'CUDA error: an illegal memory access was encountered' from empty_cache() inside vLLM standby. That was the async shadow of the same OOM; CUDA_LAUNCH_BLOCKING=1 produced the honest error. UNWIRED is now empty. The test that read its grpo entry is replaced by the invariants that outlive any one leg: every leg is wired or explained, nothing is both, and an unwired note says what is open. Two new tests pin the config and the vLLM pin, so restoring either to a value that OOMs fails here rather than on Kaggle.
An illegal memory access is reported at whatever CUDA call synchronises next, which on the first T4 GRPO run was empty_cache() inside vLLM standby, nowhere near the kernel that faulted. Re-running with this flag produced the honest error instead: torch.OutOfMemoryError in the backward. That is what turned an unexplained CUDA fault into a memory budget, and the budget is now the leg's config. The environment variables are set before the first import torch in the process rather than merely before train(), because they have to precede CUDA context creation. It serialises every kernel launch, so it stays a switch and never a default, and it is recorded in the report because it changes what a timing means.
Every Studio workflow in this repo runs on ubuntu-latest, macos-15 or windows-latest. macOS gives Metal and MLX some hardware; the CUDA path is exercised by nothing at all, and studio-inference-smoke.yml uses a 270M GGUF precisely because it has to decode on a CPU. tests/kaggle/studio_gpu installs Studio the supported way on a Kaggle T4, starts it headless, and asserts three things a CPU runner cannot: that a GGUF is actually offloaded to the GPU rather than falling back to CPU and returning text anyway, that a LoRA training run completes and leaves an adapter on disk, and that a GGUF export against a CUDA llama.cpp produces a file that loads. The repo's existing playwright_chat_ui.py then drives the browser path, last, because it stops the server on its way out. The gate and the launcher are the notebook leg's, reused unchanged: the payload prints the same report line, so the transport needed no edit. The two legs share a concurrency group because Kaggle's 2-kernel cap is per account and is not workflow-aware. Sampled at 4 percent of a filter measured at ~760 eligible invocations a week, which is ~30 launches and ~23 GPU-h against the notebook leg's 15-20 and 1.4. The rate is lower and the spend is fifteen times higher because the eligible stream is five times larger and a launch costs nine times as much; the arithmetic is in the workflow header.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
Repo tests (CPU) is red on this branch:
test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding
AssertionError: 17 file reads in the test trees touch a checked-in file
with the platform default encoding, so they break on Windows as soon as
that file gains a non-ASCII byte.
All 17 are in tests/kaggle/test_t4_smoke_harness.py, which this branch adds,
so this is ours and not inherited. The reads pull in the workflow YAML, the
smoke scripts, the committed reference JSON and ci-preempt.json, and none of
them said what encoding to read them as. On Linux that resolves to UTF-8 and
nobody notices; on a Windows runner it resolves to the ANSI code page and the
first non-ASCII byte in any of those files takes the test out with a
UnicodeDecodeError that has nothing to do with what the test is checking.
Every one now passes encoding = "utf-8", matching how the rest of the suite
spells it. Reads of files the test itself just wrote under tmp_path are left
alone: the gate only covers checked-in files, and those are ours end to end.
test_source_read_encoding.py 1 passed
tests/kaggle/test_t4_smoke_harness.py 148 passed
The only conflict was tests/kaggle/test_t4_smoke_harness.py, and both sides are the same change: name utf-8 explicitly on the two reads of the workflow YAML and ci-preempt.json. This branch already had it, wrapped by pre-commit; the base gained it in 7033d8f on one line. Kept this branch's formatting, since pre-commit would rewrite the other back to it anyway. tests/kaggle/test_t4_smoke_harness.py + test_source_read_encoding.py 149 passed
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
Kaggle's kernels/output returns the log as a JSON array of {stream_name,
time, data} records, one record per line, so no line in the file starts
with T4_SMOKE_REPORT. extract_reports read it verbatim, so the log
fallback -- the one that covers a run whose executed notebook never came
back -- recovered nothing and a failed assertion was scored as infra with
the workflow exiting 0.
report.py::kernel_log_text and collect_evidence.py::iter_text already
flatten the records; extract_reports was the reader that did not. The
records are also cut by write rather than by line, so the join has to
happen before any line splitting.
A push whose CLI stalls past the 600s ceiling says nothing about whether Kaggle took it. Kaggle can accept the push and start the kernel billing before the response is lost, and the branch returned infra while keeping neither the slug nor an inflight entry, so finish() had nothing to delete and the next launcher's orphan sweep had nothing to see. The kernel ran to its ceiling with nobody reading the result. The slug is ours and already decided at that point, so record it in the inflight registry and hand it back as orphan_slug: release_kernels deletes it on the way out, and a launcher killed first leaves the entry for the next sweep. It is deliberately not returned as slug, because the caller must not wait on a kernel that may never have been created.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
The guide named --percent 15 and --reserve-hours 25 against a 30h account; the workflow runs 40 and 20 against the 60h figure measured on 2026-08-11, and it is the only consumer of that quota today. Following the guide would have tuned the reserve from a baseline that no longer exists. Re-derived from the same live numbers as the workflow header, and says which of the two is the source of truth when they disagree.
The concurrency verdict refused only when EVERY in-window status came back
an error. One unreadable status among readable ones was treated as an idle
account, and driving concurrency_verdict with
{busy: [], own: [], foreign: [], surveyed: 2, unreadable: 1, complete: True}
returned (True, ""). That kernel can be the human session the zero-foreign
policy exists to yield to, and proceeding takes the account's last slot: the
first push wins it, the second comes back at capacity, and the run reports a
subset of its legs.
A 404 is kept separate and stays benign. A deleted kernel is not an unknown
state and the launcher deletes every kernel it pushes, so blocking on that
would wedge the gate shut rather than make it careful.
- The pull_request trigger used GitHub's default activity types, which are opened, synchronize and reopened only. The kaggle-t4-ci label the gate advertises as a human override could therefore never start a run on its own. Subscribe to labeled as well. - pyproject.toml was in neither paths filter, though every payload installs the commit under test as a distribution built from it. BUDGET.md counted it as a watched path already. - The job deadline of 120 minutes was shorter than the launcher's worst case. Two sequential pushes can take 2 x (4 x 600s + 315s of backoff) and the 5400s polling window only starts after them, so about 187 minutes with the deletions; a runner killed at 120 takes finish() -> release() with it and leaves pushed kernels billing quota. 200, with the arithmetic written down beside it. - The gate surveys quota and in-flight kernels before t4-smoke queues on the account-wide concurrency group, so a second sampled run could launch on an approval a full run old. Re-ask with the slot in hand, immediately before the push; --force true skips the sampling draw and nothing else. - --zoo-ref main let each payload's own pip resolve a different unsloth-zoo commit, including between the control and the canary within one session, and zoo is not in pins/control.txt either. Resolve it once with git ls-remote and pass that SHA to every leg. - A dispatch with max_steps != 10 still shipped the 10-step reference, and check_reference reports step_count_mismatch as a failure, so the run could only ever go red on arithmetic. Drop the band automatically when the counts differ, and say so. Also: check out the same head SHA the launcher installs, so the harness and the package under test are one snapshot rather than the merge tree and the head; and run tests/kaggle/test_t4_smoke_harness.py on the runner before anything is built or pushed, since testpaths limits pytest to tests/security and nothing else collected it.
Two ways a real payload verdict was being lost in transport, both ending in
verdict=infra and a green workflow.
The kernel log fallback could never work. Kaggle's kernels/output hands the
log over as a JSON array of {stream_name, time, data} records, which is why
report.kernel_log_text flattens it before reading; extract_reports scanned
the file as text, so no line began with the report prefix and the fallback
that exists for the run whose notebook never came back found nothing. Record
boundaries are not line boundaries either, so the records are joined before
the scan rather than read one at a time.
push() documented a fresh slug per attempt and used one for all four. Pushing
to an id that already exists does not replace it: Kaggle files a new version
and starts a second batch session, and kernels status and kernels/output send
no version label, so they answer for the newest session only. A retry after a
lost response therefore collected the wrong execution's evidence while the
first kept a session slot and billed unseen. Each attempt now takes its own
slug and discards the previous one first, and every slug filed is returned
and recorded, since a push that reported an error may still have landed.
Four ways the two payloads of one kernel were not actually isolated, plus the import probe exiting without a verdict. The probe was the P1. When the commit under test breaks import unsloth, the verify cell raises before the run cell can write a report, the launcher extracts none, and no reports is classified as infra -- so a deterministic import regression exits green. A probe failure is a verdict, not missing evidence, so it now emits its own failing report. nvidia-smi failing or a one-GPU allocation fell back to N_GPU = 1 and pinned both payloads to device 0. Each child still saw exactly one card and passed its own visibility assertion, so the contention came back looking like a code failure. A shortfall is infrastructure and stands the kernel down before a thread starts, which is what the comment above it already claimed. A payload whose virtualenv could not be built kept the base python3 kernel and installed into the shared system site-packages. That is the one thing the per-child venv exists to prevent: the legs install deliberately different library sets, so the last writer wins and the resulting import error reads as a regression. The payload is skipped instead. Both payloads materialised into one source directory and compiled into one unsloth_compiled_cache. The sources are byte-identical copies but write_bytes truncates first, and the compile cache is a relative path resolved against a working directory both papermill children inherit while compiling the same modules against different transformers versions. Each payload now owns both, and the prune globs still reach them. Finally, --smoke-args is appended after every leg's own arguments, so the workflow's --max-steps 10 landed after the gpt-oss leg's --max-steps 3 and argparse took the last one. The 20B leg was training for ten steps rather than the three that were measured to fit. A shared argument no longer reaches a leg that sets that option itself.
The base branch fixed two of the same problems this branch did, so all six conflicts are in launch.py and every one of them is resolved as a union. The log flattener existed twice; one survives, keeping the join over whole records so a report split across two of them is still read, which is what both sides' tests assert. push() keeps the base branch's fresh slug per attempt, its discard of the previous attempt and the list of every slug it filed, and this branch's handling of a push whose CLI never answered: the slug is recorded in the in-flight registry and handed back as orphan_slug so release_kernels deletes it. The kernel entry carries both fields. The base branch's own push test now points INFLIGHT at tmp_path, since after the merge an accepted push records itself and the test was otherwise filing a kernel that never existed into the real registry.
|
Merged the #8440 base in at All six conflicts were in
One test changed, and it is not a weakening.
|
… leg 8440 was squash-merged, so this branch's copy of the Kaggle CI shares no history with main's and every file came back as an add/add conflict. b147dbb^2 is the 8440 tip this branch had already merged, which gives a real three-way base; against it only five files carry edits of this branch's own. launch.py takes main's side unchanged. The one guarantee worth checking was the in-flight registry: this branch recorded a slug in exactly two places, a confirmed push and the push timeout, and main records in both. Main's release() is strictly stronger than the release_kernels it replaces, since it retries, honours GONE_MARKERS, and sweeps every filed slug rather than the one that was returned. The workflow needed a real fix. Its gate flags were re-applied at --percent 15 but its budget prose was left at the pre-Studio 40% rate, so the header claimed 23.1 GPU-h against a 40 GPU-h allowance a few lines above a layer-3 paragraph describing a 15 GPU-h one. 15% is the rate this branch already uses everywhere else: kaggle-t4-studio-gpu-ci.yml, added here, documents the notebook leg at 15%, 3.3-8.7 GPU-h, a 15h share and 13-35 launches, and those are the numbers the EXPECTED SPEND block now derives. reserve-hours stays at 20, which is what the Studio block cites in prose, and the test now asserts that sentence agrees rather than letting the two files drift. tests/kaggle/test_launch_cleanup.py retargeted onto the merged API. Nothing deleted or xfailed; the two tests that named orphan_slug and release_kernels now drive the real push loop and the real release() end to end, and one was added for a push that raises rather than times out. Every one was mutation-proved: 13 mutations of launch.py, each required RED then restored to GREEN. One caveat worth recording. The SIGINT parametrisation stays green with the signal handlers removed, because Ctrl-C is also carried by main()'s outer except BaseException and by atexit; all three have to go before it fails. SIGTERM has only the handler. tests/kaggle/: 532 passed in 76s, down from 723s, because the reworked timeout tests zero PUSH_BACKOFF_SEC / DELETE_BACKOFF_SEC instead of sleeping through the real 45/90/180s ladders while still running every attempt.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 382e5c2e9b
ℹ️ 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".
| - name: Install the Kaggle client | ||
| run: python -m pip install --quiet 'kaggle==1.7.4.5' |
There was a problem hiding this comment.
Use a Kaggle client that supports token authentication
Every sampled or forced invocation stands down before launching because this gate supplies only KAGGLE_API_TOKEN, while the pinned 1.7.4.5 client rejects that credential during api.authenticate(). The repository's compatibility test documents that 1.7.4.5 also lacks quota_view() and kernels delete (tests/kaggle/test_t4_smoke_harness.py:4261-4283), and the sibling notebook workflow consequently pins 2.2.4; update both Studio job pins to a compatible 2.x release so the gate can approve runs and the launcher can clean them up.
Useful? React with 👍 / 👎.
| # 120 min: the kernel ceiling is 70 and collection adds a few, so this | ||
| # only fires if the launcher itself wedged. | ||
| timeout-minutes: 120 |
There was a problem hiding this comment.
Allow the launcher enough time to finish cleanup
When pushes are throttled or deletes consume their retry ceilings, this 120-minute job deadline is shorter than the launcher's own bound: worst_case_seconds(5400, 1) is 8,220 seconds (137 minutes), before checkout, installation, and notebook construction. Unlike the notebook workflow, this job also passes no --deadline-epoch, so it can push even when that cleanup window no longer fits; GitHub can then kill it while release() is still reconciling earlier attempt slugs, leaving the live kernel billing. Raise the timeout above the computed bound and pass the real job deadline so launch.py can stand down safely.
Useful? React with 👍 / 👎.
| --kernels 1 \ | ||
| --budget-hours 2 \ | ||
| --reserve-hours 10 |
There was a problem hiding this comment.
Reserve quota for the launcher's full billing window
When Kaggle accepts a push but returns a timeout or 5xx and deletion of that ambiguous attempt fails, the kernel can bill throughout the remaining push retries, evidence collection, and release retries rather than only for the nominal 70-minute kernel timeout. For this invocation worst_case_seconds(5400, 1) is 8,220 seconds (2.28 hours), and ambiguous retries can leave more than one session running, so reserving only 2 hours can approve a launch that spends below the promised 10-hour human reserve even if the job is given enough time to clean up. Derive this value from the launcher's bound and account concurrency, as the notebook workflow does, rather than from the unreliable Kaggle-side ceiling.
Useful? React with 👍 / 👎.
| REF='${{ inputs.unsloth_ref }}' | ||
| if [ -z "$REF" ]; then | ||
| REF='${{ github.event.pull_request.head.sha || github.sha }}' | ||
| fi |
There was a problem hiding this comment.
Validate the ref before spending a Kaggle session
When a workflow dispatch supplies a mistyped, deleted, or fork-only ref—or an older queued PR run's head SHA becomes unreachable—this step forwards it without checking that unslothai/unsloth can fetch it. The first validation is therefore the generated notebook's git fetch, after the paid kernel has already been pushed; that cell raises before producing a payload report, so the launcher reports a green infrastructure outcome after consuming quota. Resolve and fetch the object on the hosted runner before building or launching the kernel, and stand down if it is unavailable.
Useful? React with 👍 / 👎.
Stacked on #8440. Review the second commit; the first is that PR.
Unsloth Studio has no CUDA coverage anywhere in CI today. Every
runs-on:inthis repo is
ubuntu-latest,macos-15orwindows-latest, andstudio-inference-smoke.ymlruns a 270m GGUF on CPU. So the parts of Studiothat only exist on a GPU -- offloading layers to VRAM, training, and CUDA GGUF
conversion -- ship on the strength of unit tests and nothing else.
#8440 established that Kaggle gives us a real T4 for free from a workflow. This
adds a second leg on the same machinery: install Studio the way a user does
(
install.sh --local, frontend build, CUDA torch, prebuilt llama.cpp), boot it,and drive it.
What the payload asserts
Three surfaces, each written so a CPU fallback or a no-op cannot pass it.
A. GPU inference and tool calling. Loads a GGUF and asserts the offload
actually happened:
n_gpu_layersresolved above zero ANDnvidia-smishows theserver process holding VRAM AND the llama.cpp log names the CUDA backend. Any
one of those alone is passable by a CPU run. Then a tool call round-trips
through the real handler.
B. Training through the UI. Eight LoRA steps on a 0.5B base, driven through
Studio rather than through the trainer API, and asserted on the adapter it wrote
plus a loss that moved. Clicking the controls and getting a green toast is not
the assertion.
C. Export on CUDA. Merge, convert, quantize, and then reload the quantized
file and generate from it. An export that produces a file nothing can open is a
false green, so the reload is the check.
gpu_assert.pycarries a short note per surface on how that surface could gogreen while proving nothing, which is what the three-way checks above are
answering.
Budget
The account has 60 accelerator-hours a week. CI is allowed 50; the last 10 are
held for human use.
That is shared with #8440, and this leg is the expensive one: ~0.75 GPU-h per
launch against ~0.25, on an eligible event stream about three times larger.
Both budget blocks are now solved against the one account rather than
separately, split Studio 35 / notebooks 15:
The reserves encode priority rather than each leg's own ceiling. The gate reads
account-wide remaining quota, so the notebook leg stands down once 35h is spent
and this one runs on to 50.
The percentage is the one axis where this leg reads lower, and it cannot be made
to agree: the eligible stream is ~3.3x larger and each launch costs 3x more, so
a point of rate is worth about ten times as much here. Matching 15% would be
~86 GPU-h a week, more than the whole account. Both headers say so and
test_studio_is_sampled_harder_than_the_notebook_legasserts the inversion, soa later edit that "corrects" the percentages has to argue with a test rather
than quietly starve one leg.
The paths filter is deliberately not
studio/**. This leg exists to exerciseCUDA and the frontend is not where CUDA lives; frontend changes are already
covered on every commit by
studio-ui-smoke.yml,studio-frontend-ci.ymlandthe mac and windows UI jobs. Filtering on
studio/**would raise the eligiblestream from ~760 to ~1600 a week and halve the affordable rate for coverage this
job cannot see.
Only one T4 of the session is used. The notebook leg runs a payload on each card
because the second is free, but here a server, a browser and a llama.cpp process
are already contending for four cores, and a second copy would measure
contention rather than Studio.
Failure semantics
Red only when the payload ran on a T4 and an assertion failed. Not sampled, no
quota, account busy, kernel died on Kaggle's side, evidence would not download:
all skip or warn and exit 0. Nothing was learned about the code in those cases.
Not intended as a required check, since it runs on a minority of commits by
design.
The gate and launcher are the shared ones from
.github/scripts/kaggle_t4_ci/,not a second copy of the quota and concurrency policy.
Also here
test_the_workflow_step_count_and_the_payload_default_agreeon #8440 had gonevacuous: pre-commit.ci reformatted
default=10todefault = 10, the payloadregex stopped matching, and the test failed by
AttributeErroronNoneratherthan by comparing anything. It now asserts each pattern matches exactly once.
tests/kaggle/is 208 passed.