Skip to content

Studio: faster frontend type check with TypeScript 7 and bun check - #13986

Merged
NilayYadav merged 4 commits into
unslothai:mainfrom
Etherll:fix/inline-ts7-bun-typecheck-0d93a42e7ac1
Oct 16, 2026
Merged

NilayYadav merged 4 commits into
unslothai:mainfrom
Etherll:fix/inline-ts7-bun-typecheck-0d93a42e7ac1

Conversation

@Etherll

@Etherll Etherll commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The Unsloth Studio frontend type check (npm run typecheck, and the type-check step at the start of npm run build) took about 73 s on every run, including reruns with no changes. It now uses the TypeScript 7 native compiler with incremental builds, and runs bun check instead when a Bun that has it is on PATH. On the same host a cold check takes 8.4 s with tsc or 2.2 s with Bun, and an unchanged rerun takes 1.1 s.

Benchmarks

npm run typecheck (app, node and test projects), one run each, timed with /usr/bin/time. Base is main at 6baec3b; on the rebased branch the tsc path took 7.41 s and bun check 1.84 s.

Run Wall time Peak RSS Exit
base, tsc 5.9.3, cold 72.65 s 2.47 GiB 0
base, tsc 5.9.3, rerun 73.83 s 2.46 GiB 0
head, tsc 7.0.2, cold 8.39 s 2.27 GiB 0
head, tsc 7.0.2, rerun 1.09 s 0.89 GiB 0
head, bun check (Bun 1.4.3), cold 2.24 s 1.41 GiB 0
head, bun check (Bun 1.4.3), rerun 1.90 s 1.47 GiB 0
  • A cold check is about 8.7x faster with tsc and about 32x faster with bun check. An unchanged rerun with tsc is about 68x faster, because the base config re-checked everything on every run.
  • npm run build (cold, tsc path) went from 38.79 s to 14.74 s. Total emitted JS is byte-identical (33,620,229 bytes), since Vite still does the bundling.
  • Incremental rebuilds still catch edits: after a clean 8.03 s run and a 0.85 s rerun, an injected error in src/lib/sse-framing.ts failed in 5.84 s with exit 1, the revert passed in 4.38 s, and the next unchanged run took 0.93 s.

These timings come from a shared 192-core host with other users' jobs running (load average 19 to 44 during the runs, and higher during the head runs than the base runs). Treat them as single samples, not medians.

Benefits

  • Source installs of Unsloth Studio (setup.sh / setup.ps1 run npm run build), the Tauri build and every frontend CI job type-check about 9x faster with tsc, and about 30x faster on machines that have Bun 1.4.3 or newer. Nothing new is required: without Bun the build uses tsc as before.
  • Reruns during development drop from about 73 s to about 1 s, because the incremental build info is now actually used.
  • bun check peaks at about 1.4 GiB instead of 2.5 GiB for the old check.
  • Picking the checker costs one bun --help spawn: median 1.2 ms with no Bun on PATH, 2.7 ms with Bun (20 runs each).

How the type check picks a compiler

scripts/typecheck.mjs replaces the inline tsc commands in build and typecheck:

  • It runs bun --help (no shell, 5 s timeout, color off), strips ANSI codes and \r, and looks for a check command in the list. Bun before 1.4.3 has no check command and would treat bun check as bun run check, so those versions fall back to tsc. No Bun on PATH also falls back to tsc.
  • It uses bun check --build --no-pretty and bun check --project=tsconfig.test.json --no-pretty, not bun --check. --check is a global Bun flag that ignores --build, --project and --no-pretty, and in that position -b means --bun and -p means --print.
  • If package.json has a check script (or cannot be read), Bun is skipped, because bun check would run that script instead of type-checking.
  • Bun is used only when the TypeScript version it follows (process.versions.typescript, 7.0.2 for Bun 1.4.3) equals the pinned typescript version; otherwise the check uses tsc. In auto mode a failing bun check is still rerun with tsc, and the tsc result is final.

UNSLOTH_TYPECHECK overrides the choice:

  • auto (default): the behavior above.
  • tsc: always tsc, Bun is never probed.
  • bun: always bun check. It exits 1 with a message if there is no Bun with check on PATH or if a check script exists, and passes Bun's exit code through otherwise.
  • Any other value exits 2.

TypeScript 7 migration

  • typescript goes from ~5.9.3 to 7.0.2. TypeScript 7 ships no JS API, so the 79 test imports of typescript (77 test files plus tests/helpers/module-stubs.ts and tests/helpers/tsx-ast.ts) now import @typescript/typescript6, a side-by-side TypeScript 6 API package. module-stubs.ts sets esModuleInterop: false, because TypeScript 6 turns it on by default and would wrap the stubs in __importDefault.
  • eslint.config.js imports scripts/eslint-typescript6.cjs first. It is a require hook that sends typescript-eslint's require("typescript") to the TypeScript 6 copy, so npm run lint, npx eslint and editor ESLint all keep working. Lint output is the same as on main (1459 problems: 1126 errors, 333 warnings). Lint is not a CI gate. The hook can be removed once typescript-eslint supports TypeScript 7.
  • baseUrl is removed from tsconfig.json, tsconfig.app.json and tsconfig.test.json using the TypeScript team's ts5to6 tool. The @/* path mapping is unchanged.
  • Two source changes for the TypeScript 6+ lib typings: src/lib/latex.ts adds a non-null assertion on match.indices![1], and src/features/training/lib/training-start-request-id.ts types getRandomValues with ArrayBufferView<ArrayBuffer>.
  • incremental is on for the app, node and test projects. All three .tsbuildinfo files are written under node_modules/.tmp, so nothing new is tracked by git.

CI

studio-frontend-ci.yml keeps the existing npm run typecheck step, which covers the tsc path because runners have no Bun. A new step downloads Bun 1.4.3 for linux-x64 from the GitHub release, checks it against a pinned SHA-256 (taken from the release's SHASUMS256.txt) before running it, and runs UNSLOTH_TYPECHECK=bun npm run typecheck so it cannot silently fall back to tsc. Bun 1.4.3 is the first release with bun check. It was admitted before the usual 7-day release-age wait by explicit maintainer decision. The comment in lint-ci.yml that described the type check as tsc --noEmit is updated.

Dependencies

  • typescript: ~5.9.3 to 7.0.2. The lockfile adds the optional per-platform native compiler packages (@typescript/typescript-<os>-<arch> 7.0.2).
  • Added dev dependency @typescript/typescript6 6.0.2, which brings @typescript/old 6.0.3.
  • overrides gains "typescript": "$typescript" so typescript-eslint's typescript peer dependency resolves to the root version.

Compatibility notes

  • Windows: an npm-installed Bun is a bun.cmd shim. The script spawns bun without a shell, so the shim is never executed and the type check falls back to tsc. A native bun.exe on PATH should be picked up; this is not yet confirmed on a Windows machine (the Windows CI job covers the bun.cmd fallback).
  • node_modules/.bin/tsc now links to TypeScript 6.0.3 from @typescript/old, so npx tsc prints version 6. The scripts call node_modules/typescript/bin/tsc (7.0.2) directly.
  • Editor ESLint integrations load the same config, so they get the hook too. Inside that ESLint process, require("typescript") resolves to the TypeScript 6 API.
  • npm ci deletes node_modules/.tmp, so the first type check or build after a fresh install is a cold run (about 8 s for tsc on this host).

Testing

Run in studio/frontend on Linux:

npm ci
npm run typecheck
UNSLOTH_TYPECHECK=bun npm run typecheck   # with Bun 1.4.3 on PATH
npm test
npm run build
npm run lint
  • npm ci from the committed lockfile passes on npm 11.21.1 with --strict-allow-scripts and on npm 10.9.9 with --ignore-scripts, and leaves the lockfile byte-identical. Lockfile audit, allowScripts sync, the dependency-removal check and the duplicate-import lint all pass.
  • npm run typecheck passes through tsc (7.0.2) with Bun 1.3.13 on PATH, and through bun check with Bun 1.4.3 in both auto and forced mode (2,060 files across 2 projects plus 3,253 test-project files, no errors).
  • Injected errors in src/, vite.config.ts and tests/helpers/module-stubs.ts, and an unknown option in tsconfig.app.json, all fail with exit 1 on both paths with byte-identical diagnostics. With a check package script present, auto mode used tsc and UNSLOTH_TYPECHECK=bun refused to run; the script was never executed.
  • New tests/typecheck-script.test.ts: 16 pass, 1 skipped off Windows (the bun.cmd case). It covers no Bun, Bun 1.3 without check, Bun 1.4.3, a Bun that follows a different TypeScript version, colored CRLF help output, the check script guard, tsc confirming a failed bun check, and each UNSLOTH_TYPECHECK value. It passes with a system Node and with the setup-node layout, where Node's directory has no coreutils.
  • npm test: 12,503 tests, 0 failures, 1 skipped (the Windows-only case) on the final head.
  • npm run build passes and emits byte-identical JS to main (33,628,077 bytes at 147b694). npm run bundle:check fails on main itself right now (6637.0 KB raw, 1996.3 KB transfer startup JS against the budget); this branch reports the same numbers.
  • npm run lint output matches main (1459 problems).
  • Installer, Docker and Tauri paths are untouched. test_system_node_readonly.sh, the installer npm ci tests (5 passed), the Docker update tests (59 passed) and the workflow tests (95 passed) pass.

… bun check when available

- typescript 5.9.3 -> 7.0.2 (native compiler). Tests that use the TypeScript
  JS API import @typescript/typescript6, since TypeScript 7 ships none; an
  overrides entry keeps typescript-eslint's peer resolvable, and a small
  require hook keeps `npm run lint` on the TypeScript 6 API.
- baseUrl removed with the TypeScript team's ts5to6 tool; two lib-typing
  fixes TypeScript 6+ needs (latex.ts, training-start-request-id.ts).
- incremental on for the app, node and test projects: an unchanged rerun no
  longer re-checks everything.
- scripts/typecheck.mjs runs `bun check` when a Bun that has it (>= 1.4.3) is
  on PATH, else tsc; build and typecheck call it. UNSLOTH_TYPECHECK=auto|tsc|bun.
- Frontend CI also runs the type check through a pinned Bun 1.4.3.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 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 ⚠️ Failed 2026-10-16T12:55:45.810065Z 1286a6c New commits
ℹ️ 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.

The fake bun was a /bin/sh script calling dirname and cat, but the fixture's
PATH holds only its bin directory and node's own directory. Under setup-node,
nvm and similar installs that directory has no coreutils, so six cases failed.
It is now a node script started through /usr/bin/env.
npx eslint and editor ESLint load eslint.config.js without the --require
preload, so typescript-eslint got TypeScript 7 (no JS API) and crashed.
Importing the hook first in the config covers every entry point, and
npm run lint is plain eslint again.
@NilayYadav

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 791fe53559

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

bun check applies the rules of the TypeScript version its Bun ships with
(process.versions.typescript). A Bun that follows another version could pass
code that the pinned tsc rejects, so auto mode now falls back to tsc unless the
two versions match, and UNSLOTH_TYPECHECK=bun fails on a mismatch.

@NilayYadav NilayYadav 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.

Review + reproduction evidence

Pinned review: 791fe53559. No blocking findings.

I ran the frontend checks from a clean clone on current main (a1d4daa475) and on main with this PR merged, Linux x64 with 8 CPUs, Node 22:

  • main: npm run typecheck 90.87 s cold, 91.02 s on an unchanged rerun (TypeScript 5.9.3). npm run build 44.75 s.
  • PR: npm run typecheck 11.66 s cold, 1.72 s rerun (TypeScript 7.0.2); 3.73 s with Bun 1.4.3 on PATH (typecheck: bun check (Bun 1.4.3)). npm run build 12.26 s, 8.52 s with Bun.

Same output and same checking:

  • The built dist is identical on both sides and on the Bun path: 855 files, 33,632,449 JS bytes, same content hash.
  • Five planted errors in src/lib/sse-framing.ts give the same five diagnostics on 5.9.3 and 7.0.2 (TS2322 x2, TS2339, TS2353, TS2362), and bun check also reports 5. An error in a test file and one in vite.config.ts fail the check on both sides.
  • npm test and npm run lint give the same results on both sides (lint: 1459 problems, 1126 errors, 333 warnings). On macOS arm64 the PR head passes all 12501 unit tests, type-checks in 3.3 s cold and 0.46 s rerun.
  • Bun 1.3.0 on PATH falls back to tsc. npm ci works with npm 10 and 11, and the lockfile audit, install-script diff and npm package scan report nothing new.

One small wording note, not blocking (studio/frontend/scripts/typecheck.mjs lines 6-7). In auto mode a passing bun check is final, so the header claim that the pinned compiler stays the authority only holds when Bun reports errors. CI is unaffected because the plain Typecheck step always runs tsc:

// UNSLOTH_TYPECHECK=auto (default) | tsc | bun. In auto mode a red Bun result is re-checked with
// tsc, so a Bun error never fails the check on its own; a green Bun result is final.

Conclusion: the speedup is real and the type check catches the same errors with identical build output. The PR's CI runs were all cancelled before any step ran, so it needs a re-run to go green before merge.

@Etherll

Etherll commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

npm run typecheck for the Unsloth Studio frontend now runs on TypeScript 7.0.2 with incremental builds. On the same shared machine it took 73.6 s on main, 7.7 s with tsc on this branch, 1.0 s on an unchanged rerun, and 1.9 s through Bun 1.4.3.

What changed

  • The new type-check test's fake bun was a shell script that needed dirname and cat, so six cases failed wherever Node's own directory has no coreutils (setup-node, nvm). It is now a small Node script, and the file passes in that layout.
  • npx eslint and editor ESLint loaded the config without the TypeScript 6 API hook and crashed under TypeScript 7. The config now imports the hook first, so every entry point lints as before and npm run lint is plain eslint . again.
  • Any passing bun check was trusted, even from a Bun that follows a different TypeScript version. Bun is now used only when process.versions.typescript matches the pinned TypeScript; otherwise the check uses tsc.

On 1286a6c, the frontend unit tests pass (12,503 tests, 0 failures) with a system Node and with the setup-node layout. Injected type errors fail the same way through tsc and Bun 1.4.3, the build output is byte-identical to main, and lint output matches main.

Fork CI for 1286a6c ran in Etherll/unsloth#353. The type check, the new Bun 1.4.3 type-check step and the frontend build passed. Three checks failed, and all three fail the same way on main without this change. The startup bundle budget reports 6641.9 KB raw / 1997.6 KB transfer against a limit of 6639.0 KB / 1996.8 KB, with identical numbers on main. Two macOS update-idempotency tests fail. The version-compat canary fails because a new upstream beam MoE type is missing from its snapshot.

danielhanchen added a commit that referenced this pull request Oct 16, 2026
## Summary

`Frontend build + bundle sanity` is red on main again (for example on
#13986, based on a1d4daa): `over the startup budget: transfer 1997.6
KB > 1996.8 KB, raw 6641.9 KB > 6639.0 KB`.

Measured commit by commit (one machine and build, Node 24, `rm -rf dist`
before each build, 95 chunks throughout):

| commit | raw B | transfer B |
|---|---|---|
| 4ebc263~1 | 6,798,138 | 2,044,534 |
| 4ebc263 (#13999) | 6,798,175 | 2,044,556 |
| bcf7c81 (#13993) | 6,798,217 | 2,044,592 |
| d4e005e (#13998) | 6,801,255 | 2,045,592 |

Nearly all of it is #13998 (searching a model maker in the Model hub
lists Unsloth's uploads of its models): +3,038 B raw / +1,000 B
transfer. Its owner-to-uploads search was added to
`use-hub-model-search`, a hook the startup screen already loads, so
there is no separate module to lazy-load without restructuring that
hook.

## Change

The budget is raised by the growth (3,117 B raw / 1,058 B transfer),
keeping main's margin, with the per-commit numbers recorded beside the
limits as in the earlier raises.

## Testing

- `npm run build && npm run bundle:check` on main with this change:
within budget (0.2 KB transfer, 0.2 KB raw to spare). Without it: over
by the amounts above.
- `tests/bundle-budget-cli.test.ts` and
`tests/bundle-budget-closure.test.ts`: 43 passed.
- `prettier --check scripts/check-bundle-budget.ts`: clean.
danielhanchen added a commit that referenced this pull request Oct 16, 2026
…uses as qwen2_moe (#14005)

## Summary

`pinned-symbol matrix (vLLM, TRL, PEFT, ST, bitsandbytes, transformers)`
fails on PRs based on current main (for example #13986):

```
tests/version_compat/test_peft_conversion_symbol_backfill.py::test_the_fused_snapshot_matches_upstream
E   AssertionError: fused MoE types missing from the snapshot: ['beam']
```

The test is the canary for this case. It reads transformers main's
`conversion_mapping.py`, and huggingface/transformers#49664 (today)
added `"beam": "qwen2_moe"` there. `_PEFT_MOE_CONVERSION_PATTERNS` in
`unsloth/import_fixes.py` is the snapshot our PEFT MoE config handling
falls back on. Without the entry, a `beam` model's LoRA config would
miss the fused-expert conversion, because the name says nothing about
MoE. The snapshot is behind; the test is right.

## Change

Add `"beam": "qwen2_moe"` to the snapshot, in alphabetical order with
the other qwen2_moe-family entries.

## Testing

- `tests/version_compat/test_peft_conversion_symbol_backfill.py`: 68
passed on transformers 5.18, 5.20 and 4.57.6.
- Without the entry, `test_the_fused_snapshot_matches_upstream` fails
with the CI message above.
danielhanchen added a commit that referenced this pull request Oct 16, 2026
….cpp release cannot cover the scene (#14007)

## Summary

`studiobench CI / Real-path session, every action ran` failed on #13986
and #14000, which are unrelated. On the same base (a1d4daa) it passed
on two other PRs a few minutes later. Both failures are the same click
timeout:

```
cell FAILED: TimeoutError: ElementHandle.click: Timeout 8000ms exceeded.
  - <div class="mt-4 flex shrink-0 flex-wrap items-center gap-x-1 gap-y-2 justify-between">... from <div data-testid="overlay-rail" ...> subtree intercepts pointer events
```

That element is the action row of `LlamaUpdateBanner`, the "llama.cpp
update available" card in the bottom-right overlay rail.

| run | llama.cpp installed | start (UTC) | result |
|---|---|---|---|
| #14000 | b11669 | 13:07 | click intercepted |
| #13986 | b11669 | 13:06 | click intercepted |
| studio-video-unsloth-mirrors | b11681 | 13:09 | pass |
| studio-flux3-klein | b11681 | 13:13 | pass |

`unslothai/llama.cpp` published b11681 at 13:07:33, between the install
and the session. The two failing runs were then one release behind, so
Studio offered the update over the controls the scene clicks. Nothing in
Studio or in either PR is wrong: any run that straddles a llama.cpp
release hits it.

## Change

- The `liveness` job boots Studio with `UNSLOTH_DISABLE_UPDATE_CHECK=1`.
The backend's llama, whisper and audio update status already honours it
and reports `update_checks_disabled`, so no card is offered. The session
measures chat rendering against its own pacer, so update UI is not part
of what it checks.
- `tests/studio/test_studiobench_ci_update_checks_off.py` requires every
studiobench job that boots Studio to set it, and checks that the name
still matches what `utils/update_status.py` reads. It runs in
`workflow-trigger-lint`, as `test_workflow_guards_run_unfiltered.py`
requires of workflow-reading guards.

## Testing

- New guard: 2 passed. With the workflow change reverted it fails.
- `test_workflow_guards_run_unfiltered.py` plus the other tests that
read `workflow-trigger-lint.yml`: 176 passed.
@NilayYadav
NilayYadav merged commit 03fcdea into unslothai:main Oct 16, 2026
Etherll added a commit to Etherll/unsloth that referenced this pull request Oct 18, 2026
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