Commit graph

3,038 commits

Author SHA1 Message Date
Daniel Han
1679ddee9b Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit c427be9f49.
2025-12-01 07:24:58 -08:00
pre-commit-ci[bot]
c427be9f49 [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
77bb017d5e Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 1146769456.
2025-12-01 07:24:21 -08:00
pre-commit-ci[bot]
1146769456 [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
d5ab983168 Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 9bf82bb34c.
2025-12-01 07:23:31 -08:00
pre-commit-ci[bot]
9bf82bb34c [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
68c70d129f
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
a9a3db349a
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
d71186a1a2 Update qwen3_moe.py 2025-12-01 07:19:07 -08:00
Datta Nimmaturi
4b124da504
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
6e8de57f02 Verisoning 2025-12-01 07:09:17 -08:00
Daniel Han
d7c6fc1000 Update rl.py 2025-12-01 06:23:23 -08:00
Daniel Han
3d0be20ef6 Revert "[FIX] Vllm guided decoding params (#3662)"
This reverts commit 6c47dc57f0.
2025-12-01 05:43:45 -08:00
Datta Nimmaturi
6c47dc57f0
[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 fbb98c5c5c.

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

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

* [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
afc6ac86ed Merge branch 'main' into nightly 2025-12-01 04:21:27 -08:00
Santosh Bhavani
e64c53a2de
Fix: Pass gradient_checkpointing parameter to model.for_training() calls (#3659) 2025-12-01 04:18:41 -08:00
Daniel Han
ee4980f682 Update vision.py 2025-12-01 01:21:26 -08:00
Daniel Han
029f33d4a6 Typos 2025-12-01 00:01:07 -08:00
Daniel Han
2b37b9e938 Update qwen3_moe.py 2025-11-30 23:37:32 -08:00
Daniel Han
f7790f0e9c Update vision.py 2025-11-30 21:32:07 -08:00
VED
349a81f96f
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
5aa7c17dca Update rl.py 2025-11-30 04:40:03 -08:00
Daniel Han
6234e903cc Merge branch 'main' into nightly 2025-11-30 04:39:55 -08:00
DoubleMathew
0fb14e6a76
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
3c658a6e1e
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
05c6f91c55
Fix broken link for Advanced pip install instructions (#3652) 2025-11-29 15:33:48 -08:00
Michael Han
9d6565e720
Update README.md 2025-11-29 08:01:00 -08:00
DoubleMathew
172886d8ca
fix rope_theta -> rope_parameters['rope_theta'] (#3651) 2025-11-29 06:44:26 -08:00
Michael Han
bda9e3d39b
Update README.md 2025-11-27 20:52:27 -08:00
Michael Han
7c6d83f594
Update README.md 2025-11-27 20:49:47 -08:00
Daniel Han
c04d1407fc Merge branch 'main' into nightly 2025-11-27 05:45:20 -08:00
mk0walsk
f08b337ee0
Fix indefinite article usage in comments and docstrings (#3648) 2025-11-26 18:15:27 -08:00
Dina Suehiro Jones
d4a311d8e7
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
43d931c007 Merge branch 'main' into nightly 2025-11-25 07:59:24 -08:00
Daniel Han
f3e95372cd Update mapper.py 2025-11-25 07:59:21 -08:00
Daniel Han
0581621550 Merge branch 'main' into nightly 2025-11-25 07:45:27 -08:00
Daniel Han
1a769f1389 Update loader.py 2025-11-25 07:45:14 -08:00
Daniel Han
b9c963c401 Merge branch 'main' into nightly 2025-11-25 07:39:00 -08:00
Daniel Han
0524df14dd Update loader.py 2025-11-25 07:38:51 -08:00
Daniel Han
7f2eb33550 Merge branch 'main' into nightly 2025-11-25 07:23:55 -08:00
Daniel Han
aa086eab6b
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]
c1a02088df [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
51247e9ebf Versioning 2025-11-25 07:12:45 -08:00
Daniel Han
ed43bcb0fe Update fp8.py 2025-11-25 07:11:30 -08:00
Daniel Han
5e419d57e4 Update loader.py 2025-11-25 07:06:41 -08:00
Daniel Han
05d80fb5b8 Update loader_utils.py 2025-11-25 07:05:43 -08:00
Daniel Han
acf9d534e2 Update mapper.py 2025-11-25 07:02:20 -08:00
Daniel Han
c4d5e9a9dc Update mapper.py 2025-11-25 06:53:06 -08:00
Daniel Han
a3e6ef06e8 Update fp8.py 2025-11-25 06:50:58 -08:00
Daniel Han
4246d3e81d Float8 2025-11-25 06:48:10 -08:00