Repository navigation
Kaggle CI: use both accounts, weighted by their own weekly quota - #10121
Conversation
The Kaggle GPU workflows authenticated with one repo secret,
KAGGLE_ACCESS_TOKEN_GH. That secret has been deleted and replaced by
KAGGLE_API_TOKEN and KAGGLE_API_TOKEN_2, one account each.
Nothing went red. gate.py answers a missing credential with a skip that exits 0
("expected on a fork pull request, where secrets are withheld"), so both
workflows have been a silent no-op with every check passing. That is the same
failure #9535 fixed once already, arriving this time through a deleted secret
rather than an unreadable client, so the first guard added here is the one that
would have caught it: the set of Kaggle secrets a workflow may name is closed,
and a name outside it fails the suite.
WHICH ACCOUNT
A run is drawn onto one account in proportion to the accounts' weekly
allowances, so the bigger one takes proportionally more traffic. The weights are
READ from each account's own quota_view() rather than written down, which is
worth the one extra API call: a plan changed on Kaggle's side changes the split
with nothing here to update. Measured over 200k synthetic run ids against 60h
and 30h, the split lands at 0.6660 / 0.3340.
The draw is keyed on the run id ALONE, not the attempt. A re-run of a run whose
kernels are still in flight has to return to the account that holds them,
because the other account cannot delete them.
An account that cannot take the run hands over to the other rather than standing
the run down. Both conditions are known before anything is pushed: the gate
already reads exact remaining hours and already surveys busy sessions. Outcomes
are structured codes rather than prose, because the fallback branches on them.
FOUR THINGS THAT WOULD HAVE MADE THIS QUIETLY WRONG
* The owner was hardcoded as `--user danielhanchen` on both launch paths. A
kernel id is <owner>/<slug>, so the second account could not push under it and
-- worse -- could not DELETE under it, turning a leaked session into a log
line indistinguishable from a kernel already gone. The owner now comes from
the authenticated client, and the launcher refuses to push when the name it
was given and the token disagree.
* `${{ cond && secrets.A || secrets.B }}` is not used, deliberately. An empty
first secret makes the && falsy and the || hands over the OTHER account's
token while every output still names the first. The gate publishes a one
element matrix carrying the secret NAME and the job indexes the secrets
context with it, which cannot express that state at all. No token is ever a
job output.
* The concurrency groups were account-wide, so with two accounts every run would
still have queued behind every other one and the second account would have
bought no capacity. They are now keyed on the chosen account: one notebook and
one Studio kernel each, four sessions over two accounts, still two per account.
* The reserve is now a fraction of each plan rather than a flat number of hours.
20h held back from a 30h account is two thirds of it against one third of a
60h one, which would have made the smaller account the stricter one on top of
it already taking less traffic by weight.
Studio also gains the queue-time recheck the notebook leg has always had, and
its push is gated on the answer -- a measurement that cannot stop the push is a
log line, not a control. With a 293-deep repo queue a gate answer is easily a
whole run stale.
TESTS
tests/kaggle: 575 passed. 14 new guards, 14 of 14 mutations caught, including
the deleted secret, the ternary, the flat reserve, the hardcoded owner, a sweep
reaching across accounts and a re-run rerolling its account.
A new tests/kaggle/conftest.py clears every Kaggle credential before each test.
Found the hard way: with KAGGLE_API_TOKEN_2 exported on a dev box, the "a fork
gets no secret" test authenticated to a real account and read that week's actual
hours over the network. It failed for a right-looking reason, and would have
PASSED had the quota been low.
One test claim is deliberately narrower than it looks. The account draw is
salted apart from the sampling draw, but the statistical test for that does not
work and was tried: removing the salt moves the measured share of account 1
among sampled-in runs from a 0.0039 gap to a 0.0059 one over 200k ids, both
inside noise, because %100 and %1000000 of one digest are independent enough.
The test asserts the derivation instead, and says so.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6a3e23085
ℹ️ 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".
| for index, env_name in enumerate(account_envs, start = 1): | ||
| account_id = str(index) | ||
| try: | ||
| record, api = probe_account( |
There was a problem hiding this comment.
Bound the two-account gate within the workflow timeout
When Kaggle responds slowly and the sampled account requires a fallback, this sequential loop can exceed the unchanged 10-minute gate timeout in both kaggle-t4-notebook-ci.yml and kaggle-t4-studio-gpu-ci.yml: probing two accounts permits four 60-second authentication/quota calls, and surveying both candidates permits two 180-second survey budgets, already totaling the entire timeout before checkout, setup, installation, or a network call overrunning a survey deadline. GitHub can therefore kill the job red before the handlers convert the condition into the intended skip; increase the job timeout or enforce one wall-clock budget across all probes and surveys.
Useful? React with 👍 / 👎.
| probes[account_id] = record | ||
| clients[account_id] = api |
There was a problem hiding this comment.
Reject credentials that resolve to the same account
When the two repository secrets are accidentally populated with the same Kaggle token, both probes succeed with the same record["user"], but they remain separate account IDs. The workflows then place their GPU jobs in separate account-1 and account-2 concurrency groups even though every job targets one real Kaggle account, so same-workflow launches can overlap, consume both slots, and cause other sampled GPU checks to stand down or report a green capacity failure. Since the authenticated usernames are already available here, detect duplicates before publishing either ordinal as an independent account.
Useful? React with 👍 / 👎.
| # recheck to it, so this step cannot quietly clear a DIFFERENT account | ||
| # from the one whose slot this job is holding and whose kernels it is | ||
| # about to push. | ||
| KAGGLE_API_TOKEN: ${{ secrets[matrix.secret_name] }} |
| if: steps.recheck.outputs.should_run == 'true' | ||
| env: | ||
| KAGGLE_API_TOKEN: ${{ secrets.KAGGLE_ACCESS_TOKEN_GH }} | ||
| KAGGLE_API_TOKEN: ${{ secrets[matrix.secret_name] }} |
| - name: Recheck the Kaggle account | ||
| id: recheck | ||
| env: | ||
| KAGGLE_API_TOKEN: ${{ secrets[matrix.secret_name] }} |
| if: steps.recheck.outputs.should_run == 'true' | ||
| env: | ||
| KAGGLE_API_TOKEN: ${{ secrets.KAGGLE_ACCESS_TOKEN_GH }} | ||
| KAGGLE_API_TOKEN: ${{ secrets[matrix.secret_name] }} |
#9700 landed the SLOTTED concurrency group (two dispatcher-chosen slots, because one group cannot express "at most two" and a second PENDING run cancels the first rather than queueing). This branch keyed the same group on the chosen account. Both are kept, because they answer different halves of one cap: the slot bounds a single account to its two sessions, and the account is what makes a second account add capacity at all rather than queueing behind the first. The group is now account + notebook + slot, which is 2 accounts x 2 slots and still Kaggle's two per account. Also carries main's `single_device` placement into the fetch-timer branch of run_t4_smoke.py rather than choosing between them: the timer is this work's point and `device_map={"": 0}` is what stops the multi_gpu leg loading a sharded model that cannot train. tests/kaggle: 902 passed.
…kaggle-two-accounts
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 579753d5c5
ℹ️ 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".
| weights = {i: p["total_hours"] for i, p in probes.items() if p.get("total_hours")} | ||
| sampled_account, account_draw = weighted_pick(args.run_id, weights) |
There was a problem hiding this comment.
Keep the final account stable across reruns
When a rerun occurs after account quotas or availability change, keying only the draw to run_id does not preserve the account that actually handled the prior attempt: dynamic weights can move the draw boundary, and an earlier attempt may have handed over to the other account while a later one does not. If the prior launcher left a kernel running, the rerun therefore authenticates to an account that cannot clean it up and may spend quota on both accounts, contradicting the stated rerun-safety invariant; the selected account itself must be made stable rather than only the hash input.
Useful? React with 👍 / 👎.
The problem
The Kaggle GPU workflows authenticated with one repo secret,
KAGGLE_ACCESS_TOKEN_GH. That secret has been deleted and replaced byKAGGLE_API_TOKENandKAGGLE_API_TOKEN_2, one Kaggle account each.Nothing went red.
gate.py:596answers a missing credential with a skip that exits 0 ("expected on a fork pull request, where secrets are withheld"), so both Kaggle workflows have been a silent no-op on main with every check passing. That is the same failure #9535 fixed once already, arriving through a deleted secret rather than an unreadable client.So the first guard here is the one that would have caught it: the set of Kaggle secrets a workflow may name is closed, and a name outside it fails the suite rather than the next quiet Sunday.
Which account a run lands on
Drawn in proportion to the accounts' weekly allowances, so the bigger account takes proportionally more traffic. Two decisions worth stating:
The weights are read, not written down.
remaining_gpu_hours()already returnstotal_time_allowedfrom Kaggle's own quota API, so the split follows a plan that changes on Kaggle's side with nothing here to update. Measured over 200k synthetic run ids against 60h and 30h, the split lands at 0.6660 / 0.3340.The draw is keyed on the run id alone, not the attempt. A re-run of a run whose kernels are still in flight must return to the account holding them, because the other account cannot delete them.
An account that cannot take the run hands over to the other rather than standing the run down. Both conditions are known before anything is pushed: the gate already reads exact remaining hours and already surveys busy sessions. Outcomes are structured codes rather than prose, because the fallback branches on them.
Four ways this would have been quietly wrong
--user danielhanchenon both launch paths. A kernel id is<owner>/<slug>, so account 2 could not push under it and, worse, could not DELETE under it: a leaked session becomes a log line indistinguishable from a kernel already gone. The owner now comes from the authenticated client, and the launcher refuses to push when the name it was given and the token disagree.${{ cond && secrets.A || secrets.B }}is not used, deliberately: an empty first secret makes the&&falsy and the||hands over the OTHER account's token while every output still names the first. The gate publishes a one-element matrix carrying the secret NAME and the job indexessecrets[...]with it, which cannot express that state. No token is ever a job output.Studio also gains the queue-time recheck the notebook leg has always had, and its push is gated on the answer. A measurement that cannot stop the push is a log line, not a control, and with a 293-deep repo queue a gate answer is easily a whole run stale.
Tests
tests/kaggle: 575 passed. 14 new guards, 14 of 14 mutations caught — the deleted secret, the ternary, the flat reserve, the hardcoded owner, a sweep reaching across accounts, a re-run rerolling its account, and the rest.A new
tests/kaggle/conftest.pyclears every Kaggle credential before each test. Found the hard way: withKAGGLE_API_TOKEN_2exported on a dev box, the "a fork gets no secret" test authenticated to a real account and read that week's actual hours over the network. It failed for a right-looking reason, and would have PASSED had the quota been low.One claim is narrower than it looks, and the limit is in the test. The account draw is salted apart from the sampling draw, but the statistical test for that does not work and was tried: removing the salt moves the measured share of account 1 among sampled-in runs from a 0.0039 gap to a 0.0059 one over 200k ids — both inside noise, because
%100and%1000000of one digest are independent enough. A test asserting independence therefore cannot fail on the mutation it exists for. It asserts the derivation instead, and says so.What still needs a real dispatch
A green tick here proves nothing, because the failure being fixed IS a green run. Two forced dispatches, one per account, are what confirm it: the job summary should name the sampled account, the account used, the authenticated username and the quota pair the weights came from, and a kernel should actually run.