Avaya Aggarwal
7c5464ad71
feat: Add cactus QAT scheme support ( #4679 )
...
* feat: Add cactus QAT scheme support
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test(qat): add tests for cactus QAT scheme and fix missing import
* Fix cactus QAT scheme: correct MappingType import, tighten PerGroup filter
- Drop the broken `from torchao.dtypes import MappingType` import. `MappingType`
lives in `torchao.quantization` (and `torchao.quantization.quant_primitives`);
it is not exported from `torchao.dtypes` in any supported torchao release
(verified on 0.14, 0.16, 0.17). The previous code raised `ImportError` on
every cactus call and was masked as a misleading 'torchao not found' error.
- Since `IntxWeightOnlyConfig` already defaults `mapping_type` to
`MappingType.SYMMETRIC`, drop the explicit kwarg entirely and remove the
import. Behavior is unchanged.
- Introduce a named `group_size = 32` constant (matches the int4 / fp8-int4
pattern in the surrounding branches) and add a `% group_size == 0`
divisibility guard to the filter. `PerGroup(32)` requires
`in_features % 32 == 0` at `quantize_()` time, otherwise torchao raises
`ValueError: in_features (N) % group_size (32) must be == 0`. The old
`in_features >= 32` filter would admit non-aligned widths (e.g. 33, 48, 65,
127) and crash `_prepare_model_for_qat` for those shapes.
* Warn when cactus QAT skips non-divisible Linear layers
Multiple reviewers flagged that the divisibility guard added in the
previous commit can silently leave Linear layers in full precision when
their in_features is not a multiple of 32. For currently supported
Unsloth models (Qwen, Llama, Gemma, Mistral, Phi) every Linear width is
already a multiple of 32/64/128 so this never triggers, but surfacing
the coverage gap is cheap and avoids users assuming 100% QAT coverage
when they bring a custom model with unusual shapes.
Emit a UserWarning listing up to the first 8 skipped layers whenever
the cactus filter excludes any Linear due to the modulo guard. This
keeps the lenient silent-skip behavior (consistent with int4 /
fp8-int4), but stops making it silent.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
2026-04-15 07:40:03 -07:00
Avaya Aggarwal
45d0a343b5
feat: Implement Q-GaLore optimizer and custom embedding learning rate… ( #4511 )
...
* feat: Implement Q-GaLore optimizer and custom embedding learning rate in the Unsloth trainer.
* feat: Implement QGaLoreAdamW8bit optimizer with 8-bit states, GaLore low-rank gradient projection, and optional INT8 weight quantization, along with supporting projector and tests.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat: Introduce Q-GaLore AdamW optimizer with low-rank quantized gradient projection and integrate into the trainer, along with dedicated tests.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* feat: Implement Q-GaLore AdamW optimizer with gradient projection and quantization, including trainer integration and corresponding tests.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix 3 bugs in Q-GaLore optimizer and add weight_quant forward hooks
1. Fix use-after-delete crash: move `del p._saved_data` after the
weight decay block so decoupled weight decay can reference the
current weights correctly (p.data).
2. Fix substring matching in make_q_galore_param_groups: split
parameter names on "." and check exact component matches to
prevent false positives (e.g. "not_q_proj" matching "q_proj").
3. Implement forward pre-hooks for weight_quant: after the optimizer
quantizes weights to INT8, replace p.data with a 1-element
placeholder to free float memory. A register_forward_pre_hook
dequantizes back to float before each forward pass. The trainer
calls install_weight_quant_hooks() when weight_quant is enabled.
4. Update test_weight_decay_uses_saved_data to match the fixed code
path (decoupled decay uses p.data, expected value 2.7). Add
test_weight_quant_hook_restores_float to verify the INT8-to-float
hook round-trip.
All 24/24 Q-GaLore tests pass. Benchmarked on Llama-3.2-1B-Instruct
FFT: Q-GaLore saves 32% VRAM (10.63 -> 7.24 GB) with better loss
convergence (1.3 vs 2.0 at step 100). No regressions in 31-notebook
sweep across Llama, Qwen, Mistral, Phi, Gemma, vision, and GRPO.
* Default weight_quant to False in QGaloreConfig
Benchmarks show weight_quant=True adds ~1 GB on Llama-3.2-1B due to
INT8 copy/scale overhead exceeding savings from the placeholder trick.
Users can still opt in explicitly. The optimizer logic is unchanged.
* Optimize Q-GaLore projector and optimizer step performance
Projector (q_galore_projector.py):
- Use torch.svd_lowrank with oversampling p=10 (Halko et al. 2009) instead
of full SVD for large matrices. Falls back to full SVD when min(m,n) <= 2*rank.
SVD steps are 6-8x faster on Llama-3.2-1B (22s -> 3s for first step).
- Cache the dequantized ortho matrix between project() and project_back() to
avoid redundant dequantization when quant=True.
- Replace F.cosine_similarity with torch.dot for 1-D unit vectors in the
adaptive schedule. Remove unused torch.nn.functional import.
- Use collections.deque(maxlen=queue_size) instead of list with manual pop(0).
Optimizer (q_galore_adamw.py):
- Remove redundant .clone() on dequantized weights (line 151) and on float
data before re-quantization (line 211). _dequantize already returns a fresh
tensor and _quantize/_quantize_stochastic only reads its input.
- Consolidate per-group torch.cuda.synchronize() into a single call after
all param groups complete.
- Use torch.empty instead of torch.zeros for the scalar placeholder tensor
that is never read.
Verified: 24/24 unit tests pass. Llama-3.2-1B 61-step training produces
losses within 0.24% relative diff (correlation >0.9999) of the original.
* [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>
2026-03-25 01:03:10 -07:00
Daniel Han
3bddfed117
Patch trunc_normal_ for low-precision stability ( #4027 )
...
* Fix low-precision trunc_normal initialization instability
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Document TorchTitan trunc_normal low-precision failure mode
* Fix trunc_normal generator positional compatibility
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix trunc_normal generator TypeError fallback
---------
Co-authored-by: Daniel Hanchen <danielhanchen@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-02-19 04:40:14 -08:00
Mohammad Miadh Angkad
336bec216a
Refactor Ollama template wiring and harden packing helpers ( #3890 )
...
* Refactor Ollama template wiring and harden packing helpers
Signed-off-by: Mohammad Miadh Angkad <MAngkad.BSDSBA2027@aim.edu>
* Fix Qwen3 and Gemma3n template bindings and tidy packing test helper
* Fix gptoss Ollama comment and tinyllama stop parameter
- Fix wrong comment referencing gemma3n for gptoss_ollama in chat_templates.py
- Add missing stop keyword to tinyllama PARAMETER in ollama_template_mappers.py
* Fix _DummyTrainer compatibility across TRL versions
The try/except only handled the removal of return_position_ids
(TRL v0.24+) but not the absence of padding_free (TRL v0.18.2).
Gracefully degrade through all optional collator flags so the
test works from trl>=0.18.2 through v0.27+.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Signed-off-by: Mohammad Miadh Angkad <MAngkad.BSDSBA2027@aim.edu>
Co-authored-by: Daniel Hanchen <danielhanchen@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-02-09 04:04:48 -08:00
electroglyph
d80e69258c
add weight-only int8 QAT scheme and update tests for torchao 0.15.0 ( #3859 )
...
* add int8 weight-only QAT scheme, add test, fix tests for current torchao version
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* change quantization to PerAxis
* lambda =/
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add torchao messages, remove group_size from int8
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* raise exception on missing torchao
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* touch up the torchao imports
* [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-01-16 09:32:29 +05:30
Dan Saunders
75e0d7ce62
Auto-enable padding-free SFT ( #3672 )
...
* implement (sdpa, xformers, fa2) sample packing
* attention dispatching
* ddp working OOTB with CLI
* packed SWA and softcap support
* enable batch flattening
* LGPL license headers
* mask packed sequence boundaries
* auto-enable sample packing
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add explicit toggle for sample packing
* Add explicit toggle for sample packing
* Update __init__.py
* Update unsloth/kernels/rope_embedding.py
* Update unsloth/kernels/rope_embedding.py
* remove grad output clones; restore deleted FastLanguageModel arg
* fix
* restore rope embedding clones
* xformers mask cache
* implement (sdpa, xformers, fa2) sample packing
* attention dispatching
* ddp working OOTB with CLI
* packed SWA and softcap support
* enable batch flattening
* LGPL license headers
* mask packed sequence boundaries
* auto-enable sample packing
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add explicit toggle for sample packing
* Add explicit toggle for sample packing
* Update __init__.py
* Update unsloth/kernels/rope_embedding.py
* Update unsloth/kernels/rope_embedding.py
* remove grad output clones; restore deleted FastLanguageModel arg
* fix
* restore rope embedding clones
* xformers mask cache
* add back accidental deletion
* Update unsloth/kernels/rope_embedding.py
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix merge conflicts
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add **kwargs
* add back clobbered
* Update rope_embedding.py
* Update rope_embedding.py
* simplify trl warnings filter
* docstring
* nit
* bugfix
* add padding-free seqlen metadata
* auto-enable padding free
* gemma2 disable
* Apply suggestion from @danielhanchen
* Update trainer.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update trainer.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>
2025-12-10 03:07:29 -08:00
Dan Saunders
496f84ff6b
SFT sample packing ( #3566 )
...
* implement (sdpa, xformers, fa2) sample packing
* attention dispatching
* ddp working OOTB with CLI
* packed SWA and softcap support
* enable batch flattening
* LGPL license headers
* mask packed sequence boundaries
* auto-enable sample packing
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add explicit toggle for sample packing
* Add explicit toggle for sample packing
* Update __init__.py
* Update unsloth/kernels/rope_embedding.py
* Update unsloth/kernels/rope_embedding.py
* remove grad output clones; restore deleted FastLanguageModel arg
* fix
* restore rope embedding clones
* xformers mask cache
* implement (sdpa, xformers, fa2) sample packing
* attention dispatching
* ddp working OOTB with CLI
* packed SWA and softcap support
* enable batch flattening
* LGPL license headers
* mask packed sequence boundaries
* auto-enable sample packing
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add explicit toggle for sample packing
* Add explicit toggle for sample packing
* Update __init__.py
* Update unsloth/kernels/rope_embedding.py
* Update unsloth/kernels/rope_embedding.py
* remove grad output clones; restore deleted FastLanguageModel arg
* fix
* restore rope embedding clones
* xformers mask cache
* add back accidental deletion
* Update unsloth/kernels/rope_embedding.py
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix merge conflicts
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add **kwargs
* add back clobbered
* Update rope_embedding.py
* Update rope_embedding.py
* simplify trl warnings filter
* docstring
* nit
* bugfix
* Apply suggestion from @danielhanchen
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update unsloth/trainer.py
* Update unsloth/trainer.py
* Update unsloth/trainer.py
* Update unsloth/trainer.py
---------
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-09 17:36:45 -08:00
Daniel Han
66649d18bd
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
...
This reverts commit cad158a56c .
2025-12-01 07:24:58 -08:00
pre-commit-ci[bot]
cad158a56c
[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
487a951914
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
...
This reverts commit 964c9fef95 .
2025-12-01 07:24:21 -08:00
pre-commit-ci[bot]
964c9fef95
[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
5f27bc4db5
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
...
This reverts commit d34e0454ac .
2025-12-01 07:23:31 -08:00
pre-commit-ci[bot]
d34e0454ac
[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
ba2897a318
Revert "[FIX] Vllm guided decoding params ( #3662 )"
...
This reverts commit fb4f0fdf56 .
2025-12-01 05:43:45 -08:00
Datta Nimmaturi
fb4f0fdf56
[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 58b483dc0d1790f99580665801d3fa0d7267c533.
* [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 b2497519659a9f301e7a633795d9efdafdc2b277.
* [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 de3daaf429f81aceb6632932b0cb1af5149652a8.
* [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
d6bb89ad44
Formatting & bug fixes ( #3563 )
...
* Update rl.py
* Fix CE Loss
* Versioning
* Update loader.py
* Update loader.py
* extract_model_type_from_config
* Model types
* Update loader.py
* get_transformers_model_type
* Update loader.py
* Update loader.py
* Update loader.py
* Update rl.py
* Update pyproject.toml
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Versioning
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update vision.py
* Update vision.py
* Fix DataParallel
* Update _utils.py
* Update rl.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update mapper.py
* Versioning
* Update loader.py
* Update loader.py
* Update rl.py
* Versioning
* Update _utils.py
* Fix auto_mapping
* Update loader.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update loader.py
* Message
* Update vision.py
* Update loader.py
* Update vision.py
* cache_implementation
* Update vision.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Save max_seq_length
* Update _utils.py
* Update rl.py
* Update vision.py
* Update llama.py
* Mistral3 vllm (#3349 )
* [WIP] use vLLM for vision language models
* Update README.md
Editing icon sizes
* Update README.md
Updating icon sizes
* Update README.md (#2885 )
* MoE kernels AGPLv3
* versioning
* Many bug fixes (#2908 )
* add deepseek v3
* add deepseek r1 base
* add deepseek r1 zero
* add deepseek distill llama
* add deepseek distill models
* remove redundant code when constructing model names
* add mistral small to registry
* rename model registration methods
* rename deepseek registration methods
* refactor naming for mistral and phi
* add global register models
* refactor model registration tests for new registry apis
* add model search method
* remove deprecated registration api
* add quant type test
* add registry readme
* make llama registration more specific
* clear registry when executing individual model registration file
* more registry readme updates
* Update _auto_install.py
* Llama4
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Synthetic data
* Update mapper.py
* Xet and Synthetic
* Update synthetic.py
* Update loader.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update pyproject.toml
* Delete .gitignore
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update _utils.py
* Update pyproject.toml
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update chat_templates.py
* Seasame force float16 / float32
* Fix Seasame
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* is_multimodal
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* UNSLOTH_DISABLE_STATIC_GENERATION
* Update vision.py
* Auto vision detection
* Sesame
* Whisper
* Update loader.py
* Update loader.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update _utils.py
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* logging
* Update pyproject.toml
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* logits / temperature
* Update rl_replacements.py
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Debugging only
* Update llama.py
* Update llama.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Generic efficient GRPO
* Update rl_replacements.py
* Update rl_replacements.py
* Remove debugging
* Update rl_replacements.py
* Update rl_replacements.py
* Update vision.py
* Update llama.py
* Update rl_replacements.py
* versioning
* Update _utils.py
* Update vision.py
* Update mapper.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update loader.py
* Update _utils.py
* Update vision.py
* gradient checkpointing
* Gemma 3N fixes
* Update loader.py
* Versioning
* Gemma 3N fixes
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Fix setup.py
* setup.py
* Prints
* Update setup.py
* Update setup.py
* Update setup.py
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update vision.py
* Update vision.py
* Update pyproject.toml
* Update vision.py
* Update _utils.py
* Update __init__.py
* Update __init__.py
---------
Co-authored-by: jeromeku <jerome.ku@gmail.com>
Co-authored-by: Michael Han <107991372+shimmyshimmer@users.noreply.github.com>
* silienty skip falcon h1 import is transformers_version < 4.53.0 (#2912 )
* Dynamically adjust get_per_token_logps function and patch as well (#2911 )
* add intel gpu with vllm support (#2903 )
* [bugs] fix for casual mask (#2868 )
* fix for casual mask
* use un_casual in sdpa
* add missing mask
* fix for type
* Explicitly check if xformers exists for attention (#2889 )
* Update __init__.py
* Update llama.py
* if mlp doesn't exist in layer module check for feed_forward name for falcon h1 (#2913 )
* Move inputs to right devices. (#2919 )
* Move tensors to right devices
* fix multi gpu for non mistral models
* multi GPU RoPE for gemma2
* Finish up multi GPU inference
* Make multiGPU rope a list
* Remove unnecessary transfer to CPU
* Remove unnecessary move to CPU
* Donot move inputs to device yet
will be handled separately in another PR
* Move inputs to appropriate decoder device
* Make device count global variable
* Cleanup RoPE device code
* Fixup num_gpu to device count
* Cleanup device counts
* Use device index for RoPE get_cache
* Donot typecast
* Use tuple instead of list for tensors. Use device index directly
* fixup move to device logic
* WIP VLM vLLM
* Make vLLM patch a function
* Add save and load lora functions
* Make fast_inference setup depend on the flag
* Improve fast inference patching mechanism
* Make vision setting depend on checks in fastbasemodel
* Check LoRA and vLLM intercompatibility for vision models
* Comment pointing to vLLM LoRA check
* Improve lora validation on vLLM
* Error out on no vLLM and increase max lora rank
* Bug fixes (#3017 )
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update pyproject.toml
* Delete .gitignore
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update _utils.py
* Update pyproject.toml
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update chat_templates.py
* Seasame force float16 / float32
* Fix Seasame
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* is_multimodal
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* UNSLOTH_DISABLE_STATIC_GENERATION
* Update vision.py
* Auto vision detection
* Sesame
* Whisper
* Update loader.py
* Update loader.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update _utils.py
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* logging
* Update pyproject.toml
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* logits / temperature
* Update rl_replacements.py
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Debugging only
* Update llama.py
* Update llama.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Generic efficient GRPO
* Update rl_replacements.py
* Update rl_replacements.py
* Remove debugging
* Update rl_replacements.py
* Update rl_replacements.py
* Update vision.py
* Update llama.py
* Update rl_replacements.py
* versioning
* Update _utils.py
* Update vision.py
* Update mapper.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update loader.py
* Update _utils.py
* Update vision.py
* gradient checkpointing
* Gemma 3N fixes
* Update loader.py
* Versioning
* Gemma 3N fixes
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Fix setup.py
* setup.py
* Prints
* Update setup.py
* Update setup.py
* Update setup.py
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update vision.py
* Update vision.py
* Update pyproject.toml
* Update vision.py
* Update _utils.py
* Update __init__.py
* Update __init__.py
* Small fixes
* Update vision.py
* Update vision.py
* versioning
* Update __init__.py
* Update llama.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Update vision.py
* Update vision.py
* compiler stance
* Update _utils.py
* Update pyproject.toml
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Revert "Revert "Add Qwen2.5-VL-32B-Instruct mapping to fix quantized model me…" (#2990 )
This reverts commit 4021da634a .
* skip_guard_eval_unsafe fix
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update llama.py
* Update llama.py
* Fix `quantization_method`
* versioning
* fix for casual mask (#3011 )
* [intel] add for intel path for llama.py (#3012 )
* fix for intel path
* remove unuse code
* Update unsloth/models/llama.py
---------
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* Update llama.py
* Fix Gemma 2 (#3024 )
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update pyproject.toml
* Delete .gitignore
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update _utils.py
* Update pyproject.toml
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update chat_templates.py
* Seasame force float16 / float32
* Fix Seasame
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* is_multimodal
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* UNSLOTH_DISABLE_STATIC_GENERATION
* Update vision.py
* Auto vision detection
* Sesame
* Whisper
* Update loader.py
* Update loader.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update _utils.py
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* logging
* Update pyproject.toml
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* logits / temperature
* Update rl_replacements.py
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Debugging only
* Update llama.py
* Update llama.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Generic efficient GRPO
* Update rl_replacements.py
* Update rl_replacements.py
* Remove debugging
* Update rl_replacements.py
* Update rl_replacements.py
* Update vision.py
* Update llama.py
* Update rl_replacements.py
* versioning
* Update _utils.py
* Update vision.py
* Update mapper.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update loader.py
* Update _utils.py
* Update vision.py
* gradient checkpointing
* Gemma 3N fixes
* Update loader.py
* Versioning
* Gemma 3N fixes
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Fix setup.py
* setup.py
* Prints
* Update setup.py
* Update setup.py
* Update setup.py
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update vision.py
* Update vision.py
* Update pyproject.toml
* Update vision.py
* Update _utils.py
* Update __init__.py
* Update __init__.py
* Small fixes
* Update vision.py
* Update vision.py
* versioning
* Update __init__.py
* Update llama.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Update vision.py
* Update vision.py
* compiler stance
* Update _utils.py
* Update pyproject.toml
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Revert "Revert "Add Qwen2.5-VL-32B-Instruct mapping to fix quantized model me…" (#2990 )
This reverts commit 4021da634a .
* skip_guard_eval_unsafe fix
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update llama.py
* Update llama.py
* Fix `quantization_method`
* versioning
* Update _utils.py
* Update _utils.py
* Update _utils.py
* falcon force float32 on sm<75 machines (#3026 )
* Fix torch compile issues (#3028 )
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update pyproject.toml
* Delete .gitignore
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update _utils.py
* Update pyproject.toml
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update chat_templates.py
* Seasame force float16 / float32
* Fix Seasame
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* is_multimodal
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* UNSLOTH_DISABLE_STATIC_GENERATION
* Update vision.py
* Auto vision detection
* Sesame
* Whisper
* Update loader.py
* Update loader.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update _utils.py
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* logging
* Update pyproject.toml
* Update rl.py
* versioning
* Update rl.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* logits / temperature
* Update rl_replacements.py
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Debugging only
* Update llama.py
* Update llama.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Generic efficient GRPO
* Update rl_replacements.py
* Update rl_replacements.py
* Remove debugging
* Update rl_replacements.py
* Update rl_replacements.py
* Update vision.py
* Update llama.py
* Update rl_replacements.py
* versioning
* Update _utils.py
* Update vision.py
* Update mapper.py
* Update loader.py
* Update mapper.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update loader.py
* Update _utils.py
* Update vision.py
* gradient checkpointing
* Gemma 3N fixes
* Update loader.py
* Versioning
* Gemma 3N fixes
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Fix setup.py
* setup.py
* Prints
* Update setup.py
* Update setup.py
* Update setup.py
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update pyproject.toml
* Update vision.py
* Update vision.py
* Update pyproject.toml
* Update vision.py
* Update _utils.py
* Update __init__.py
* Update __init__.py
* Small fixes
* Update vision.py
* Update vision.py
* versioning
* Update __init__.py
* Update llama.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Update vision.py
* Update vision.py
* compiler stance
* Update _utils.py
* Update pyproject.toml
* Update pyproject.toml
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Revert "Revert "Add Qwen2.5-VL-32B-Instruct mapping to fix quantized model me…" (#2990 )
This reverts commit 4021da634a .
* skip_guard_eval_unsafe fix
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update synthetic.py
* Update llama.py
* Update llama.py
* Fix `quantization_method`
* versioning
* Update _utils.py
* Update _utils.py
* Update _utils.py
* check stride
* Cleanup
* Update rope_embedding.py
* Update gemma2.py
* Fix `set_stance`
* Update pyproject.toml
* Update _utils.py
* Fixup patch vllm
* Disable mllama
* Use variables to decide VLM support
* Better attn_impl handling
* Patch TF protobuf incompatability
* Torch 2.8 (#3186 )
* Fix mamba
* Update loader.py
* Update vision.py
* Update loader.py
* Filter vLLM standby logs (#3131 )
* filter vLLM standby logs
* safeguard standby logger patch
* Update unsloth/models/_utils.py
* Update unsloth/models/_utils.py
* Update unsloth/models/_utils.py
---------
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* Update loader.py
* Add scaler
* Update llama.py
* Update _utils.py
* Versioning
* GPT OSS fix
* GPT OSS fix
* Update loader.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update llama.py
* Update llama.py
* Update llama.py
* Versioning
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Upcast norms
* Update loader.py
* Update vision.py
* Upcast layernorms
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update save.py
* Update rl.py
* Update pyproject.toml
* Update rl.py
* Update rl_replacements.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Update __init__.py
* Torch 2.8
* Update rl_replacements.py
---------
Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com>
* Update _auto_install.py
* Update pyproject.toml
* Update rl.py
* Protobuf issue
* Update pyproject.toml
* Fix extras transformers typo in pyproject.toml
* Update _utils.py
* Bug fixes (#3195 )
* Fix mamba
* Update loader.py
* Update vision.py
* Update loader.py
* Filter vLLM standby logs (#3131 )
* filter vLLM standby logs
* safeguard standby logger patch
* Update unsloth/models/_utils.py
* Update unsloth/models/_utils.py
* Update unsloth/models/_utils.py
---------
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* Update loader.py
* Add scaler
* Update llama.py
* Update _utils.py
* Versioning
* GPT OSS fix
* GPT OSS fix
* Update loader.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update llama.py
* Update llama.py
* Update llama.py
* Versioning
* Update mapper.py
* Update vision.py
* Update vision.py
* Update vision.py
* Upcast norms
* Update loader.py
* Update vision.py
* Upcast layernorms
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update save.py
* Update rl.py
* Update pyproject.toml
* Update rl.py
* Update rl_replacements.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Update __init__.py
* Torch 2.8
* Update rl_replacements.py
* Update loader.py
* UNSLOTH_ENABLE_CCE
* Fix
* Update loader.py
* Update loader.py
* Update __init__.py
* Update __init__.py
* Update __init__.py
* Update __init__.py
* Import fixes
* Update loader.py
* Fix aimv2 issue
* Update loader.py
* Update import_fixes.py
* Update import_fixes.py
* Update loader.py
* Update loader.py
* Update loader.py
* Upgrade
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
---------
Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com>
* adallow float32 dtype in FastLanguageModel (#3204 )
* Update loader.py
* Update vision.py
* Suppress message and use unsloth sampling params
* Use trl sampling params for now
* Improve error message
* fixup quantized fast inference model name
* Add mistral 3 support
---------
Co-authored-by: Michael Han <107991372+shimmyshimmer@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: jeromeku <jerome.ku@gmail.com>
Co-authored-by: DoubleMathew <mmathew23@gmail.com>
Co-authored-by: Lei Zhenyuan <zhenyuan.lei@intel.com>
Co-authored-by: parth2510 <parthguptapg7326@gmail.com>
* Set padding to 0
* Fix patch
* fixup patch (#3359 )
Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com>
* Update vision.py
* Versioning
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* MXFP4 dequant
* Update loader.py
* Update vision.py
* load_in_16bit
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl.py
* Update vision.py
* offload_embedding
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl_replacements.py
* Update loader.py
* Fix padding issue
* Update pyproject.toml
* Update _utils.py
* Update pyproject.toml
* Update _utils.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* New models
* Update llama.py
* Versioning
* Update _utils.py
* Update llama.py
* Update _utils.py
* Update llama.py
* Fix AMD
* Update _utils.py
* Update llama.py
* Update vision.py
* DEVICE_TYPE_TORCH
* Update __init__.py
* Update __init__.py
* Update _utils.py
* Move DEVICE_TYPE
* Update rl_replacements.py
* Update loader.py
* AMD install script
* Move AMD
* Update _amd_install.sh
* Update pyproject.toml
* Update pyproject.toml
* Delete _amd_install.sh
* Update device_type.py
* Update loader.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update tokenizer_utils.py
* Versioning
* Update pyproject.toml
* Update loader.py
* Update _utils.py
* Update pyproject.toml
* Update pyproject.toml
* Update _utils.py
* Update pyproject.toml
* Update _utils.py
* Update _utils.py
* Update loader.py
* Update _utils.py
* Update _utils.py
* local_files_only
* Cut Cross Entropy
* Update llama.py
* Update vision.py
* Update vision.py
* Update vision.py
* Qwen 3 VL vLLM (#3489 )
* Update __init__.py
* patch_torchao
* torchao_logger
* Update rl_replacements.py
* Fix
* Update rl.py
* Update rl.py
* Update rl.py
* Update rl.py
* Update _utils.py
* Versioning
* fbgemm fp8 block quant support (>=1.4.0) (#3531 )
* fbgemm fp8 block quant support (>=1.4.0)
* Verify for fp8 support before proceeding
* Use unsloth zoo's Version and improve comments
* spacessss
* Update vision.py
* Update vision.py
* Update rl.py
* vllm_sampling_params
* Update rl.py
* Update rl.py
* Update rl.py
* Add `ruff` pre-commit hook and apply it (#3424 )
* Add Ruff pre-commit config and workflow
* Add kwarg spacing enforcement helper
* Apply Ruff formatting
* Update fp8.py
* Revert ruff on some files
* Update
* force-exclude = true
* Datasets issue
* Ruff
* Remove mapper
* Update mapper.py
* Update pyproject.toml
---------
Co-authored-by: Datta Nimmaturi <venkatadattasainimmaturi@gmail.com>
Co-authored-by: Michael Han <107991372+shimmyshimmer@users.noreply.github.com>
Co-authored-by: jeromeku <jerome.ku@gmail.com>
Co-authored-by: DoubleMathew <mmathew23@gmail.com>
Co-authored-by: Lei Zhenyuan <zhenyuan.lei@intel.com>
Co-authored-by: parth2510 <parthguptapg7326@gmail.com>
Co-authored-by: Dan Saunders <danjsaund@gmail.com>
2025-11-07 06:00:22 -08:00
andrewor14
3ffb3bdcfe
Fix QAT + LoRA fast path, add tests ( #3307 )
...
**Summary:** The existing QAT + LoRA path only applied fake
quantization to the original slow path, but the default is the
fast path that calls unsloth's fast LoRA primitives. This commit
integrates fake quantization into these fast primitives as well,
and add unit tests to assert that fake quantization is actually
taking place.
**Test Plan:**
Unit tests:
```
pytest tests/utils/test_qat.py
```
End-to-end test: https://gist.github.com/andrewor14/6360dd69b5784c71c46e80c14f53e6b6
Full fine-tuning Llama3.1-8B with and without QAT + LoRA on yahma/alpaca-cleaned for 1 epoch:
- Batch size = 8 (no grad accum)
- Learning rate = 2e-4
- Quantization scheme = int4 weight only (with bf16 activations)
Wikitext perplexity:
- Baseline = int4 quantized model finetuned without QAT
- QAT int4 quantized model (with this PR) achieved 33% lower perplexity than the int4 baseline
- QAT int4 quantized model without this PR was worse than the int4 baseline
```
==> unsloth_model_lora_baseline_output/lm_eval_float.log <==
| | |none | 0|word_perplexity|↓ |7.5551|± | N/A|
==> unsloth_model_lora_baseline_output/lm_eval_quantized.log <==
| | |none | 0|word_perplexity|↓ |8.7655|± | N/A|
==> unsloth_model_lora_qat_int4_output/lm_eval_quantized.log <==
| | |none | 0|word_perplexity|↓ |8.3548|± | N/A|
```
2025-09-17 15:18:17 -07:00
leopardracer
c6e0366e0d
Fix Typos in Documentation and Comments ( #2721 )
...
* Update ocr_eval.md
* Update backward.py
2025-06-17 04:34:51 -07:00
Roland Tannous
efe2cc43a7
tests for additional merge fix unsloth zoo pr 163 ( #2719 )
...
* tests for additional merge fix unsloth zoo pr 163
* fixed load_dataset indent in mistral perplexity test file
2025-06-11 14:08:41 -07:00
Roland Tannous
58f3a6e29d
reroute merge logic language models + comprehensive tests + eval kits ( #2673 )
2025-06-02 20:32:57 -07:00
Daniel Han
c466303956
Fix Transformers 4.45 ( #2151 )
...
* Update pyproject.toml
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Batch samples
* Update loader.py
* Update loader.py
* Update loader.py
* Update loader.py
* Update _utils.py
* Update loader.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update mapper.py
* Update vision.py
* Temporary patches
* Update loader.py
* model names
* Gemma 3 chat template
* Bug fixes
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update llama.py
* Update llama.py
* Update rl.py
* Update chat_templates.py
* Update chat_templates.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update vision.py
* Revert
* Update _utils.py
* forced precision
* Autocast
* Update vision.py
* Update vision.py
* Update rl.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl.py
* vLLM fixes
* constexpr
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update save.py
* New models
* Triton windows update (#1976 )
* Update pyproject.toml
* Update README.md
* Update RMS LayerNorm implementation, and list compr. change in chat templates (#1974 )
* Update RMS LayerNorm implementation with optimizations and testing suite
* perf: optimize list comprehension in get_ollama_eos_tokens
* Update Zoo
* Update llama.py
* Update llama.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl_replacements.py
* Update vision.py
* grpo fix
* Update rl_replacements.py
* Update vision.py
* Update rl_replacements.py
* Update vision.py
* Update mapper.py
* Update vision.py
* Update vision.py
* Update loader.py
* Update vision.py
* Update save.py
* Update save.py
* Update save.py
* Update rl.py
* Update _utils.py
* Version
* Update pyproject.toml
* Update llama.py
* Update llama.py
* bug fix #2008 (#2039 )
* fix (#2051 )
* Update loader.py
* Update pyproject.toml
* Update pyproject.toml
* Update vision.py
* more prints
* Update loader.py
* LoRA 16bit fix
* Update vision.py
* Update vision.py
* Update _utils.py
* Update vision.py
* move forced float32
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update _utils.py
* move print
* Update _utils.py
* disable bfloat16
* Fix forced float32
* move float32
* Ensure trust_remote_code propegates down to unsloth_compile_transformers (#2075 )
* Update _utils.py
* Show both `peft_error` and `autoconfig_error`, not just `autoconfig_error` (#2080 )
When loading a PEFT model fails, only the `autoconfig_error` is shown. Instead of the `peft_error`, which is what really matters when we're trying to load a PEFT adapter, the user will see something like this:
```
RuntimeError: Unrecognized model in my_model. Should have a `model_type` key in its config.json, or contain one of the following strings in its name: albert, align, altclip, ...
```
This PR just changes it so `autoconfig_error` and `peft_error` are both displayed.
* fix error message (#2046 )
* Update vision.py
* Update _utils.py
* Update pyproject.toml
* Update __init__.py
* Update __init__.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update rl_replacements.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update rl_replacements.py
* Update vision.py
* Update rl_replacements.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Remove double generate patch
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update mapper.py
* Update vision.py
* fix: config.torch_dtype in LlamaModel_fast_forward_inference (#2091 )
* fix: config.torch_dtype in LlamaModel_fast_forward_inference
* Update llama.py
* update for consistency
---------
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
* versioning
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* model_type_arch
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update vision.py
* Update loader.py
* check
* Update _utils.py
* Update loader.py
* Update loader.py
* Remove prints
* Update _utils.py
* Update _utils.py
* versioning
* Update _utils.py
* Update _utils.py
* Update _utils.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update llama.py
* Update vision.py
* HF Transfer
* fix(utils): add missing importlib import to fix NameError (#2134 )
This commit fixes a NameError that occurs when `importlib` is referenced in _utils.py
without being imported, especially when UNSLOTH_USE_MODELSCOPE=1 is enabled.
By adding the missing import statement, the code will no longer throw a NameError.
* Add QLoRA Train and Merge16bit Test (#2130 )
* add reference and unsloth lora merging tests
* add test / dataset printing to test scripts
* allow running tests from repo root
* add qlora test readme
* more readme edits
* ruff formatting
* additional readme comments
* forgot to add actual tests
* add apache license
* Update pyproject.toml
---------
Co-authored-by: Akshay Behl <126911424+Captain-T2004@users.noreply.github.com>
Co-authored-by: Nino Risteski <95188570+NinoRisteski@users.noreply.github.com>
Co-authored-by: Mukkesh Ganesh <mukmckenzie@gmail.com>
Co-authored-by: Kareem <81531392+KareemMusleh@users.noreply.github.com>
Co-authored-by: Xander Hawthorne <167850078+CuppaXanax@users.noreply.github.com>
Co-authored-by: Isaac Breen <isaac.breen@icloud.com>
Co-authored-by: lurf21 <93976703+lurf21@users.noreply.github.com>
Co-authored-by: naliazheli <nalia0316@gmail.com>
Co-authored-by: jeromeku <jerome.ku@gmail.com>
2025-03-21 17:55:12 -07:00