Repository navigation
Studio: faster frontend type check with TypeScript 7 and bun check - #13986
NilayYadav merged 4 commits into
Conversation
… 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.
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. |
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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
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
left a comment
There was a problem hiding this comment.
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 typecheck90.87 s cold, 91.02 s on an unchanged rerun (TypeScript 5.9.3).npm run build44.75 s. - PR:
npm run typecheck11.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 build12.26 s, 8.52 s with Bun.
Same output and same checking:
- The built
distis 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.tsgive the same five diagnostics on 5.9.3 and 7.0.2 (TS2322 x2, TS2339, TS2353, TS2362), andbun checkalso reports 5. An error in a test file and one invite.config.tsfail the check on both sides. npm testandnpm run lintgive 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 ciworks 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.
|
What changed
On Fork CI for |
## 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.
…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.
….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.
…s do since TypeScript 7 (unslothai#13986)
Summary
The Unsloth Studio frontend type check (
npm run typecheck, and the type-check step at the start ofnpm 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 runsbun checkinstead 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 andbun check1.84 s.bun check(Bun 1.4.3), coldbun check(Bun 1.4.3), rerunbun 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.src/lib/sse-framing.tsfailed 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
setup.sh/setup.ps1runnpm 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.bun checkpeaks at about 1.4 GiB instead of 2.5 GiB for the old check.bun --helpspawn: 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.mjsreplaces the inlinetsccommands inbuildandtypecheck:bun --help(no shell, 5 s timeout, color off), strips ANSI codes and\r, and looks for acheckcommand in the list. Bun before 1.4.3 has nocheckcommand and would treatbun checkasbun run check, so those versions fall back to tsc. No Bun on PATH also falls back to tsc.bun check --build --no-prettyandbun check --project=tsconfig.test.json --no-pretty, notbun --check.--checkis a global Bun flag that ignores--build,--projectand--no-pretty, and in that position-bmeans--bunand-pmeans--print.package.jsonhas acheckscript (or cannot be read), Bun is skipped, becausebun checkwould run that script instead of type-checking.process.versions.typescript, 7.0.2 for Bun 1.4.3) equals the pinnedtypescriptversion; otherwise the check uses tsc. In auto mode a failingbun checkis still rerun with tsc, and the tsc result is final.UNSLOTH_TYPECHECKoverrides the choice:auto(default): the behavior above.tsc: always tsc, Bun is never probed.bun: alwaysbun check. It exits 1 with a message if there is no Bun withcheckon PATH or if acheckscript exists, and passes Bun's exit code through otherwise.TypeScript 7 migration
typescriptgoes from~5.9.3to7.0.2. TypeScript 7 ships no JS API, so the 79 test imports oftypescript(77 test files plustests/helpers/module-stubs.tsandtests/helpers/tsx-ast.ts) now import@typescript/typescript6, a side-by-side TypeScript 6 API package.module-stubs.tssetsesModuleInterop: false, because TypeScript 6 turns it on by default and would wrap the stubs in__importDefault.eslint.config.jsimportsscripts/eslint-typescript6.cjsfirst. It is a require hook that sends typescript-eslint'srequire("typescript")to the TypeScript 6 copy, sonpm run lint,npx eslintand 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.baseUrlis removed fromtsconfig.json,tsconfig.app.jsonandtsconfig.test.jsonusing the TypeScript team'sts5to6tool. The@/*path mapping is unchanged.src/lib/latex.tsadds a non-null assertion onmatch.indices![1], andsrc/features/training/lib/training-start-request-id.tstypesgetRandomValueswithArrayBufferView<ArrayBuffer>.incrementalis on for the app, node and test projects. All three.tsbuildinfofiles are written undernode_modules/.tmp, so nothing new is tracked by git.CI
studio-frontend-ci.ymlkeeps the existingnpm run typecheckstep, 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'sSHASUMS256.txt) before running it, and runsUNSLOTH_TYPECHECK=bun npm run typecheckso it cannot silently fall back to tsc. Bun 1.4.3 is the first release withbun check. It was admitted before the usual 7-day release-age wait by explicit maintainer decision. The comment inlint-ci.ymlthat described the type check astsc --noEmitis updated.Dependencies
typescript:~5.9.3to7.0.2. The lockfile adds the optional per-platform native compiler packages (@typescript/typescript-<os>-<arch>7.0.2).@typescript/typescript66.0.2, which brings@typescript/old6.0.3.overridesgains"typescript": "$typescript"so typescript-eslint'stypescriptpeer dependency resolves to the root version.Compatibility notes
bun.cmdshim. The script spawnsbunwithout a shell, so the shim is never executed and the type check falls back to tsc. A nativebun.exeon PATH should be picked up; this is not yet confirmed on a Windows machine (the Windows CI job covers thebun.cmdfallback).node_modules/.bin/tscnow links to TypeScript 6.0.3 from@typescript/old, sonpx tscprints version 6. The scripts callnode_modules/typescript/bin/tsc(7.0.2) directly.require("typescript")resolves to the TypeScript 6 API.npm cideletesnode_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/frontendon Linux:npm cifrom the committed lockfile passes on npm 11.21.1 with--strict-allow-scriptsand 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 typecheckpasses through tsc (7.0.2) with Bun 1.3.13 on PATH, and throughbun checkwith Bun 1.4.3 in both auto and forced mode (2,060 files across 2 projects plus 3,253 test-project files, no errors).src/,vite.config.tsandtests/helpers/module-stubs.ts, and an unknown option intsconfig.app.json, all fail with exit 1 on both paths with byte-identical diagnostics. With acheckpackage script present, auto mode used tsc andUNSLOTH_TYPECHECK=bunrefused to run; the script was never executed.tests/typecheck-script.test.ts: 16 pass, 1 skipped off Windows (thebun.cmdcase). It covers no Bun, Bun 1.3 withoutcheck, Bun 1.4.3, a Bun that follows a different TypeScript version, colored CRLF help output, thecheckscript guard, tsc confirming a failedbun check, and eachUNSLOTH_TYPECHECKvalue. 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 buildpasses and emits byte-identical JS to main (33,628,077 bytes at 147b694).npm run bundle:checkfails 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 lintoutput matches main (1459 problems).test_system_node_readonly.sh, the installernpm citests (5 passed), the Docker update tests (59 passed) and the workflow tests (95 passed) pass.