Skip to content

Give the launcher signal tests a worker to themselves - #11085

Merged
danielhanchen merged 1 commit into
mainfrom
fix/serialise-kaggle-launch-signal-tests
Sep 16, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/serialise-kaggle-launch-signal-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, python) failed on an unrelated PR with a 120s timeout in
tests/kaggle/test_launch_cleanup.py::test_a_reentrant_log_inside_the_delete_retries_does_not_abandon_them:

AssertionError: the launcher was still alive 120s after its signal. Launcher said: (nothing logged after READY)
Stack at the abort: Fatal Python error: Aborted
Current thread (most recent call first):
  File ".../test_a_reentrant_log_inside_th0/runner.py", line 22 in <module>

The file's own faulthandler diagnostic answers this: line 22 is the stall, so the child never reached its
signal handler at all. The budget stopped measuring "did the handler run" and started measuring "was the
child ever scheduled".

Why it happens

The step runs -n 4 with xdist's default load scheduling, so these tests are free to land on four
workers of a four-core runner at once. Each starts a real launcher subprocess and signals it, so four
of them together are eight processes contending for four cores. _DEATH_BUDGET_SEC's comment already
records this pressure, noting the SIGINT case once needed over 30 seconds purely to be scheduled.

The fix

Put the file in one xdist group so its tests share a worker, and pass --dist loadgroup on the two
jobs that run them. Ungrouped tests still distribute exactly as before, so this costs no parallelism
anywhere else.

Raising the budget was the alternative and it is the wrong lever: the test would still be timing how
loaded the box is, just with a larger number, and a real hang would take longer to report.

Verification

Worker assignment over the same selection, measured rather than assumed:

scheduling workers used
--dist loadgroup gw3 only
default load gw0, gw1, gw2, gw3

Whole file under the CI flags, -n 4 --dist loadgroup --timeout=330: 27 passed.

The failure this addresses is a flake, so a green run does not prove much on its own. What is checked
here is the mechanism: the tests now share a worker, which removes the contention the stack pointed at.

`Repo tests (CPU, python)` failed on an unrelated PR with a 120s timeout in
`tests/kaggle/test_launch_cleanup.py::test_a_reentrant_log_inside_the_delete_retries_does_not_abandon_them`:

```
AssertionError: the launcher was still alive 120s after its signal. Launcher said: (nothing logged after READY)
Stack at the abort: Fatal Python error: Aborted
Current thread (most recent call first):
  File ".../test_a_reentrant_log_inside_th0/runner.py", line 22 in <module>
```

The file's own faulthandler diagnostic answers this: line 22 is the stall, so the child never reached its
signal handler at all. The budget stopped measuring "did the handler run" and started measuring "was the
child ever scheduled".

## Why it happens

The step runs `-n 4` with xdist's default `load` scheduling, so these tests are free to land on four
workers of a four-core runner at once. Each starts a real launcher subprocess and signals it, so four
of them together are eight processes contending for four cores. `_DEATH_BUDGET_SEC`'s comment already
records this pressure, noting the SIGINT case once needed over 30 seconds purely to be scheduled.

## The fix

Put the file in one xdist group so its tests share a worker, and pass `--dist loadgroup` on the two
jobs that run them. Ungrouped tests still distribute exactly as before, so this costs no parallelism
anywhere else.

Raising the budget was the alternative and it is the wrong lever: the test would still be timing how
loaded the box is, just with a larger number, and a real hang would take longer to report.

## Verification

Worker assignment over the same selection, measured rather than assumed:

| scheduling | workers used |
| --- | --- |
| `--dist loadgroup` | `gw3` only |
| default `load` | `gw0`, `gw1`, `gw2`, `gw3` |

Whole file under the CI flags, `-n 4 --dist loadgroup --timeout=330`: 27 passed.

The failure this addresses is a flake, so a green run does not prove much on its own. What is checked
here is the mechanism: the tests now share a worker, which removes the contention the stack pointed at.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T07:43:45.740650Z b0bc941 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: b0bc94112b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen added a commit that referenced this pull request Sep 16, 2026
)

`Backend CI` has been red on main since the reasoning-budget controls landed, with three
multi-account tests answering `{"detail":"Failed to get status"}`, a message naming neither
the field nor the cause.

Four reasoning fields were added to `_InferenceRuntimeFields` and they are not Optional,
which is right: `LlamaCppBackend.__init__` sets `_reasoning_budget = -1` and
`_reasoning_budget_message = ""`, so the real backend never answers None for them.
`_llama_runtime_fields` mirrors every field in that model off the backend, and the test
doubles answered None for anything nobody set, so /status raised ValidationError and the
route returned 500. The PR that added the fields is correct; the doubles were not.

## What changed

`FakeLlamaCppBackend` carries the runtime surface /status mirrors, at the values
`LlamaCppBackend.__init__` gives them. The same block was being re-declared by hand in the
per-test fakes, which is what the shared double exists to end. Fields the real backend holds
only as `_name` are declared under that name, so the double claims nothing production cannot
read.

The blanket `__getattr__` several fakes carried defeated that fallback: answering None for
the public name hides the private slot that has the value. It lives on the shared double now,
scoped to the names /status mirrors and taken from the model rather than listed. Everything
else raises `AttributeError` as before, so `getattr(backend, name, default)` keeps its
default; a blanket version broke `supports_tool_passthrough` defaulting to `supports_tools`,
which Codex caught during review.

Attributes the status route reads straight off the backend rather than through the model-field
loop are declared too, at the real backend's initial values.

## Coverage

The existing canary drives /chat/completions and never reaches this. A second one builds the
/status runtime payload from the bare double and validates it, failing with the offending
field in the message.

Mutation-tested: removing the four reasoning fields reproduces the original break and the
canary names all four; answering None instead of the private slot names the seven
private-only fields; restoring the blanket fallback fails the video chat-completions tests.

All nine files that use the double pass, 110 tests. `(Python 3.13, rest)` is green here,
against red on main.

The two remaining red jobs are inherited from main and fixed elsewhere: the studio shard by
#11065, and the python shard's kaggle launcher flake by #11085.
@danielhanchen
danielhanchen merged commit 9d72fad into main Sep 16, 2026
16 of 19 checks passed
@danielhanchen
danielhanchen deleted the fix/serialise-kaggle-launch-signal-tests branch September 16, 2026 08:23
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…lothai#11076)

`Backend CI` has been red on main since the reasoning-budget controls landed, with three
multi-account tests answering `{"detail":"Failed to get status"}`, a message naming neither
the field nor the cause.

Four reasoning fields were added to `_InferenceRuntimeFields` and they are not Optional,
which is right: `LlamaCppBackend.__init__` sets `_reasoning_budget = -1` and
`_reasoning_budget_message = ""`, so the real backend never answers None for them.
`_llama_runtime_fields` mirrors every field in that model off the backend, and the test
doubles answered None for anything nobody set, so /status raised ValidationError and the
route returned 500. The PR that added the fields is correct; the doubles were not.

## What changed

`FakeLlamaCppBackend` carries the runtime surface /status mirrors, at the values
`LlamaCppBackend.__init__` gives them. The same block was being re-declared by hand in the
per-test fakes, which is what the shared double exists to end. Fields the real backend holds
only as `_name` are declared under that name, so the double claims nothing production cannot
read.

The blanket `__getattr__` several fakes carried defeated that fallback: answering None for
the public name hides the private slot that has the value. It lives on the shared double now,
scoped to the names /status mirrors and taken from the model rather than listed. Everything
else raises `AttributeError` as before, so `getattr(backend, name, default)` keeps its
default; a blanket version broke `supports_tool_passthrough` defaulting to `supports_tools`,
which Codex caught during review.

Attributes the status route reads straight off the backend rather than through the model-field
loop are declared too, at the real backend's initial values.

## Coverage

The existing canary drives /chat/completions and never reaches this. A second one builds the
/status runtime payload from the bare double and validates it, failing with the offending
field in the message.

Mutation-tested: removing the four reasoning fields reproduces the original break and the
canary names all four; answering None instead of the private slot names the seven
private-only fields; restoring the blanket fallback fails the video chat-completions tests.

All nine files that use the double pass, 110 tests. `(Python 3.13, rest)` is green here,
against red on main.

The two remaining red jobs are inherited from main and fixed elsewhere: the studio shard by
unslothai#11065, and the python shard's kaggle launcher flake by unslothai#11085.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
`Repo tests (CPU, python)` failed with a 120s timeout in
`test_a_reentrant_log_inside_the_delete_retries_does_not_abandon_them`:

    AssertionError: the launcher was still alive 120s after its signal.
    Launcher said: (nothing logged after READY)
    Stack at the abort: Current thread (most recent call first):
      File ".../runner.py", line 22 in <module>

The file's own faulthandler diagnostic answers it: line 22 is the stall, so the child never
reached its signal handler. The budget stopped measuring "did the handler run" and started
measuring "was the child ever scheduled".

## Why

The step runs `-n 4` with xdist's default `load` scheduling, so these tests are free to land on
four workers of a four-core runner at once. Each starts a real launcher subprocess and signals
it, so four together are eight processes contending for four cores. `_DEATH_BUDGET_SEC`'s own
comment records this pressure, noting the SIGINT case once needed over 30 seconds purely to be
scheduled.

## The fix

Put the file in one xdist group so its tests share a worker, and pass `--dist loadgroup` on the
two jobs that run them. Ungrouped tests distribute exactly as before, so no parallelism is lost
elsewhere.

Raising the budget was the alternative and it is the wrong lever: the test would still be timing
how loaded the box is, just with a larger number, and a real hang would take longer to report.

## Verification

Worker assignment over the same selection, measured rather than assumed:

    --dist loadgroup   gw3 only
    default load       gw0, gw1, gw2, gw3

Whole file under the CI flags, `-n 4 --dist loadgroup --timeout=330`: 27 passed.

The failure it addresses is a flake, so a green run proves little on its own. What is checked is
the mechanism: the tests now share a worker, which removes the contention the stack pointed at.
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