Repository navigation
feat(studio): draft MLX tool, video, grammar, KV and LoRA replies - #16441
Conversation
|
@codex review |
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: e4c08b3002
ℹ️ 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".
A tool reply skipped the drafter, and chat offers tools by default, so a speculative load ran at plain speed. The target verifies every token a call is parsed from, so tool-call text does not depend on the draft.
The draft now sees the prompt as the clip's frames expand it. A speculative batch still does not decode a clip, so these replies run one at a time.
Rollback works on quantized caches on the single path. Speculative batches run on full-precision caches, so such a load declines the resident batch and replies one at a time. TurboQuant's mlx-lm notice can now apply beside a requested draft.
An adapter on a text architecture stays refused, since it loads only through mlx-lm and speculation runs on mlx-vlm.
A speculative load with mx.quantize KV rows runs its replies together again where unsloth-zoo can draft those rows. TurboQuant, whose caches a speculative batch cannot run, still replies one at a time, as does a load on an older unsloth-zoo.
A fixed multi-reply command on a speculative load now hands each row its clip, whose row resumes no cache because token ids do not vary with the clip. A resident batch still refuses a clip, and a load with a quantized KV cache declines, since only a resumed row carries the quantization.
|
@codex review |
e4c08b3 to
bd805ac
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Review and CI are done at bd805ac.
|
[skip ci]
|
Review record for #16441, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#693. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
…les (unslothai#2365) Short MLX streams can close without recording completed plain decoding, and MTP initialization can allocate and replay work before the controller chooses to draft. Replay and one-time shortlist construction can also distort the controller's recurring cost estimates. Record completed plain work on stream close, defer unused draft preparation, and account for folded replay and separately timed replay consistently. Keep full-width draft projections on the native table, exclude shortlist construction from recurring samples, and confirm cold plain-decoding costs before comparing rates. For settling processors, queue the next plain step before delivering the current output and preserve that committed output if the queued step fails. This is a runtime dependency for [unslothai/unsloth#16441](unslothai/unsloth#16441). Merge this companion before Unsloth #16441. Validation of executable revision `027d5869` (the final `8a06af54` commit removes comments only): - [macOS 15](https://github.com/NilayYadav/unsloth/actions/runs/41520265611) and [macOS 26](https://github.com/NilayYadav/unsloth/actions/runs/41520265804) each passed 84 native Metal checks without skips and completed five MLX LoRA training steps. Installed and imported revisions were verified. Reverting only the native-head selector failed three shape checks; reverting only the shortlist first-use marker failed its accounting check. Restoring the changes passed both controls and the full selection. - [Linux](https://github.com/NilayYadav/unsloth/actions/runs/41520265740) and [Windows](https://github.com/NilayYadav/unsloth/actions/runs/41520265669) each passed 70 CPU simulation checks, with five explicit skips. Those checks establish portability and controller behavior; the native Metal runs cover the skipped GPU operations. - The latest cost-regime differential has nine failing-before/passing-after checks and no head failures. An independent matrix covers 4,980 replay-cost and subset-selection cells: 1,961 already correct, 3,019 corrected, zero regressions. - The remote Core switchboard finished with no regression in regression smoke, SFT and inference smoke, using Colab L4 and Kaggle T4 GPUs. It left no processes behind. The final comment-only head is AST-equivalent to the tested revision. - All eight current Metal feature workers passed: packed 4-bit KV-cache updates, a loaded nonzero LoRA adapter, a single red video, and a batch of separate red and blue clips. Every paired rendered reply matched. Actual video patch tensors reached the model, and both head batch rows drafted. The probe was corrected to recognize this model's 2D patches. - A three-row 8-bit KV batch preserves each rendered reply against its individual baseline, with 8, 21, and 12 proposed tokens. The Tokyo reply reaches the same 24-token budget on both arms. - Exact-head review approved the executable revision. The final comment pass removed eight comment lines and passed strict AST checks. Full-stack inference performance retains diagnostic failures. The [first comparison](https://github.com/NilayYadav/unsloth/actions/runs/41525979139) preserves all 330 rendered replies but fails late tool time to first token: 434 to 475 ms, beyond the 7.8% noise band. The [unchanged repeat](https://github.com/danielhanchen/unsloth-staging-2/actions/runs/41551616128) preserves another 330 replies and confirms a tool regression: late decode falls from 74.2 to 46.5 tokens/s, beyond the 12.5% noise band, while total response time rises from 0.599 to 0.760 seconds with a harmful paired interval. Plain chat passes every phase of the repeat; grammar remains inconclusive. Cold and first-use costs are reported separately and also include failing cells. Green collection jobs and passing correctness tests do not clear this gate. The performance measurements above come from standard GitHub macOS VMs. A subsequent execution trace reports `Apple Paravirtual device`; physical GPU identity and exclusive allocation were not established for the benchmark runs. These remain diagnostic timing failures; an exclusively reserved Apple GPU would be needed to establish a final hardware performance verdict. Release decision: proceed based on team validation and the correctness evidence above, accepting the remaining performance uncertainty. The additional exclusive-Apple-GPU benchmark is not a prerequisite for this merge. No passing hardware performance verdict or general speedup is claimed; the diagnostic VM timing failures and recorded coverage limits remain.
MLX speculative decoding currently skips tool, video, grammar-constrained, KV-quantized and multimodal LoRA replies. The drafter's memory fit also needs the selected KV-cache width.
This change enables those supported replies to draft, keeps each fixed video-batch row attached to its own clip, and passes the cache width through drafter fitting. Grammar processors follow tentative tokens on a copy of their committed matcher and commit only settled output; an error in one row remains isolated to that row. Affine quantized KV caches can batch where the runtime supports them. TurboQuant, resident video batches, text-only LoRA loads, logprobs, diffusion, encoder-state models and distributed inference retain their existing restrictions.
Grammar drafting and affine KV batches require the merged unsloth-zoo #2359. On older runtimes, grammar replies decode without drafting and quantized loads reply individually. Validation also identified runtime cost-accounting and initialization defects addressed by unsloth-zoo #2365; merge that companion first.
Validation at source
37836adeewith companion executable revision027d5869:Full-stack inference performance retains diagnostic failures. The first comparison preserves all 330 rendered replies but fails late tool time to first token: 434 to 475 ms, beyond the 7.8% noise band. The unchanged repeat preserves another 330 replies and confirms a tool regression: late decode falls from 74.2 to 46.5 tokens/s, beyond the 12.5% noise band, while total response time rises from 0.599 to 0.760 seconds with a harmful paired interval. Plain chat passes every phase of the repeat; grammar remains inconclusive. Cold and first-use costs are reported separately and also include failing cells. Green collection jobs and passing correctness tests do not clear this gate.
The performance measurements above come from standard GitHub macOS VMs. A subsequent execution trace reports
Apple Paravirtual device; physical GPU identity and exclusive allocation were not established for the benchmark runs. These remain diagnostic timing failures; an exclusively reserved Apple GPU would be needed to establish a final hardware performance verdict.Release decision: proceed based on team validation and the correctness evidence above, accepting the remaining performance uncertainty. The additional exclusive-Apple-GPU benchmark is not a prerequisite for this merge. No passing hardware performance verdict or general speedup is claimed; the diagnostic VM timing failures and recorded coverage limits remain.
Three upstream style-check failures were reproduced on the exact CI base with byte-identical offending files and tests; pre-commit passed.
The contributor also reported one differing row in an earlier three-row 8-bit KV batch experiment, with its cause unconfirmed. The current native tests and small-model paired runs do not establish parity for that separate configuration or every checkpoint. That earlier report remains a limitation; a non-speculative load remains available when exact reproducibility is required.
UI before and after
The obsolete KV-cache warning is present before and absent after. Both isolated Studio builds receive the same seeded MLX loaded status; this comparison verifies presentation only. BEFORE is merge base
6401ceda2; AFTER is95e18fe31, whose executable code matches current source head37836adee. The composite was inspected manually, and the warning change was checked in Chromium, Firefox, WebKit and Microsoft Edge. Cross-platform Studio/Desktop validation runs in staging CI.