Commit 6559367
Update transformers to v5.x, unsloth, and add MoE LoRA conversion (#576)
* feat: update transformers to v5.x, unsloth, and add MoE LoRA conversion
Update core dependencies for transformers v5 ecosystem:
- transformers: >=4.55.2,<=4.57.3 → >=5.1.0
- unsloth: 2025.12.9 → 2026.2.1
- unsloth-zoo: 2025.12.7 → 2026.2.1 (+ updated VCS pin)
- trl: 0.20.0 → >=0.28.0
- peft: >=0.14.0 → >=0.18.0 (required by transformers v5)
Fix transformers v5 breaking changes:
- Replace removed dummy_pt_objects import with direct transformers import
- Update masking_utils patch return type (now returns 5 values)
- Remove deprecated TrainerArgs fields (overwrite_output_dir,
jit_mode_eval, mp_parameters, logging_dir, fp16_backend,
push_to_hub_token/model_id/organization)
Add MoE LoRA adapter conversion utility for vLLM compatibility:
- Unsloth + transformers v5 saves MoE LoRA as fused 2D tensors
- vLLM expects per-expert format
- Auto-detect and convert after checkpoint save
Closes #575
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: pin trl<=0.24.0 for unsloth 2026.2.1 compatibility
Unsloth 2026.2.1 requires trl>0.18.2,!=0.19.0,<=0.24.0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: override unsloth dep constraints for transformers v5 + trl compat
Unsloth 2026.2.1's pyproject.toml has overly strict constraints
(transformers<=4.57.6, trl<=0.24.0) but the February-2026 release
notes confirm v5.1.0 + trl 0.27.1 work well.
Use uv override-dependencies to allow the upgrade.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add warnings_issued attr for transformers v5 + unsloth compat
Transformers v5 removed `warnings_issued` from PreTrainedModel, but
Unsloth's GRPOTrainer still accesses it during initialization. Add it
as an empty dict on the PEFT model before creating the trainer.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add return_dict=False to apply_chat_template calls for transformers v5
Transformers v5 changed apply_chat_template to return BatchEncoding by
default when tokenize=True. Add return_dict=False to all calls that
expect list[int] return type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove unsloth-zoo VCS pin, use PyPI 2026.2.1 instead
The bradhilton/unsloth-zoo fork is at version 2025.8.4 which is
missing modules needed by unsloth 2026.2.1 (e.g. unsloth_zoo.device_type).
Switch to the official PyPI release which matches unsloth 2026.2.1.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* revert: remove unnecessary changes to backend.vcs.txt and model.py
These changes were not needed for the transformers v5 upgrade:
- backend.vcs.txt: not used for installation (pyproject.toml handles deps)
- model.py TrainerArgs: TypedDict fields don't cause runtime errors
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove TrainerArgs fields removed in transformers v5
Remove fields that transformers v5 dropped from TrainingArguments:
overwrite_output_dir, logging_dir, jit_mode_eval, half_precision_backend,
tpu_num_cores, past_index, fp16_backend, push_to_hub_model_id,
push_to_hub_organization, push_to_hub_token, mp_parameters,
torchdynamo, ray_scope.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: pin transformers==5.1.0 to avoid breakage from future releases
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: restore trl==0.20.0 pin and remove unnecessary trl override
trl was originally pinned to 0.20.0. No reason to loosen it — 0.20.0
already satisfies unsloth's trl<=0.24.0 constraint.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: centralize apply_chat_template return_dict=False patch
Instead of adding return_dict=False to every call site, patch
PreTrainedTokenizerBase.apply_chat_template once in patches.py to
default return_dict=False. This restores transformers v4 behavior
(returning list[int]) globally.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: correct comment about warnings_issued workaround
The attribute wasn't removed in transformers v5 — Unsloth's model
patching can leave the PEFT model without it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: remove invalid exclude-dependencies and add apex dependency-metadata
exclude-dependencies is not a valid [tool.uv] field in uv 0.8.x, which
caused the entire settings section to be silently ignored. This meant
dependency-metadata, no-build-isolation-package, and extra-build-dependencies
were all skipped, forcing uv to build apex from source during resolution —
which fails on non-GPU machines missing torch.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* add exclude-dependencies = ["pynvml"] back
* clean pyproject
* update uv lock
* update transformers to v5.2.0
* cleaner types
* lint fix
* add extra fix to lora conversion
* fix build
* ruff fix
* revert pyproject change
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 6560dfd commit 6559367
8 files changed
Lines changed: 260 additions & 41 deletions
File tree
- src/art
- dev
- preprocessing
- transformers
- unsloth
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
| |||
226 | 225 | | |
227 | 226 | | |
228 | 227 | | |
229 | | - | |
230 | 228 | | |
231 | 229 | | |
232 | 230 | | |
| |||
243 | 241 | | |
244 | 242 | | |
245 | 243 | | |
246 | | - | |
247 | 244 | | |
248 | 245 | | |
249 | 246 | | |
250 | 247 | | |
251 | | - | |
252 | 248 | | |
253 | 249 | | |
254 | 250 | | |
255 | 251 | | |
256 | 252 | | |
257 | | - | |
258 | 253 | | |
259 | 254 | | |
260 | 255 | | |
261 | 256 | | |
262 | 257 | | |
263 | 258 | | |
264 | | - | |
265 | 259 | | |
266 | 260 | | |
267 | 261 | | |
| |||
302 | 296 | | |
303 | 297 | | |
304 | 298 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | 299 | | |
311 | 300 | | |
312 | | - | |
313 | | - | |
314 | 301 | | |
315 | 302 | | |
316 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 200 | + | |
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
| |||
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
349 | | - | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | | - | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| 441 | + | |
439 | 442 | | |
440 | 443 | | |
441 | 444 | | |
| |||
921 | 924 | | |
922 | 925 | | |
923 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
924 | 932 | | |
925 | 933 | | |
926 | 934 | | |
| |||
0 commit comments