Commit graph

3,037 commits

Author SHA1 Message Date
pre-commit-ci[bot]
3beade641d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-01 15:24:34 +00:00
Daniel Han
0613fafefe Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 727da805d9.
2025-12-01 07:24:21 -08:00
pre-commit-ci[bot]
727da805d9 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-01 15:23:44 +00:00
Daniel Han
1bf2af5165 Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 3722c95e42.
2025-12-01 07:23:31 -08:00
pre-commit-ci[bot]
3722c95e42 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-01 15:20:22 +00:00
Daniel Han
9ab2d23233 Update unsloth/models/rl.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-01 07:20:00 -08:00
Daniel Han
e38209de83 Update unsloth/models/rl.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-01 07:19:50 -08:00
Daniel Han
89fc908d85 Update qwen3_moe.py 2025-12-01 07:19:07 -08:00
Datta Nimmaturi
2bc0765a2d Vllm guided decoding (#3663)
* vllm sampling params fix

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

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

* do not patch base_trainer

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

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

* seperate vllm fixes

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

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

* Fixup deletion

* Fix indentation

* revert to old style

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-01 07:11:28 -08:00
Daniel Han
d15b9b8acb Verisoning 2025-12-01 07:09:17 -08:00
Daniel Han
b80f2761ac Update rl.py 2025-12-01 06:23:23 -08:00
Daniel Han
5f0c9cff5e Revert "[FIX] Vllm guided decoding params (#3662)"
This reverts commit e4d566e159.
2025-12-01 05:43:45 -08:00
Datta Nimmaturi
e4d566e159 [FIX] Vllm guided decoding params (#3662)
* vllm sampling params fix

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

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

* do not patch base_trainer

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

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

* seperate vllm fixes

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

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

* Apply suggestion from @danielhanchen

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

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

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

This reverts commit fe334c4dffda0c799295a69b3fc5f4c071d83176.

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

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

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

This reverts commit ae94be7d7e0a4780820adfbcde3549aec0ec49cf.

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

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

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

This reverts commit cde2dde170d35bce2b50211eeaf4c9788f33734c.

* [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>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
2025-12-01 05:42:37 -08:00
Daniel Han
64bd3e552f Merge branch 'main' into nightly 2025-12-01 04:21:27 -08:00
Santosh Bhavani
6abd9afe99 Fix: Pass gradient_checkpointing parameter to model.for_training() calls (#3659) 2025-12-01 04:18:41 -08:00
Daniel Han
08a399092f Update vision.py 2025-12-01 01:21:26 -08:00
Daniel Han
a40a7b03fb Typos 2025-12-01 00:01:07 -08:00
Daniel Han
3ef6b66f39 Update qwen3_moe.py 2025-11-30 23:37:32 -08:00
Daniel Han
f691b2616e Update vision.py 2025-11-30 21:32:07 -08:00
VED
5d0523c1ca set defualt [128, 128] insted of none (#3658)
Co-authored-by: Ved <ved.work2024@gmail.com>
2025-11-30 17:00:31 -08:00
Daniel Han
ad3221a7fd Update rl.py 2025-11-30 04:40:03 -08:00
Daniel Han
a40189fa4d Merge branch 'main' into nightly 2025-11-30 04:39:55 -08:00
DoubleMathew
69f7dfdb90 make unsloth_tiled_mlp a from_pretrained arg (#3655)
* make unsloth_tiled_mlp a from_pretrained arg

* adjust patching logic
2025-11-29 22:47:51 -08:00
Bhuvan Prakash
27ae5c335c Fix: prevent load_in_fp8 kwarg from reaching Qwen3MoeForCausalLM constructor (Fix #3649) (#3654)
* Fix: remove load_in_fp8 from kwargs to prevent Qwen3Moe init TypeError (Fix #3649)

* [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>
2025-11-29 20:18:11 -08:00
gitpullpull
d8ea261924 Fix broken link for Advanced pip install instructions (#3652) 2025-11-29 15:33:48 -08:00
Michael Han
f730ad0b3e Update README.md 2025-11-29 08:01:00 -08:00
DoubleMathew
f3803cdee0 fix rope_theta -> rope_parameters['rope_theta'] (#3651) 2025-11-29 06:44:26 -08:00
Michael Han
2769e27566 Update README.md 2025-11-27 20:52:27 -08:00
Michael Han
74a9fc808c Update README.md 2025-11-27 20:49:47 -08:00
Daniel Han
5cae64b834 Merge branch 'main' into nightly 2025-11-27 05:45:20 -08:00
mk0walsk
b86ce33996 Fix indefinite article usage in comments and docstrings (#3648) 2025-11-26 18:15:27 -08:00
Dina Suehiro Jones
8d72323bd8 Fix llama tokenizer padding_side when using model.generate in inference mode (#3644)
* Only restore training mode after generation, if the model started out in training mode

Signed-off-by: Dina Suehiro Jones <dina.s.jones@intel.com>

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

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

---------

Signed-off-by: Dina Suehiro Jones <dina.s.jones@intel.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-25 17:33:28 -08:00
Daniel Han
7cdad0c7df Merge branch 'main' into nightly November-2025 2025-11-25 07:59:24 -08:00
Daniel Han
efa783df3c Update mapper.py 2025-11-25 07:59:21 -08:00
Daniel Han
84e303dc63 Merge branch 'main' into nightly 2025-11-25 07:45:27 -08:00
Daniel Han
3bc471b1af Update loader.py 2025-11-25 07:45:14 -08:00
Daniel Han
6231d25fca Merge branch 'main' into nightly 2025-11-25 07:39:00 -08:00
Daniel Han
a66b828a98 Update loader.py 2025-11-25 07:38:51 -08:00
Daniel Han
a90452e04c Merge branch 'main' into nightly 2025-11-25 07:23:55 -08:00
Daniel Han
38aa148aba Float8 GRPO, RL (#3640)
* Enable FP8 + RL training for bf16 models (#3440)

* Enable FP8 + RL training for bf16 models

**Summary:** Enable FP8 + RL training using TorchAO for 1.33x faster training and 42% less model memory usage:
- We quantize the frozen LoRA weights into fp8 and keep the LoRA adapters in bf16
- We leverage TorchAO's `Float8Tensor`, which calls into fbgemm's fp8 x fp8 rowwise matmul kernel
- For now, we need to do an offline quantization first, because vllm doesn't support on-the-fly quantization for torchao yet  (this is in progress: https://github.com/vllm-project/vllm/pull/26327)

**Example usage:**
```
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "unsloth/Qwen3-8B-Base",
    max_seq_length = 2048,
    load_in_4bit = False,
    fast_inference = True,
    max_lora_rank = 32,
    load_in_fp8 = True,  # set this to True
)

\# the rest is the same as before
model = FastLanguageModel.get_peft_model(...)
```

**Initial results:**
```
\# fp8
{'train_runtime': 1725.4337, 'train_samples_per_second': 0.232, 'train_steps_per_second': 0.058, 'train_loss': 0.00015715716748673002, 'epoch': 0.01}

\# bf16
{'train_runtime': 2297.8145, 'train_samples_per_second': 0.174, 'train_steps_per_second': 0.044, 'train_loss': 0.00016081033063528594, 'epoch': 0.01}
```

<img width="1199" height="448" alt="Screenshot 2025-11-11 at 4 10 50 PM" src="https://github.com/user-attachments/assets/b6304afd-89e9-42b1-8064-775807e17b23" />

Test script: https://gist.github.com/andrewor14/5b85119fae46845d07b608d420907423

**Requires:**
- https://github.com/pytorch/ao/pull/3158 (torchao nightly or 0.15.0+)
- https://github.com/unslothai/unsloth-zoo/pull/351

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

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

* Update utils.py

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

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

* _get_inference_mode_context_manager

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

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

* Update utils.py

* Update utils.py

* [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>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>

* Update __init__.py

* Fix/save torchao model loading logic (#3621)

* make loading gpt-oss-BF16 faster. Linked to unsloth-zoo PR #314

* fix model loading and clean merged model directory

* revert default quant

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

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

* revert mapper.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Update loader_utils.py

* Update loader_utils.py

* Add 128x128 PerBlock FP8 + RL (#3629)

* Add 128x128 PerBlock FP8 + RL

**Summary:** Following https://github.com/unslothai/unsloth/pull/3440,
this PR extends torchao FP8 + RL support to also handle 128x128
PerBlock granularity (in addition to PerRow).

**Example usage:**

```
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "unsloth/Qwen3-8B-Base",
    max_seq_length = 2048,
    load_in_4bit = False,
    fast_inference = True,
    max_lora_rank = 32,
    load_in_fp8 = "block",  # or "row" or True
)
```

**Initial results:** TBD

**Note:**
- Requires https://github.com/pytorch/ao/pull/3370

* [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>

* Version

* Update vision.py

* Update rl.py

* Add torch 2.9.1

* Fix auto installer

* Update fp8.py

* Float8

* Update fp8.py

* Update mapper.py

* Update mapper.py

* Update loader_utils.py

* Update loader.py

* Update fp8.py

* Versioning

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

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

---------

Co-authored-by: andrewor14 <andrewor14@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Roland Tannous <115670425+rolandtannous@users.noreply.github.com>
2025-11-25 07:23:26 -08:00
pre-commit-ci[bot]
e7acd095eb [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-25 15:20:19 +00:00
Daniel Han
69c7a23bc4 Versioning 2025-11-25 07:12:45 -08:00
Daniel Han
2368a0ce51 Update fp8.py 2025-11-25 07:11:30 -08:00
Daniel Han
422ab9bba6 Update loader.py 2025-11-25 07:06:41 -08:00
Daniel Han
5f51fc644c Update loader_utils.py 2025-11-25 07:05:43 -08:00
Daniel Han
3ba79978e4 Update mapper.py 2025-11-25 07:02:20 -08:00
Daniel Han
9bce1d4116 Update mapper.py 2025-11-25 06:53:06 -08:00
Daniel Han
db292872c8 Update fp8.py 2025-11-25 06:50:58 -08:00
Daniel Han
cb00618e49 Float8 2025-11-25 06:48:10 -08:00
Daniel Han
fee3841c24 Update fp8.py 2025-11-25 05:35:34 -08:00