Skip to content

Studio: refuse Laya choice questions whose options would be cut short - #14558

Merged
Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:refuse-truncated-laya-options-answering
Oct 22, 2026
Merged

Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:refuse-truncated-laya-options-answering

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Laya reads a question's options inside a fixed token budget (192 tokens for Laya English, 256 for Laya Multilingual). Past it, each option keeps only its share of the budget, so longer options are silently cut and the Decision API still answers with HTTP 200. When only the descriptions tell the options apart, the answer goes wrong with no warning: a double-charge refund ticket went to the "new feature" team at 32 options on Laya Multilingual. Plain labels get cut too: with 40 labels on Laya English, mobile_app_crash and mobile_app_slow both read as mobile_app, and a crash ticket went to mobile_app_slow at 99.8%. At 118 options Laya English said "Shorten the state" for a two-sentence state.

A choice question is now refused with a 422 naming the question and the budget when one of its options would be cut, the same way a state that does not fit is already refused. Options that fit their share, including long lists of short labels, get exactly the same answers as before.

@NilayYadav NilayYadav self-assigned this Oct 21, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-10-22T07:48:08.155822Z a7f4692 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: a477bb9359

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

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. Swish!

Reviewed commit: a477bb9359

ℹ️ 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 Oct 21, 2026
…heck test (#14561)

`test_block_dequant_is_checked_for_its_peak_intermediates[nvfp4]` (added
in #14510) failed on #14558's Backend CI `(Python 3.13, a-k)` run (job
119452419222), on the same base where main's run passed it. #14558 only
touches Laya files:

```
E   AssertionError: ([50298880], 56627200)
E   assert ([50298880] and 50298880 >= (0.9 * 56627200))
```

The test samples `RssAnon` while `dequant_block` runs and requires the
host RAM charge to cover 90% of the growth. `RssAnon` is process-wide,
so in a busy xdist worker anything else allocating at the same time is
counted as the dequant's peak.

Run alone, the charge is close to exact. Charge / growth over 12 local
runs each:

| format | min | max |
|---|---|---|
| nvfp4 | 0.963 | 1.038 |
| mxfp8 | 0.990 | 1.078 |

CI's 0.889 is about 6 MB of unrelated growth. The product's estimate is
right; the measurement was noisy.

## Change

The measurement runs three times, and the smallest growth is the one
checked against the same 0.9 bar. Unrelated activity can only add to a
reading, so the minimum is the closest to the dequant's own peak, and
the guard keeps its strength.

## Testing

- Three back-to-back runs of both parameters: pass.
- Sabotage: charging only the bf16 output, without the chunk
intermediates, in `diffusion_comfy_block.py` fails both formats
(`[33554432] vs ~50 MB`).
@Lyxot Lyxot self-assigned this Oct 22, 2026
Lyxot added 2 commits October 22, 2026 15:10
The refusal fires once options pass head_max_len minus the 16 tokens build_sequence reserves for the question, so the message now names that limit (176 for Laya English) instead of head_max_len. The test also covers the exact budget boundary and checks the vendored build_sequence shortens options exactly when the API refuses.
@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Pushed cd9c190a55 and a merge of latest main (the branch was 61 commits behind).

  • The refusal now names the limit that actually triggers it: head_max_len - 16, i.e. 176 tokens for Laya English and 240 for Laya Multilingual. Before, it said 192, so options totalling 180 tokens were told they exceeded a 192-token budget.
  • The test now covers the exact boundary: options totalling 176 tokens are answered.
  • The test also checks that the vendored build_sequence really shortens options in exactly the cases the API refuses, so a future change to the vendored rule can't leave the tests green.

@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 3322db7a76

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

@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: a7f4692ff9

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

@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Codex review and CI are done on head a7f4692ff9.

Codex: "Didn't find any major issues" on a7f4692ff9: #14558 (comment) (it also passed on the earlier head 3322db7a76).

CI: upstream jobs were stuck in the queue, so CI ran on a staging copy with the same head and base (Lyxot#189): 35 pass, 4 fail, 2 skipped. None of the 4 failures come from this PR. Staging PR Lyxot#188, which has the same base (main at 465263ef92), fails the same 4 jobs:

  • Core (HF=4.57.6 + TRL<1, default, latest): tests/utils/test_single_row_cached_attention.py and "Unsloth cannot find any torch accelerator" on CPU runners.
  • Repo tests (CPU, studio): tests/python/test_accelerator_skip_guards.py flags test_decode_fused_rope.py:230, which came in from main.

What changed in this round:

  • cd9c190a55: the refusal now names the limit that actually triggers it (176 tokens for Laya English, 240 for Multilingual) instead of head_max_len. The test now covers the exact boundary and checks that the vendored build_sequence shortens options in exactly the cases that are refused.
  • Merged latest main (the branch was 61 commits behind).
  • a7f4692ff9: a pre-commit.ci autofix that only reformats tests/test_moe_autotune_cache_validate.py.
  • The two earlier Codex threads (the 48-token per-option cap, and the last option clipped only when the state is empty) were answered with why they aren't changed here, and resolved.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

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