Skip to content

Run deterministic notebook smoke tests on real Kaggle T4s - #8440

Merged
danielhanchen merged 85 commits into
mainfrom
kaggle-t4-notebook-ci
Aug 14, 2026
Merged

danielhanchen merged 85 commits into
mainfrom
kaggle-t4-notebook-ci

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Adds a notebook smoke test that runs on real Kaggle T4s, so a change that
breaks Turing gets caught before a user finds it. Nothing in the existing CI
matrix runs on an sm_75 card.

Why Kaggle

Kaggle hands out dual-T4 sessions on a free quota, which is the only free
source of the exact hardware most notebook users are on. Measured quota on the
account: 60.0 h/week, 2 concurrent batch GPU kernels. A dual-T4 session bills
wall clock once, not per card, so one launch costs about 0.08 h once training
starts.

Shape

  • .github/scripts/kaggle_t4_ci/ builds a kernel, launches it, polls, and
    reports. gate.py decides whether a given event is worth a session at all,
    so the weekly quota is spent on changes that could plausibly affect the GPU
    path rather than on every push.
  • tests/kaggle/t4_smoke/run_t4_smoke.py is the payload: a short
    unsloth/Qwen2.5-0.5B-Instruct LoRA run against a 6-row canary dataset.
  • determinism.py plus a committed reference under references/ turns it into
    a comparison rather than a smoke test. Losses are checked against a band.

Evidence it works

Run end to end on real Kaggle T4s. Output was bitwise identical across 4
processes on 2 T4s
. The committed reference
(references/t4_qwen2.5-0.5b.json) came from the first green run and was then
validated by a second, independent launch reproducing it.

CPU-only harness tests: tests/kaggle/, 45 passed, 0 skipped. Those cover
the gate, the band check, the build paths and the survey bound without needing
Kaggle credentials.

Two honest gaps

  1. No xformers on Kaggle T4. The base image does not carry a compatible
    build, so the payload runs without it. This therefore does not cover the
    xformers attention path on Turing, which is a real part of what T4 users
    hit. Worth closing later.
  2. An import-order warning is baked into the reference. The captured run
    emits it, so the reference encodes it. If that warning is fixed, the
    reference needs regenerating; references/README.md says how.

Not a required check

It is deliberately not proposed as a required status check. It depends on a
third-party service and a finite weekly quota, so a Kaggle outage must not be
able to block merges. It needs the KAGGLE_ACCESS_TOKEN_GH repository secret,
and the gate skips cleanly when that is absent, so forks are unaffected.

danielhanchen and others added 9 commits August 11, 2026 09:57
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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d8b477078

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

Comment thread tests/kaggle/t4_smoke/run_t4_smoke.py Outdated
Comment on lines +530 to +533
failed = {"label": args.label, "model": args.model,
"passed": False, "runs": runs, "metrics": [],
"failures": [f"cycle {i} did not complete "
f"(rc={proc.returncode})"]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Separate pre-assertion infrastructure errors from failures

When a cycle exits nonzero before reaching any assertion—for example because Hugging Face times out while downloading the model—this path unconditionally emits a report with passed: false. The launcher consequently labels an external network failure as a payload assertion failure and turns the workflow red, contrary to its documented infrastructure semantics. Preserve enough phase/error information to classify external setup failures as infra while retaining red results for actual code or assertion failures.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one: the swap makes a real failure green, and the classifier it needs is not available here.

The mechanics first. report.py exits 1 on verdict fail and 0 on verdict infra, and launch.py decides purely
on not r.get("passed"). So for a network timeout to land as infra the payload would have to stop emitting
passed:false, and every genuine assertion failure would go green with it. The parent has only the child's
return code: "Hugging Face timed out" and "import unsloth raised" are the same integer, and inferring one
from the other is a guess that fails towards green.

The genuine infrastructure case is already green, and by a route that does not need the guess. A session
that dies without producing any report has no report to fail on, so launch.py classifies it infra and
report.py exits 0. The path this comment is about is specifically the one where the payload DID run and DID
report, and this is also the same reordering that was rejected on this PR in the launcher's own classify
(3761245219), and the same false green the two P1 items of that round were about.

The half of this I do agree with is the reporting: that failure report was missing its environment block
and the run that produced it was unattributable. That is item 3762396949, fixed in 12198df -- the
environment fingerprint and the config are now collected before the cycles and carried into it.

danielhanchen and others added 5 commits August 11, 2026 15:18
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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab4866206b

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

Comment on lines +206 to +214
- name: Decide
id: decide
env:
KAGGLE_API_TOKEN: ${{ secrets.KAGGLE_ACCESS_TOKEN_GH }}
run: |
python .github/scripts/kaggle_t4_ci/gate.py \
--percent 10 \
--force '${{ inputs.force || 'false' }}' \
--labels '${{ join(github.event.pull_request.labels.*.name, ',') }}' \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not expose the Kaggle token to pull-request code

On a non-fork pull request, the preceding checkout materializes the PR's version of .github/scripts/kaggle_t4_ci/gate.py, and this step then executes that repository-controlled script with KAGGLE_ACCESS_TOKEN_GH in its environment. A collaborator who can push a same-repository branch but cannot read Actions secrets can modify gate.py in a PR to transmit the token as soon as the gate job starts; the later launcher step has the same wiring. Run credential-bearing logic from a trusted base-branch copy or otherwise ensure pull-request code never executes in a step that receives the token.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The premise does not hold, and the remedy would not work.

The premise is a collaborator "who can push a same-repository branch but cannot read Actions secrets". There is no
such person. GitHub's hardening reference states it directly: "Any user with write access to your repository has read
access to all secrets configured in your repository"
(https://docs.github.com/en/actions/reference/security/secure-use). Write access is enough to push a branch carrying
any workflow at all and read every repository secret from it; no pull request and no gate.py are needed, so this
workflow adds no exposure that write access did not already carry.

The remedy would not close it either. On pull_request GitHub executes the workflow file from the merge ref, not from
the base branch (https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows),
so the YAML in the pull request is the YAML that runs. Sourcing gate.py and launch.py from a trusted base-branch copy
protects the scripts and leaves the file that invokes them under the pull request's control.

The mechanism that would actually narrow the blast radius is an environment secret with required reviewers, plus
deleting the repository-level copy, and its cost is a human approval on every sampled run. That is a repository
policy call about one token rather than a defect in this workflow, so I have written the boundary down in the
CREDENTIALS block instead of changing the wiring: what is protected, what is not, and what it would take.

danielhanchen and others added 4 commits August 11, 2026 17:53
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.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 2 commits August 11, 2026 19:29
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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f14f184861

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

Comment on lines +374 to +376
losses = [m.get("loss") for m in metrics if m.get("loss") is not None]
if not losses:
failures.append("no loss was logged at all, so nothing trained")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail when any gpt-oss step omits its loss

When one requested training step produces a metric entry with loss=None, it still counts toward the max_steps length check but is filtered out here. If another step has a finite loss, both the no-loss and non-finite checks remain clear, so the leg can pass without establishing the documented requirement that every requested step logged a finite loss; treat a missing loss on any metric entry as a failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one: the case is not reachable, so making the filter fatal changes no outcome.

result["metrics"] is built from trainer.state.log_history filtered by if "loss" in entry, and transformers
writes that key as logs["loss"] = round(tr_loss_scalar / (...), 4) -- a float, unconditionally, in
Trainer._maybe_log_save_evaluate. So an entry that reaches metrics at all carries a float loss and the
is not None filter can never drop one. The neighbouring key is the one that can be missing, and it is
missing rather than None: if grad_norm is not None: logs["grad_norm"] = ....

The gap in this same function that IS reachable is the one right beside it -- grad_norm was captured on
every entry and asserted on by nothing, so a run with all-zero gradients passed. That is 3761487054, and it
is fixed in a4b2a1d.

…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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ab3352ecd

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

Comment thread .github/scripts/kaggle_t4_ci/launch.py Outdated
Comment on lines +573 to +575
failing = [r for r in reports if not r.get("passed")]
if failing:
result["verdict"] = "fail"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check completeness before treating reports as failures

When a kernel fails to push or report back while one of the returned payloads has passed: false, this branch sets the verdict to fail before checking len(reports) < args.expect. The report step then turns the workflow red even though the run is incomplete, contradicting the launcher's stated rule that a half-launched run is partial because only a subset of the experiment ran; classify incomplete result sets before evaluating payload failures.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one. The ordering is deliberate and the swap would cost the check its point.
Take the concrete case: kernel 2 never pushed and kernel 1's control leg failed its reference
band. Today that is fail and report.py exits 1. Classifying incompleteness first makes it
partial, which report.py exits 0 for, so a payload that ran on a T4 and disagreed with its
assertions stops turning the job red. "Half a comparison is not evidence of a regression"
applies to reports that passed, where nothing was learned; a report that says it failed is
evidence on its own, whatever else did not report. It would also undo the two P1 items in this
same round, which ask for more definitive failures to reach report.py, not fewer.

danielhanchen and others added 2 commits August 11, 2026 19:59
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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ad968d3ba

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

Comment thread .github/scripts/kaggle_t4_ci/launch.py Outdated
# the payload deliberately does not propagate a nonzero exit, so ERROR
# here usually means the SESSION died (timeout, OOM of the box, Kaggle
# side), which is infra unless a report says otherwise.
failing = [r for r in reports if not r.get("passed")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require a literal boolean pass verdict

If a payload schema regression serializes passed as the string "false" (or any other truthy non-boolean value), this truthiness check excludes it from failing; once the expected report count is present, the launcher records an overall pass despite the payload saying it failed. Since these reports cross a notebook/log transport boundary, validate that passed is True rather than accepting arbitrary truthy values.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one. passed does not arrive as anything but a bool: all three payloads set
report["passed"] = not failures, and json.dump/json.loads round-trip a bool as a bool. Both
failure directions already fail closed, since a missing key and a false are equally falsy and
both land in failing. The string "false" needs a schema regression in code that ships in
this same PR, which is the hypothetical rather than the reachable case.

Comment-only pass over the Kaggle T4 notebook CI: the prose blocks that
explain the leg pairing, the budget arithmetic, the cleanup contract and
the payload assertions were several paragraphs where a few lines carry
the same meaning.

Every measured fact stays: the kaggle client pin and the three things
1.7.4.5 cannot do, the ls-remote vs fetch behaviour on a bogus SHA, the
vLLM torch pin windows, the recorded losses, peaks, kernel ids and
version boundaries.

No code changes, verified by an AST comparison over every touched file.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81849bc9a2

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

run: |
ZOO_REF=''
for attempt in 1 2 3; do
ZOO_REF="$(git ls-remote https://github.com/unslothai/unsloth-zoo refs/heads/main | cut -f1)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Let the zoo ref retry survive ls-remote errors

When git ls-remote returns nonzero for a transient network or GitHub error, the Actions bash shell's -e -o pipefail handling makes this assignment fail the step immediately, so the loop never reaches its second attempt and never emits the intended stand_down=true result. The analogous Unsloth ref resolver already neutralizes the command status with || true; do the same here so an external lookup failure produces the documented green infrastructure stand-down rather than a red workflow failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This one does not reproduce: the premise is pipefail, and the step does not run under it. No shell: key is set here and none is defaulted, so Actions runs 'bash -e {0}'; -o pipefail is added only when shell: bash is named explicitly (GitHub's workflow-syntax table, and actions/runner#353). Without pipefail the assignment takes the status of the pipeline's last command, cut, which is 0 whatever git did. Measured: bash -e -c 'X="$(git ls-remote https://github.com/unslothai/does-not-exist-xyz refs/heads/main | cut -f1)"; echo $?' prints git's error on stderr, status 0, empty X, and execution continues, so the loop does retry and an exhausted loop does emit stand_down=true. The unsloth resolver's || true is needed because that command substitution is not a pipeline; this one is, so the pipe already neutralizes it.

danielhanchen and others added 2 commits August 13, 2026 21:38
The job deadline exists so the runner is never killed during release(),
which is what deletes the kernels and stops the billing. Its arithmetic
counted one delete per filed slug and none of the discards, so it was
about half the launcher's real bound:

  one delete   DELETE_ATTEMPTS 3 x 180s plus backoffs 5 + 10   = 555s
  push, per notebook   4 x 600s + backoffs + 3 discards        = 4380s
  two notebooks                                                = 8760s
  release(), 4 filed slugs per kernel                          = 4440s
  evidence                                                      ~600s
                                                        total  13800s

That is 230 minutes against a 200 minute deadline, so a wedged run could
be killed mid-cleanup and orphan the kernels the deadline is there to
get deleted. The deadline moves to 260, the delete ceiling gets a name,
and the harness test now derives every term from launch.py's constants
instead of hardcoding one call at 180s, so it can fail when they move.

The gate had the matching hole: no socket timeout, and the Kaggle client
has none of its own, so a stalled call blocks forever, --soft-fail never
sees an exception and the 10 minute job timeout reports red on a
workflow whose contract is that only a failed assertion on a T4 is red.
It now sets the deadline before the first call, as launch.py does, and
the in-flight survey gets a wall-clock budget: running out of it stops
the walk as incomplete, which is already a skip, rather than being
killed by the job.

tests/kaggle: 296 passed.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Three ways this workflow could spend a Kaggle session, or colour a pull
request red, for something that is not the code under test.

push() filed a slug and only published it by RETURNING. The retry loop
handles the subprocess timeout, so every other raise (subprocess.run with
text=True decodes strictly and raises UnicodeDecodeError on a malformed
response; the runner can answer OSError or MemoryError) unwound past the
line that recorded the entry, and release() then iterated a list with no
entry for that notebook at all. A kernel Kaggle may have just accepted was
left billing to its own ceiling. The list is now the caller's: main()
publishes the entry before the push and push() fills it as it files each
slug, so reconciliation no longer depends on the call returning.

max_steps is free text on a dispatch and was forwarded unchecked. A value
that is not an integer reaches the payload's argparse, which exits 2 with
no report, and the generated cell reports that crash as a failing leg on
purpose, so three legs come back red after the kernels were pushed and the
model downloaded. A value below the fp16 scaler's leading skipped steps
applies no optimizer update at all, and the payload's own checks fail it.
check_steps.py answers both before the recheck, and MEASURES the floor as
the shortest prefix of the committed reference that optimisation_failures
accepts (5, on the committed trace) rather than restating a number that
would go stale as soon as the reference moved. The build step also takes
the value through the environment now rather than interpolating it.

The evidence upload had no continue-on-error, so an artifact-service
outage failed the job, and the job is what the pull request shows. The
verdict is Report's, which runs under always() and can still conclude
pass. It is best effort now, and says so out loud: continue-on-error
leaves outcome at failure while conclusion becomes success, and the step
after it reads that outcome and warns.

tests/kaggle: 302 passed.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Evidence collection had no deadline. The job timeout counted 300s per kernel
for it, a number no code enforced: one listing walks OUTPUT_PAGE_LIMIT pages at
the 120s socket ceiling, 2400s for a single kernel, and each executed notebook
is another 300s with no cap on how many Kaggle lists. Measured against the
launcher at the previous head, two kernels can spend 14520s there, against 600s
budgeted, and the phase runs BEFORE release(), so the runner is killed with
billable kernels up. launch.py now starts one EVIDENCE_BUDGET_SEC budget before
the first collection, shared by every kernel, clamps each listing page and each
download to what is left of it, and marks a collection truncated. The job
deadline reads that constant instead of restating a per-kernel term, and
deadline=None now means a fresh budget rather than no ceiling.

The reference band never checked the card. The reference records gpu_name
"Tesla T4" and gpu_capability "sm_75" because a loss trace belongs to its
hardware -- no bf16, xformers attention -- and every other reference-defining
property already refuses before comparing. Only the GPU COUNT was checked, on
the kernel, which cannot see the file. A P100 run against the committed T4
trace returned status "ok" with no failures, so a hardware difference read as a
code regression. check_reference now gates on the reference's own environment
block, so a recaptured reference moves the gate with it, and "it does not say"
stays unchecked rather than a mismatch.

adapter_config.json was checked for being JSON. "{}" parses, so a save that
wrote no LoRA fields at all scored config_readable and the leg passed on a
directory PEFT cannot load. The question is whether PEFT can rebuild the
adapter, so it is asked of PEFT on the path a reload takes,
PEFT_TYPE_TO_CONFIG_MAPPING[peft_type].from_pretrained; PeftConfig.from_pretrained
alone returns peft_type None for "{}" and reports nothing wrong. The rebuilt
config is then compared against the arguments the payload handed
get_peft_model, so a well-formed config for a different adapter is a difference
rather than a field list this file guessed at.

The version table omitted the packages the legs move. legs.py records the
frontier resolution installing huggingface_hub 1.27.0 and datasets 5.0.1, and
the tokenizers and safetensors ceilings that forced deps back on, none of which
were in GOAL_PACKAGES, so a failure caused by one produced a comparison table
in which nothing differed. They are recorded now. The related hole is that
pin_failures answered from a table keyed on that fixed list: a pin outside it
had no entry and came back "it is not installed" for a package installed and
correct. The probe list is derived from the pin file, and an unprobed pin is
its own third outcome rather than an invented failure.

pytest tests/kaggle: 315 passed. The workflow's recorded count is updated and
its harness step installs peft, without which the two new adapter checks
importorskip and cannot fail.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45198ae3b5

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

id: decide
env:
KAGGLE_API_TOKEN: ${{ secrets.KAGGLE_ACCESS_TOKEN_GH }}
PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve label boundaries when detecting the override

When a pull request has a free-text label whose name contains a comma, joining names with commas and then splitting the result in gate.py loses the original label boundaries. For example, a label named maintenance,kaggle-t4-ci is stood down on its initial labeled event, but the next synchronize event is parsed as if the real kaggle-t4-ci opt-in label were present and therefore forces a paid run on every push, bypassing the sampling budget. Pass the label array as JSON and compare its elements rather than serializing it with a valid label character.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not reachable: GitHub does not allow a comma in a label name, so the join cannot lose a boundary. Measured against the API just now on a repo I own:

POST /repos/{owner}/{repo}/labels with name 'maintenance,kaggle-t4-ci' -> 422 Validation Failed, {"resource":"Label","code":"invalid","field":"name"}. Same for 'a,b' and for 'zz probe, spaced'; the identical request with 'zz-probe-plain' succeeds, so it is the comma and not the length or the rest of the name. PATCH .../labels/{name} with new_name containing a comma is refused the same way, and the GraphQL createLabel mutation answers UNPROCESSABLE "Name is invalid", so there is no second creation path either.

A name with a newline is normalised to a space rather than stored, so the newline the gate also splits on cannot appear either. The label list therefore round-trips through join/split unchanged and the opt-in label cannot be spoofed by a free-text one.

Evidence deadline: urlopen's timeout is per blocking socket operation, not a
ceiling on the transfer, so an endpoint that keeps returning bytes renews it
forever and one resp.read() outlasts the whole 600s budget while every deadline
check sits before the call. Measured against a body arriving in 20 chunks a
minute apart: 1211s listing, 1260s download. Read in chunks with read1, the
absolute deadline re-checked before each and the live socket re-clamped to what
is left, streaming downloads to disk instead of into memory. A listing or a
notebook abandoned that way now says the evidence is truncated.

Reference hardware: check_reference compared gpu_name and gpu_capability only
when the run supplied them, and main() records environment = {"error": ...} when
the probe raises, while the fingerprint omits every gpu_* key outright when
torch.cuda.is_available() is False. Either way the live values were absent, both
keys were filed as unchecked, and the control leg reported an ok reference check
without establishing the T4 the trace belongs to. What the reference does not
say stays a skip; what the run cannot say about a key the reference does name is
now hardware_unverified and fatal.

Harness step: peft depends on torch, so installing it first satisfied that from
the default index and the CPU-index line that followed found the requirement
already satisfied and installed nothing, leaving the CUDA set on the runner in
the window reserved before the push. CPU torch goes first, as version-compat-ci
does, and the result is checked with torch.version.cuda rather than assumed.

tests/kaggle: 323 passed.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Every gate stand-down was a green skip, exhaustion included, so a week
with no accelerator hours left looked exactly like a workflow nobody had
wired up: t4-smoke skipped, no annotation, nothing to read.

The quota floor now exits nonzero carrying

  GPU capacity exhausted - please wait until next week - you can ignore
  this CI failure

followed by the numbers the quota API already returned (hours left, the
weekly total, and the refresh time), in the log line and in the job
summary, so the reader can see when it clears and that there is nothing
for them to fix.

Only genuine exhaustion. It is decided where it already sat, before the
concurrency survey and before any kernel is pushed, so it costs one API
call rather than a Kaggle session. An UNREADABLE quota stays a green
skip: unknown is not exhausted. So do the sampling draw, the wrong
opt-in label, the missing token, a failure to authenticate, a busy
account and the launcher-side stand-downs, all with their wording
unchanged.

--soft-fail becomes a request rather than a default. It defaulted to
True, which would have made the new red unreachable, so it is now three
states: unset, --soft-fail, --no-soft-fail. An error in the gate itself
is still a skip unless --no-soft-fail is passed, exactly as before.

The gate job asks for the red and nothing swallows it. The recheck
inside t4-smoke passes --soft-fail and stands down green instead: it
runs after approval with the account slot in hand, so reaching it means
the hours went while the run queued, and red there would be the same
message after a runner, the harness suite and the kernel build.

Ten tests pin it: the exact sentence, the exit codes on both sides of
--soft-fail, that the survey never runs once the quota is short, that an
unreadable quota and a busy account stay green, and that nothing
downstream turns the gate job's failure back into a pass. 333 pass.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…corded

Three checks that stopped at the edge of the thing they bound.

The gate reserved 4 GPU-h against a launcher whose billable window is the
whole invocation, not the polling. A kernel bills from the moment Kaggle
accepts it until a delete is confirmed, so the push retries (each one
discarding the previous attempt's slug), the evidence phase and release()
are inside that window as surely as the wait is: launch.py's own constants
put one invocation at ~13800s, and Kaggle runs at most --kernels sessions
for this account at once, each billing its wall clock once. That is
2 x 13800s = 7.7 GPU-h. The reservation is now 8, and the harness suite
recomputes the bound from launch.py rather than checking the number, in the
same helper the job deadline is derived from. The old assertion read
budget >= kernels x --max-wait, which 4h satisfied while a wedged run could
bill 7.7h and take the 20h reserve down with it.

The reference identity pinned the configuration and not the rows.
canary_dataset.jsonl is inside this workflow's paths filter, so editing it
TRIGGERS the run that would then be band-checked against a trace of the old
rows: a small edit passes the tolerance and reports green on a comparison
that means nothing, a larger one is reported as a code regression. The
payload now records a sha256 of the parsed rows in config.dataset_digest and
check_reference refuses on it exactly as it refuses on max_steps, the digest
of the committed dataset is in the committed reference, and a harness test
compares the two on the runner before any session is paid for. Digesting the
parsed rows rather than the file's bytes means reformatting does not force a
session-costing recapture; changing a row, the order or the count does.

The gpt-oss leg recorded placement_after_load on every run and asserted on
none. Its documented result is that the 20B checkpoint fits and trains
wholly on one T4 with about 1.8GB to spare, and that is the claim that
degrades quietly: a loader or memory regression that spills to CPU, disk or
meta still logs finite losses, still moves the adapter, still compiles and
still generates. failures_for now fails on parameters off the visible CUDA
device, on hf_device_map offload, and on a placement record it cannot read,
the last on the same three-way rule the bf16 reading already gets.
accelerate's offload does not support training at all, so a run that reaches
it is not a slower version of this leg.

tests/kaggle: 345 passed.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abb517c624

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

Comment on lines +965 to +967
if observed is None or ref.get(key) is None:
verdict["config_unchecked"].append(key)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refuse references that omit the resolved checkpoint

When the backing Hugging Face repository is updated in place, the live run records resolved_checkpoint and resolved_revision, but the committed t4_qwen2.5-0.5b.json contains neither. This branch merely lists those one-sided fields as unchecked and proceeds with the numeric band, so the current reference can compare metrics produced from different model weights, either passing an invalid comparison or reporting an upstream model change as a code regression. Populate these fields in the committed reference or treat a missing reference-side checkpoint identity as a refusal.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The committed file does omit both, but neither remedy is right here. Refusing would put the control leg red for a reference captured before those fields were recorded, and this workflow reserves red for a payload that ran and failed - a stale reference is infrastructure, which stands down or reports, and the README already states the policy the code implements: a key the committed file does not carry is listed under config_unchecked and is not a mismatch, so an older reference keeps working until it is next recaptured. It is not an invisible skip either: report.py prints 'Not compared, absent from one side: resolved_checkpoint, resolved_revision. Recapture the reference to bring them into the check' on the job summary. And populating them is not something this branch can honestly do - the fields identify the weights the committed trace was produced from, and today's commit on the mirror is not that. The capture recipe in references/README.md already writes both from report.get(...), and the live run records them (run_t4_smoke.py:283, 440), so the next recapture arms the comparison with an identity that is true.

Comment on lines +602 to +605
generated = result.get("generated")
if generated is None:
failures.append("generation did not run")
elif not generated.strip():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify generation still uses the trained adapter

When FastLanguageModel.for_inference() or the PEFT generation path accidentally disables or detaches the LoRA adapter, the preceding fingerprint still proves that training changed the adapter, but the unmodified base gpt-oss model also generates non-empty text. This check therefore lets the leg pass even though post-training inference ignored the trained weights, contrary to the leg's stated goal of validating generation through the trained adapter; record and assert that the adapter remains active, or compare the adapter-on generation path explicitly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The stated goal is the other one. This leg's docstring, item 4: 'Generation after training returns non-empty text without raising, catching a training run that "succeeds" and leaves the model unusable, which on a quantised offloaded path is a real outcome.' Usable after training is the claim, and it is one that fails - empty output and a raise are both live on this path, which is why it is asserted here and not elsewhere. Whether the trained weights are the ones generating is answered a few lines up by the adapter fingerprint taken before and after training, and that verdict is a hard failure with no unverifiable escape (run_gptoss_t4.py:478). Asserting that the adapter is still attached at generation time is a new claim on a hypothetical, not a check that reads green while something is broken, and this leg pays for its assertions with 20B of Kaggle T4 quota - so it asserts what it exists to measure and leaves the rest to the SFT leg, which does save and reload an adapter and now compares its key set against PEFT's own.

danielhanchen added 3 commits August 14, 2026 01:20
The verify cell's import probe caught Exception, so an import that ends in
sys.exit() went straight past it: SystemExit derives from BaseException
expressly so that code catching Exception does not swallow it. The cell then
aborted before writing the report the probe exists to write, the run cell below
it never ran, and a leg that reports nothing is partial or infra at the
launcher, both of which exit 0.

transformers is a live carrier rather than a hypothetical one: it defines
OptionalDependencyNotAvailable as a BaseException subclass and raises it at
module scope, and its own lazy loader re-raises only Exception.

So catch BaseException here, as the GPU probe a few lines below already does
for the same reason, and re-raise KeyboardInterrupt: that is the runner
cancelling the job, not a broken dependency, and recording it as one would make
a cancelled run read like a regression.

The cell is executed in the tests rather than pattern matched, so the verdict
is observed the way the launcher will read it.
pyproject.toml is in this workflow's trigger paths because the payloads install
the commit under test as a distribution, and every leg then installed it with
--no-deps. pip enforces the requirements of packages IN a resolution and merely
warns about the rest, so with the tested distribution outside every resolution
the file could change its dependencies and nothing here could tell: a
requirement it adds is never installed, one it tightens is never checked
against what is already there, and the import probe passes anyway whenever the
dependency is reached by a delayed code path. A user meets all three at
pip install unsloth.

The --no-deps rationale was that the overlay must not walk the set unsloth_zoo
had just resolved. What unsloth actually declares is typer, rich, pydantic,
pyyaml, nest-asyncio, structlog and click: none of them is resolved by zoo and
none is pinned by a leg, so there is nothing to walk. A pyproject that does
name one of zoo's packages would move it, which is the regression this exists
to show rather than a side effect to suppress.

Resolving is only half of it, since pip reports a conflict with something
ALREADY installed as a warning and exits 0. So the verify cell also asks pip
check, and reads only the lines pip attributes to the distribution under test:
the Kaggle image carries pre-existing conflicts of its own, and the frontier
leg installs a transformers that zoo's metadata forbids on purpose, so the exit
code belongs to the environment while only those lines belong to this leg. An
unsatisfied requirement is written out as a verdict, like the two checks above
it, because the run cell is the only other thing that reports and is never
reached from there.

The name the check keys on is read off the requirement the legs install, so the
two cannot drift into checking nothing.
Cleanup reconciles every slug a push filed, not only the accepted one, and most
of those were never accepted: push() files a fresh slug per attempt, and a
retry's _discard() deletes the previous one without recording that it worked.
So release() asks Kaggle to delete slugs that were never created, and slugs
that are already gone.

A not-found answer settles the only question cleanup asks, which is whether the
slot is still billing. Reading it as a failed cleanup spent DELETE_ATTEMPTS on
an absent kernel, ahead of the accepted one that is the only kernel still
running, and then named it in a "may still be running, delete them by hand"
warning pointing a human at a slug that does not exist. The warning is the one
signal this emits, so a false one costs more than the calls.

The gate already reads a 404 as a kernel definitively not running, for the same
reason and against the same account, so this reads it through the gate's
GONE_MARKERS rather than a second list that could drift. The pinned client
surfaces one as "404 Client Error: Not Found for url: ..." on stderr with exit
1: kagglesdk calls raise_for_status and cli.py prints the HTTPError.

Every other nonzero exit keeps its retries. A 5xx, a reset connection or an
argparse refusal says nothing about whether the kernel is up, and trusting the
exit code alone would abandon a live session silently.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added 2 commits August 14, 2026 02:47
The job deadline is set to the launcher's worst case plus about 30 minutes for
everything that runs before it, and nothing enforces the second term. A
checkout, a pip install off a slow index, the harness suite and three network
resolutions have no cumulative limit of their own, so the allowance is an
assumption about their duration rather than a property of the run. Spend it and
the launcher still pushes, and the runner is then killed with kernels up:
GitHub sends SIGINT to the step's entry process and kills the process tree
about ten seconds later, which is not a window in which release()'s
DELETE_ATTEMPTS retries can finish. A kernel nobody deletes bills accelerator
quota to its own ceiling with nobody reading the result, which is the exact
outcome the deadline exists to prevent.

So the launcher is handed the moment the job dies and answers the question
itself, before authentication and long before the first push. Less than its own
worst case left and it pushes nothing and stands down green, which is what this
workflow's failure semantics give every infrastructure outcome: no quota spent,
and nothing learned about the code.

That worst case now lives in launch.py, computed from the constants that
produce it, because three consumers derive from it and all three are wrong by
the same amount if a phase is dropped: the job deadline, the quota the gate
reserves, and the new guard. The harness suite keeps deriving it independently
from the source text and asserts the two agree, so a term lost on either side
is a red test rather than a run that pushes with no room to clean up, or one
that stands down on every invocation.

The start of the job is recorded by the job's FIRST step. Taken any later, the
deadline computed from it sits after the real one, and the guard reads
optimistic in the one direction that costs quota. The minutes are restated in
the launch step's environment because a job cannot read its own timeout-minutes;
the suite asserts the two agree.
The saved adapter is read back with safetensors and counted, which answers
whether the bytes deserialize and not whether PEFT would consume them. PEFT
matches its state dict by NAME: set_peft_model_state_dict ends in
load_state_dict(..., strict=False) and nothing reads the returned
unexpected_keys, so tensors under names it does not recognise are ignored
without a word.

Measured on peft 0.20.0 against a real saved adapter: strip base_model.model.
from every key, or leave the adapter name in (lora_B.default.weight, which is
what filtering model.state_dict() by hand produces instead of calling
get_peft_model_state_dict), and PeftModel.from_pretrained raises nothing while
every lora_B comes back at zero. The file still deserializes, still holds the
same nonzero lora_B matrices, still carries a loadable adapter_config.json, so
every reading this payload took off the bytes is identical to a healthy save
and the leg passes on an adapter that reloads to the base model.

The oracle is PEFT's own answer for this run: save_pretrained writes exactly
get_peft_model_state_dict(self, ...), so calling it on the model that was just
saved reproduces the key set the file is supposed to hold. Nothing is restated
here, no prefix and no target-module list, so a legitimate peft renaming moves
both sides at once and only a save that disagrees with the running peft is a
difference.

Three answers, and they are not one failure. A key PEFT names that the file
does not carry is a dropped weight. A LoRA tensor under a name PEFT does not
use is a weight its loader ignores. A non-LoRA tensor beside the adapter is
recorded and not failed, since save_pretrained may legitimately write an
embedding or a modules_to_save copy that PEFT never has to match. A run that
could not derive the key set at all fails rather than recording an unchecked
field, or the strongest thing this asserts would switch itself off silently.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

check_steps.parse_steps accepts "+10", "010" and surrounding whitespace as the
ten they are, and the payload's argparse agrees, so those spellings run exactly
the reference's run. The build step compared the raw dispatch string against the
reference's count instead, read an identical run as a different one, and dropped
the committed reference band from it: a green run with the only cross-run check
in this workflow never applied, announced in a warning naming a step count that
was not different.

Both sides of that comparison now come from the step that validated them.
check_steps emits the parsed count, and the reference's own count through the
payload's reference_step_count rather than a second reading of the same JSON in
shell, which also takes the reference filename back to the leg registry.

The regression test executes the build step, on the outputs a real check_steps
run wrote, with the env resolved from the step's own env block, so a build step
that goes back to the raw dispatch string fails it.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a75e273ea4

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

# Pins go in LAST, as their own resolution step, so they beat what the
# preceding groups resolved; first, zoo's dependency set would quietly
# walk them forward again.
install = BASE_INSTALL + ((PINS.format(file = "control.txt"),),),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pin the complete control environment used by the reference

When unsloth-zoo main advances—or one of the dependencies it resolves changes—this control leg still installs that new code through BASE_INSTALL, while control.txt repins only five packages. Because the control then compares against a committed numeric reference but the canary has no reference band, ordinary dependency drift can make only the control red even though every declared pin held, yielding a misleading control-only failure. Pin the zoo revision and other reference-defining dependencies to the captured environment, or refuse the band comparison when their recorded identities differ.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one.

The uncontrolled variable it describes is already closed, and the part that is left is the point of the leg rather than a defect.

Within a run, zoo is pinned to one commit: the workflow resolves refs/heads/main once with git ls-remote (kaggle-t4-notebook-ci.yml:629 'Pin the zoo revision'), stands the whole run down if it cannot, and passes that 40-character SHA as --zoo-ref (:715), which legs.py:47 substitutes into unsloth_zoo @ git+...@{zoo_ref}. Every leg in the session installs that exact commit, so control and canary cannot resolve two different zoo revisions and the band comparison is not reading a difference the report does not name.

Across runs, zoo main advancing is the code under test moving, not environment drift. unsloth@ref and unsloth_zoo@main are what this CI exists to run; freezing zoo to the commit the reference was captured on would mean the leg with the committed trace never tests either of them again, and the numeric check would only ever confirm that a fixed pair of commits still behaves as it did. That is why torch is unpinned too, for the same reason spelled out at tests/kaggle/t4_smoke/pins/control.txt:40: the pins file freezes the five library versions the trace was captured with, not the code under test.

Control red with canary green is therefore a signal, and legs.py:24 already gives its reading. If a zoo commit moves the control's loss/grad_norm curve outside the band, that is a change in the optimization arriving from the code this workflow watches, and the band is the only thing here that can see it: the canary has no reference precisely because cross-version drift would swamp it (tests/kaggle/t4_smoke/references/README.md). Refusing the comparison when the recorded identities differ would switch the check off on exactly the commits it is for.

…utput from losing the verdict

The launcher measured the job's remaining wall clock once, before
authenticating, and pushed on that answer. With KAGGLE_API_TOKEN, the only
credential the workflow passes, kaggle 2.2.4 authenticates by introspecting the
token over HTTP, bounded only by SOCKET_TIMEOUT_SEC, so a window that fitted by
less than 120s was already gone at the first push and the runner could be killed
during release() with kernels still billing. The check is now a helper asked
twice, before and after authentication.

The generated run cell decoded the payload's stdout and stderr with
subprocess.run(text=True), which is strict: one malformed byte from a native
crash handler raised UnicodeDecodeError before the synthetic report below it,
papermill aborted the cell, and the launcher called a leg that died partial or
infra, both green. Decoding is now errors="replace".
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: a49d917cef

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant