Repository navigation
Studio: Use via API button on the Train page - #15996
Conversation
Opens Settings > API on a new Training example filled from the current training form: upload a JSONL file, create the fine-tuning job with the form's settings, follow its events, then chat with the trained model. Only an allowlist of settings is carried over; tokens, host paths, offload, drafter and Hub / S3 dataset fields never are.
|
@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: 58d2560b51
ℹ️ 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 (const [flag, fallback] of Object.entries(FLAG_DEFAULTS)) { | ||
| const value = payload[flag as keyof typeof FLAG_DEFAULTS]; | ||
| if (value != null && value !== fallback) extras[flag] = value; | ||
| } | ||
| extras.train_on_completions = payload.train_on_completions; |
There was a problem hiding this comment.
Preserve the selected decision-model checkpoint subfolder
When the Train page selects Laya's multilingual or typed-decisions checkpoint, the generated request preserves is_decision but drops payload.model_subfolder. These checkpoints share the same convaiinnovations/laya model name and are distinguished only by their subfolder (studio/backend/core/systemone/catalog.py). The decision trainer reads config.get("model_subfolder") to select the checkpoint, so running the example silently trains the root English checkpoint instead of the selected model. Include the non-null checkpoint subfolder in the allowed extras so the API example reproduces the selected training setup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the latest commit: the example now sends model_subfolder whenever the form sets one, so a Laya multilingual or typed-decisions run reproduces the selected checkpoint. The backend contract fixture gained a decision body, and the route's own validation keeps the subfolder on the TrainingStartRequest.
|
The Windows staging leg fails 6 of the 10 cases in the new The assert request.local_datasets == [str(Path(f"/uploads/{FILE_ID}.jsonl"))] |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96ad29547a
ℹ️ 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".
| extras.train_on_completions = payload.train_on_completions; | ||
| if (payload.format_type && payload.format_type !== "auto") { | ||
| extras.format_type = payload.format_type; | ||
| } |
There was a problem hiding this comment.
Preserve the selected dataset row range
When the Train form specifies a start or end row, the generated example drops dataset_slice_start and dataset_slice_end, even for an uploaded dataset. buildTrainingStartPayload includes these values, and trainer.py uses them to restrict the training rows; without them, the API example trains on the entire uploaded file instead. Include non-null slice bounds in the extras so copying the example does not silently change the training data or substantially increase the run time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed, together with the rest of this class: instead of a hand-kept allowlist, every field of the Train payload now has a route in TRAINING_FIELD_ROUTE (OpenAI field, Studio setting, derived, or kept on the host), typed over the whole request so a new field fails typecheck until it is placed. The example now also carries the row range, the embedding learning rate, gradient clipping, gradient checkpointing, the save interval, the vision image size and trust remote code when set. A new test sets every Studio setting to a non-default value and requires each one in the example, and the backend contract fixture gained a body with all of them, accepted unchanged by the route.
| const extras: Record<string, unknown> = { | ||
| "learning_rate": payload.learning_rate, | ||
| }; |
There was a problem hiding this comment.
Carry over the CPT embedding learning rate
For a Continued Pretraining run with a custom embedding learning rate and embedding targets enabled, this mapping preserves the main learning rate but discards payload.embedding_learning_rate. The training worker then substitutes learning_rate / 10 when the field is absent (studio/backend/core/training/worker.py), so the generated example silently uses different optimizer settings from the Train form. Include the non-null embedding learning rate in the allowed extras.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed, together with the rest of this class: instead of a hand-kept allowlist, every field of the Train payload now has a route in TRAINING_FIELD_ROUTE (OpenAI field, Studio setting, derived, or kept on the host), typed over the whole request so a new field fails typecheck until it is placed. The example now also carries the row range, the embedding learning rate, gradient clipping, gradient checkpointing, the save interval, the vision image size and trust remote code when set. A new test sets every Studio setting to a non-default value and requires each one in the example, and the backend contract fixture gained a body with all of them, accepted unchanged by the route.
…embedding LR, clipping, checkpointing
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
`Repo tests (CPU, rest-2)` is red on main since #15996 (Use via API button on the Train page). It now fails on unrelated PRs, for example #16024: ``` test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding[5] AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding ... 'studio/backend/tests/test_training_api_snippet_contract.py:19: read_text()' ``` The new snippet contract test reads its JSON fixture `fixtures/training_api_job_bodies.json` with `read_text()`. On Windows that decodes as cp1252, so the test breaks as soon as the fixture gains a non-ASCII byte. The guard is right and the test was wrong. The fix is `read_text(encoding = "utf-8")`. ## Verification - `tests/test_source_read_encoding.py`: fails on main (the one site above), 16 passed here. - `studio/backend/tests/test_training_api_snippet_contract.py`: 12 passed.
…op startup screens (#16069) ## What changed Studio in a non-English language showed English in several places that the parity check could not see, and `npm run i18n:check:strict` on `main` has failed since #15996 (Studio frontend CI, "Locale parity" step). - `settings.apiKeys.trainingApi` (8 keys) added to all 13 overlays. This turns the Locale parity step on `main` green again. - `managedEngines` (the More engines / vLLM / SGLang settings, about 45 strings) was `managedEngines: en.managedEngines` in 11 overlays, so the keys existed but shipped English. Now translated in ar, de, es, fr, hi, it, ja, ko, pt-BR, ru and zh-CN. - Settings > Agents configuration notes were still English in 10 overlays. - pt-BR: the Settings > Resources llama.cpp backend block and the GPU rendering old-driver warning were still English. - Stale translations whose English was reworded later: `decisions.description` still named "Laya" in every overlay; pasted-text description, GGUF quantization list description (also named the "On Device" tab in English), upload label ("Or upload a local file"). - Mistranslations found in review: he (setup code "expired" instead of "expires", "unloaded to the GPU" instead of "offloaded", message count), hi (Connections description, gender agreement, "unsaved changes"), it and pt-BR (account reset description), sv (engine "offload" instead of "unload"), fr ("full screen" for the in-app full view). - `check-parity.ts` now fails when an overlay reuses an English subtree, so a `section: en.section` alias cannot pass the key check again. ### Shared screens moved into the catalog The first screens every user sees were hardcoded English. They now go through `t()`, with translations in all 13 languages: - Sign-in and first-run password setup (`auth-form.tsx`), and browser tab titles (route `staticData` now only takes a `titleKey`). - The remote code consent dialog. Model name, provider and the follow-up note are slots, so each language picks its own word order and sentence spacing. - Guided tour chrome (badge, Skip / Back / Next / Done, tip, Read more). - Release notes panels and the llama.cpp / whisper.cpp / audio.cpp runtime update card (runtime lists use `Intl.ListFormat`, backend names reuse the existing `llamaBackend.backends.*` keys). - Desktop startup, install, repair, update, diagnostics, install location and window titlebar labels. Startup phase messages are now message keys translated at render, and `LogDetails` takes full show/hide labels instead of prefixing an English verb to a noun. ### Second review pass A second, independent review (a back-translation of every overlay string plus a read of its flagged rows) found more strings whose English changed after they were translated, or that use the wrong sense of a word: - English changed, translations did not: the LoftQ, RS-LoRA and DoRA option descriptions, the "Chat API" heading, the "Not set" Hugging Face token status (still "Add"), the loaded-models drag handle label, and the generation details description. - Dropped content: the invalid Hugging Face ID errors leave out the `--` / `..` and `.git` rules that `hub-resource-id.ts` enforces, and the chat import/export descriptions leave out Markdown although import accepts `.md`. - Wrong sense: the Japanese log notice had writing and reading reversed. In Arabic, "upload" and "transcribe" used the words for load and copy, "Unload" read as "cancel download", "offload" read as "unload", and "State" said "Input". In Hebrew, "Enable", "Resume training" and "Resuming" read as restart / new training. zh-CN used the "Projects" word for "Items". "Archives" read as "Files" in es and pt-BR. Also ru "Best loss", fr "Fork chat", de "Runtime", and the Hebrew and Swedish engine and HTML-card descriptions that still described older behaviour. - The Arabic "shell" term الصدفة is correct (it is the established computing term); it now carries "(Shell)" to avoid the reading as "chance". 155 strings across the 13 overlays. A key-by-key diff against the previous commit confirms only the listed entries changed. ### Language menu Settings > General > Language is now searchable: a pill search field (the same control as the font picker), languages sorted by English name with the native name first, Auto detect fixed above the scrolling list, a wider panel, and no scroll arrows. It opens on the language in effect, and scrolls with the mouse wheel inside the Settings dialog (the popover is modal, as the font picker's is). Two notes that still pointed at the old Sandbox and Remote access tab names now name Security and Remote & LAN.  ## Verification - `npm run i18n:check:strict`: 0 missing keys, no errors, all 13 overlays (fails on `main`). - `npm run typecheck`, `npm run build`, `npm run bundle:check` pass. - `npm test`: 14456 pass; the 4 failures in `tests/hub-gguf-card-unified-budget.test.ts` also fail on `main` (missing `@/lib/folder-icons` stub) and are unrelated. - `biome check` on the changed files reports the same 13 existing formatter diagnostics as on `main`. - Screenshots: sign-in and first-run setup pages from a local Studio build in en / ja / ar; the consent dialog (custom-code and unsafe-files variants) and the Desktop startup screen rendered from the same components in a local harness, since this host has no non-GGUF model to load and does not run the Desktop shell. - A 180-string sample per locale (weighted toward delete, password and security strings) was reviewed for meaning; nothing misleading was found on those warnings. ## Not covered About 4,200 user-visible strings in Studio are still hardcoded English and never go through `t()` (Data Recipes, Images, Audio, Video, Hub, Export, API monitor, the per-feature tour step text, and parts of Chat). The image drop zone and crop editor are left for the Images / Video migration, since their labels are built from subject names those pages pass in English. The runtime update toast text comes from `llama-job-lifecycle.ts` and backend job messages and stays English. Desktop native dialogs and menus are English only. Those need their own per-area migrations and are not part of this change. ## Screenshots First-run password setup from a local Studio build (en / ja / ar):  Sign-in page from the same build:  Remote code consent dialog, custom-code variant. Japanese puts the provider first through the `{model}` / `{provider}` slots, and the follow-up note joins without an English space:  Consent dialog, unsafe-files variant:  Desktop startup screen (ja / ar):  --------- Co-authored-by: Unsloth <[email protected]>
…6123) `Repo tests (CPU, rest-2)` is red on main since #16106 (prepare decision datasets faster, in less memory, with row progress). It fails on unrelated PRs, for example #16114: ``` tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding[14] AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding ... 'studio/backend/tests/test_decision_dataset_prefetch.py:298: read_text()' ``` `_frontend_regex` reads `studio/frontend/src/features/studio/preparation-progress.ts` with `read_text()`. On Windows that decodes as cp1252 and breaks as soon as the file gains a non-ASCII byte. The guard is right and the test was wrong, so this adds `encoding = "utf-8"`. This is the same fix #16025 made for #15996. ## Verification - `tests/test_source_read_encoding.py`: fails on main on the line above. 16 passed here. - `studio/backend/tests/test_decision_dataset_prefetch.py`: 11 passed.
The Train page gets the same "Use via API" button the Images and Video pages have. It opens Settings > API on a new Training example that reproduces the current Train page setup through the OpenAI-compatible fine-tuning endpoints, in Python, JavaScript or curl (Linux / macOS or Windows PowerShell), with the API key and server address filled in like the other API examples.
What the example does
files.create, purposefine-tune), named after the dataset the form has uploaded, elsetrain.jsonl.model,hyperparameters(n_epochs,batch_size),seed,suffix(the project name), and Studio settings as extra body fields (Pythonextra_body, flat JSON for JavaScript and curl).fine_tuned_model.Cancelling a job is shown as a separate snippet.
Every field of the payload the Start button sends has a route (
TRAINING_FIELD_ROUTE, typed over the whole request, so a new field fails typecheck until it is placed): the OpenAI fields above; Studio settings, sent where the form sets them (learning rate as the exact string, max steps, training type, 4-bit, sequence length, image size, trust remote code, dataset row range, format and custom mapping, embedding learning rate, gradient accumulation, warmup, save interval, weight decay, gradient clipping, packing, optimizer, scheduler, LoRA rank / alpha / dropout / targets, gradient checkpointing, rsLoRA / DoRA / LoftQ, train on completions, layer choices, image / audio / embedding / decision run type and the decision checkpoint subfolder); and host-side fields that never appear (tokens, cache and host paths, offload, evaluation, logging, resume, drafter, Hub / S3 dataset fields). A Hub or S3 dataset gets a note to upload it as a file instead.Without a Train page setup (opened from Settings directly), the card shows a placeholder example and says so.
Tests
studio/frontend/tests/training-api-snippets.test.ts(21): field routing and mapping (every Studio setting set to a non-default value must reach the example, nothing host-side may), every language and OS, shell and PowerShell quoting of hostile values, no secrets or host paths, events de-duplication, cancel snippet, button wiring.studio/backend/tests/test_training_api_snippet_contract.py(12): every generated job body (including one with every Studio setting set) goes through the fine-tuning route's own validation and_training_config; each setting lands on theTrainingStartRequestunchanged, and keys outside the contract are still refused. The bodies come from the frontend generator (UPDATE_TRAINING_API_BODIES=1regenerates them), so the two sides cannot drift apart.Screenshots
Before / after on two fresh
install.sh --localbuilds (main and this branch), with the Train form set tounsloth/Qwen3-0.6Band its recommended defaults.The Train header gains the API button, with the same "Use via API" tooltip as Images and Video:
Settings > API: before, the Quickstart has no Training tab. After, the button opens it filled from the form: the model, the step count and the batch size the form shows.