Commit graph

4,585 commits

Author SHA1 Message Date
Datta Nimmaturi
5a3b1ed73b Undo qwen3 rope changes 2026-03-16 07:10:10 +00:00
Datta Nimmaturi
c6f38aad8b patch for fp8 moe to use unsloth kerenls 2026-03-16 05:51:42 +00:00
Datta Nimmaturi
da3c9c1e84 [WIP] cleanup 2026-03-15 14:49:07 +00:00
Datta Nimmaturi
dec0c18400 [WIP] Fp8 training for Moe 2026-03-15 13:49:27 +00:00
Wasim Yousef Said
629199e3a6
fix: remove old comments (#4292)
* fix: quotation marks

* diceware passphrase generation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Roland Tannous <rolandtannous@gravityq.ai>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-14 16:50:13 +04:00
pre-commit-ci[bot]
b20b3b80df [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-03-14 00:54:09 -07:00
Daniel Han
4b6f5c76c1 studio: probe-based --system detection for uv
Replace _in_virtualenv() heuristic with a runtime probe. At
bootstrap time, try a dry-run uv install without --system. If
that fails (exit code 2, "No virtual environment found"), retry
with --system to confirm it works. This handles all environments
correctly: venvs, Colab (system Python), local machines, containers.
2026-03-14 00:54:09 -07:00
Daniel Han
9b7eaf8f0c studio: make uv optional + fix --system for Colab
Three fixes based on review:

1. Make uv truly optional: _bootstrap_uv() now only checks if uv is
   already on PATH. It no longer tries to pip install uv. If uv is
   not present, pip is used with zero changes to behavior.

2. Add --system flag for Colab: on Colab there is no venv (packages
   install into system Python). uv requires --system in this case,
   otherwise it errors with "No virtual environment found". Added
   _in_virtualenv() check that detects VIRTUAL_ENV, sys.real_prefix,
   or sys.base_prefix != sys.prefix.

3. Fix label printed twice on uv fallback: when uv fails and falls
   back to pip, the label now says "(pip)" to distinguish from the
   initial uv attempt, instead of printing the same label twice.

Tested:
  - venv path: no --system flag, uv installs correctly
  - no-venv path (Colab sim): --system flag added automatically
  - full unsloth studio setup + training run (Llama-3.2-1B, 10 steps)
2026-03-14 00:54:09 -07:00
Daniel Han
a7a66a66b9 studio: address review feedback
install_python_stack.py:
- Print uv error output on failure for debuggability
- Refactor pip_install() to use early return after uv success,
  removing duplicated pip command path

setup.sh:
- Guard nvidia-smi command substitution with || true so it does
  not abort the script under set -euo pipefail when nvidia-smi
  fails (e.g., containerized environments, driver quirks)
- Read all GPU compute capabilities and deduplicate, so
  mixed-GPU hosts get kernels built for all present architectures
  instead of only the first GPU
2026-03-14 00:54:09 -07:00
Daniel Han
6dda8c4c23 studio: revert combined targets, keep separate builds
Restore separate cmake --build calls for llama-server and
llama-quantize on both setup.sh and setup.ps1. The combined
approach made llama-quantize failure fatal, but it was originally
best-effort (|| true on Linux, [WARN] on Windows). The timing
savings from combining was only ~2.7s, not worth the semantic
change.

The Ninja + arch detection speedups are preserved (55s vs 1m 37s).
2026-03-14 00:54:09 -07:00
Daniel Han
e4a5da8d96 studio: combine llama.cpp build targets in setup.ps1
Build llama-server and llama-quantize in a single cmake --build
invocation on Windows, matching the same optimization done in
setup.sh. This allows MSBuild to better parallelize the two targets.

The Visual Studio generator is kept as-is (not switching to Ninja on
Windows since VS generator is the standard approach and interacts
with MSBuild).
2026-03-14 00:54:09 -07:00
Daniel Han
f8dc7c9a5c studio: speed up llama.cpp build with Ninja + arch detection
Three improvements to the llama.cpp build step in setup.sh:

1. Detect GPU compute capability via nvidia-smi and limit
   CMAKE_CUDA_ARCHITECTURES to the current GPU. Without this, cmake
   builds for all default CUDA architectures which is very slow.

2. Use Ninja build generator when available. Ninja has better
   parallelism than Make for CUDA compilation.

3. Build both llama-server and llama-quantize targets in a single
   cmake --build invocation for better parallelism.

4. Add --threads=0 to CMAKE_CUDA_FLAGS for multi-threaded nvcc
   compilation.

Measured on 192-core machine with B200 (sm_100):
  Make (all archs):       very slow (minutes for each arch)
  Make (single arch):     1m 37s
  Ninja (single arch):    55s
  Speedup:                ~1.7x

Combined with the uv change, total setup goes from ~4m 35s to ~1m 40s.
2026-03-14 00:54:09 -07:00
pre-commit-ci[bot]
174d61e0f5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-03-14 00:54:09 -07:00
Daniel Han
a537ece7eb studio: use uv for Python package installs (8x faster)
Replace pip with uv in install_python_stack.py to speed up the Python
dependency installation phase of `unsloth studio setup`.

- Add _bootstrap_uv() that checks for uv on PATH, and if not found,
  installs it via pip. Falls back to pip if uv is unavailable.
- Translate pip flags to uv equivalents (--no-cache-dir dropped since
  uv caching is fast, --force-reinstall becomes --reinstall).
- Add --torch-backend=auto so uv auto-detects CUDA version for
  PyTorch ecosystem packages.
- Per-install fallback: if any uv install step fails, it retries that
  step with pip before exiting.

Measured on clean venv setup:
  Python packages (pip):  2m 28s
  Python packages (uv):  18s
  Speedup:               ~8x

Total setup time goes from ~4m 35s to ~2m 30s (llama.cpp build is
now the bottleneck at 1m 40s).
2026-03-14 00:54:09 -07:00
Daniel Han
2bb72a2244 Revert "add support for mixtral"
This reverts commit c8f712b614.
2026-03-13 22:39:15 -07:00
tohrnii
943e8f6d84 add support for mixtral
(cherry picked from commit a55b740062)
2026-03-13 22:39:15 -07:00
Daniel Han
936c18424e Revert "patch vlm trainer to resize images"
This reverts commit 481b22fdf4.
2026-03-13 22:39:07 -07:00
oliveirabruno01
aa8d91b241 patch vlm trainer to resize images
(cherry picked from commit 14c282c4ec)
2026-03-13 22:39:07 -07:00
Daniel Han
b8eee7a8ba Revert "Initial changes: Refactor Attention"
This reverts commit a2af843271.
2026-03-13 22:38:57 -07:00
Shikhar Mishra
7502195443 Initial changes: Refactor Attention
(cherry picked from commit 5a7237abfd)
2026-03-13 22:38:57 -07:00
Daniel Han
49132ced50 Revert "feat: Add Mixtral model support"
This reverts commit 99c302d873.
2026-03-13 22:38:49 -07:00
Shikhar Mishra
659281c508 feat: Add Mixtral model support
(cherry picked from commit 2258875885)
2026-03-13 22:38:49 -07:00
Daniel Han
30a18786bf Revert "Improve documentation on how to export model from Colab"
This reverts commit 703c235a7d.
2026-03-13 22:38:41 -07:00
Vishwanath Martur
022a5d566a Improve documentation on how to export model from Colab
Related to #1615

Add documentation and function for exporting models from Colab to local machines.

* **README.md**: Add a new section titled "Exporting Models from Colab to Local Machine" under " Finetune for Free" with detailed steps for exporting models from Colab to local machines.
* **CONTRIBUTING.md**: Add a note about the new documentation section for exporting models from Colab.
* **unsloth/save.py**: Add a new function `export_model_to_local` to handle exporting models from Colab to local machines.

(cherry picked from commit 0361bd658f)
2026-03-13 22:38:41 -07:00
Daniel Han
c5fa314937 Revert "adding tools to be able to profile model fwds to see what to turn into kernels"
This reverts commit d32b00ecd8.
2026-03-13 22:38:31 -07:00
cm2435
12898b5bef adding tools to be able to profile model fwds to see what to turn into kernels
(cherry picked from commit 6db5b126b6)
2026-03-13 22:38:31 -07:00
LeoBorcherding
3ab282fd40 fix: install data-designer plugin non-editable for Colab compatibility
Editable installs (-e) work via a .pth file that is only processed at
Python startup. In Colab the kernel is already running when setup.sh
installs the plugin, so the .pth file never gets picked up and
data_designer_unstructured_seed is not importable.

Remove -e so pip copies the package files directly into site-packages,
which the live kernel can find immediately. Local venv installs are
unaffected since the venv is always created fresh before install.
2026-03-13 13:44:08 -07:00
pre-commit-ci[bot]
6baa181890 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-03-13 13:38:19 -07:00
Daniel Han
eb7637013e Update CODEOWNERS 2026-03-13 13:38:19 -07:00
Roland Tannous
b95242a80f fix: only skip frontend build for PyPI prebuilt (site-packages + dist check) 2026-03-13 20:26:10 +00:00
Roland Tannous
bf54225f86 fix: site-packages + dist check for frontend
build, fix ruff blank lines
2026-03-13 20:13:34 +00:00
Roland Tannous
0e0325127d Revert "site-packages + dist check"
This reverts commit 82063d8edb.
2026-03-13 20:09:41 +00:00
Roland Tannous
82063d8edb site-packages + dist check 2026-03-13 20:04:15 +00:00
Roland Tannous
8ce2b64df7 allow install from source 2026-03-13 20:04:15 +00:00
Daniel Han
1f99dee027
fix(seed): disable remote code execution in seed inspect dataset loads (#4275)
* fix(seed): disable remote code execution for seed inspect loads

* fix(test): use __file__-relative path in seed test

The test used a CWD-relative path (`studio/backend/routes/...`) which
only resolved when pytest was invoked from the repo root. Use
`Path(__file__).resolve()` so the test passes regardless of CWD.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Test <test@test.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-13 19:37:43 +04:00
Daniel Han
88c7b08faa
fix: prevent ai-assist model config RCE via untrusted Hugging Face repos (#4274)
* fix: disable remote code loading for ai-assist model hint lookup

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Roland Tannous <115670425+rolandtannous@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-13 19:29:11 +04:00
Roland Tannous
e539965740 fix error for chat template 2026-03-13 15:18:04 +00:00
Roland Tannous
8108f1bf11 Fix nvm/npmrc prefix conflict in setup.sh 2026-03-13 08:59:51 +00:00
Daniel Han
3e8f085474 Limit rocm711-torch291 to Linux 2026-03-13 01:40:56 -07:00
sstamenk
a54a913431 Add more ROCm/PyTorch combinations
(cherry picked from commit d02aa7f9c3)
2026-03-13 01:40:56 -07:00
sstamenk
c752c8107a Add more ROCm/PyTorch versions
(cherry picked from commit ed6877fadd)
2026-03-13 01:40:56 -07:00
Daniel Han
51bf500f57
Remove Blackwell flex attention disable workaround from studio (#4273)
The studio was disabling flex attention entirely on Blackwell+ GPUs
(sm_120 and above) by setting UNSLOTH_ENABLE_FLEX_ATTENTION=0 at
startup. This was a workaround for the flex_attention backward kernel
exceeding shared memory limits on these GPUs.

The root cause is now fixed in unsloth-zoo (PR #542) which patches the
backward kernel config selection to generate safe fallback configs that
fit within the GPU's shared memory limit. With that fix, flex attention
works correctly on Blackwell GPUs and provides a ~1.3x speedup over
the SDPA fallback.
2026-03-13 01:35:17 -07:00
Daniel Han
37b8d5e440
remove duplicate import (#4271)
(cherry picked from commit d1f4fb5d6a)

Co-authored-by: electron271 <66094410+electron271@users.noreply.github.com>
2026-03-13 00:26:38 -07:00
Daniel Han
d6e40df8fa
Fix llm_int8_skip_modules for VLM dynamic quants on transformers 5.x (#4249)
Fix `llm_int8_skip_modules` not being respected for VLMs with dynamic quantization on transformers 5.x.

Dynamic quant checkpoints (e.g. `gemma-3-4b-it-unsloth-bnb-4bit`) encode skip paths as `language_model.model.layers.*`, but the live module tree on 5.x surfaces them as `model.language_model.layers.*`. This prefix mismatch causes `should_convert_module` to miss the skip list, so 22 modules meant to stay in 16-bit get wrapped in `Linear4bit` without a `quant_state`, producing "Skipping ... no quant_state found" warnings.

Patches `should_convert_module` to expand both the module name and the skip patterns into all equivalent alias forms before matching. Guarded by `hasattr` so it is a no-op on transformers 4.x where the bug does not exist.

Closes #4208
2026-03-13 00:17:00 -07:00
Daniel Han
1ca441a3f3
[Feature] VLMs support for GRPO (#4265)
* Updated rl and rl_replacements

* Revert "Updated rl and rl_replacements"

This reverts commit 077fd5996daa73c9c58c9f213657f33f47f5d73b.

---------

Co-authored-by: Sinoué GAD <85933501+GAD-cell@users.noreply.github.com>
2026-03-12 16:09:02 -07:00
Daniel Han
74c1497f2f
[Feature] Support Sequence Classification (#4264)
* initial commit for sequence classification implementation

* Revert "initial commit for sequence classification implementation"

This reverts commit 0f3200cdf2dfb8446e5d69dcbe40d6f70bc520e7.

---------

Co-authored-by: Rabin Tiwari <84705625+rabintiwari45@users.noreply.github.com>
2026-03-12 16:08:49 -07:00
Daniel Han
96ff5c5f61
Update CODEOWNERS for studio and cli (#4266)
* Update CODEOWNERS for studio and cli

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-12 15:16:38 -07:00
Daniel Han
c26aa1a1e8 Restore non-studio files from main after history recovery 2026-03-12 21:48:45 +00:00
Daniel Han
6f0bca70f8 Merge remote-tracking branch 'studio/feature/merge-build-main' into history-recovery-candidate 2026-03-12 21:48:30 +00:00
Daniel Han
17ae3d3cba Revert "Studio (#4237)"
This reverts commit f08aef1804.
2026-03-12 21:48:23 +00:00