Skip to content

Studio: ask Laya questions without instructions by their id - #16496

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:laya-question-id-instructions
Nov 4, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:laya-question-id-instructions

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

A Decision API question with no instructions was sent to Laya on PyTorch, the default model, as an empty question. Every such question in a request read the same text, so the answer had nothing to do with what was asked. This also happens in the Try dialog when the question box is left blank. The reference encoder, llama.cpp and MLX already ask by the question id.

Laya on PyTorch now does the same, in Studio and in the library, for both predictions and training rows, so a fine-tune sees the same text it is later served. On real Laya, a noul question with no instructions went from 0.57 to 0.97 on a refund message, and from 0.31 to 0.0004 on a thank-you message. Questions that have instructions are unchanged.

Fine-tunes trained earlier from rows with no instructions learned on the empty text, and from now on they read the id instead.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reached Codex review convergence at NilayYadav#1094 on 88aea30.

danielhanchen added a commit that referenced this pull request Nov 3, 2026
…he stop (#16525)

## Summary


`studio/backend/tests/test_inference_worker_shutdown_exit.py::test_shutdown_exit_still_relays_the_mirrored_stderr_tail`
(added in #16338) fails intermittently in `(Python 3.13, g-r)`. In the
last 30 PRs it hit #16495, #16496, #16498, #16500 and #16509:

```
assert "the last line before shutdown" in result.stderr
E   assert 'the last line before shutdown' in ''
```

That is a real product bug, not a flaky test. The worker can drop its
last stderr lines when it exits, which are the lines the parent reports
when a worker dies.

**Cause.** `_tail_sink_to_stderr`, the mirror pump thread, decided it
was done from two separate steps: a read that came back empty, then a
check that `stop` was set. If the pump is descheduled between those two
steps, the worker writes its last lines to the sink and calls
`stop_worker_stderr_mirror()` in the gap. The pump then sees "empty
read, and stop is set", exits, and never relays them.

I instrumented the stop sequence in a child that runs the test's exact
script, 900 times on 24 threads. On a failing run:
- the sink held all 1720 bytes at stop time;
- the pump made exactly one read, which returned empty and was logged
after the stop;
- it emitted 0 bytes, and both threads ended cleanly within 4 ms.

So nothing timed out and nothing was cut off; the lines were simply
never read.

## Change

`studio/backend/utils/worker_stderr.py`, `_tail_sink_to_stderr`: the
pump records `stop.is_set()` before each read and only finishes on an
empty read that began after the stop was set. Bytes written before
`stop.set()` are therefore always read. Nothing else changes: the poll
interval, compaction, the relay, the join timeouts, and what a live
worker mirrors.

`studio/backend/tests/test_inference_worker_shutdown_exit.py`: new
`test_the_pump_reads_once_more_after_an_empty_read_that_raced_the_stop`.
It drives the pump with a reader whose first read returns empty and sets
`stop` in that same call, so the race is forced deterministically rather
than left to scheduling.

## Testing

| check | main | this branch |
|---|---|---|
| instrumented child, 300 / 600 / 900 parallel runs | 1 lost the whole
tail in each batch | 0 of 900 |
| new deterministic test | fails (`b'' == b'the last line before
shutdown\n'`) | passes |
| `test_shutdown_exit_still_relays_the_mirrored_stderr_tail`, `--count
40 -n 16` | 1 failed of 40 | 240 of 240 passed (`--count 80 -n 16`,
three times) |

- `test_inference_worker_shutdown_exit.py` and
`test_inference_worker_stderr_tail.py`: 77 passed.
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-11-04T08:54:07.094907Z 2750c31 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 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: 88aea3048c

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 3, 2026
@Imagineer99

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@Imagineer99

Copy link
Copy Markdown
Member

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 3, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 3, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4ea1df2dc5

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

@NilayYadav

Copy link
Copy Markdown
Collaborator 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: 4ea1df2dc5

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

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 2aca5b231e

ℹ️ 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 danielhanchen self-assigned this Nov 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member

pre-commit.ci run

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 2750c317ba

ℹ️ 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 to Imagineer99/unsloth that referenced this pull request Nov 4, 2026
@danielhanchen
danielhanchen merged commit d0a83c4 into unslothai:main Nov 4, 2026
danielhanchen added a commit that referenced this pull request Nov 4, 2026
A Laya fine-tune could be exported to GGUF from the Export page, which
says the file is for llama.cpp's decision server, but the Decision API
never used it. The fine-tune kept answering on PyTorch, even with the
runtime set to llama.cpp, so the export did nothing.

A Laya fine-tune with a current export now answers through llama.cpp
when the runtime is set to llama.cpp, and the Decision settings show the
Runtime row for it. Auto stays on PyTorch, so existing fine-tunes keep
the same answers unless llama.cpp is chosen. On llama.cpp, a state past
the model's window is refused, and so is a question over the option or
instruction budget, which llama.cpp would otherwise cut without saying
so. Long options are answered as on PyTorch.

Exports of multilingual fine-tunes remain a dead end. llama.cpp refuses
the mmBERT tokenizer, so choosing llama.cpp for one returns a 503 with
the reason, and the Export page still offers them. `confidence` also
differs by runtime: the same fine-tune and question gave 0.97 on
llama.cpp and 0.87 on PyTorch. The stock Laya models stay on PyTorch,
Laya GGUF is unchanged, and a fine-tune with no export or a stale one
works as before.

Merge after #16496, which asks blank Laya questions by their id the way
llama.cpp already does.


### Before / after

Settings > API > Decision, with a Laya fine-tune that has a current GGUF
export and the runtime set to llama.cpp. Before, there is no Runtime row
and the fine-tune answers on PyTorch. After, the Runtime row shows
llama.cpp, and the settings API reports `effective_backend: llama.cpp`,
`has_gguf_form: true`.

![Decision API settings before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16511/pr16511_before_after-d04e0a2ace19.png)

---------

Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants