Skip to content

Commit bff6b84

Browse files
authored
chore: bump unsloth to sept-2024 (#403)
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
1 parent 4e4ac66 commit bff6b84

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

pkg/aikit2llb/finetune/convert.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
unslothCommitOrTag = "27fa021a7bb959a53667dd4e7cdb9598c207aa0d" // June-2024
15+
unslothCommitOrTag = "fb77505f8429566f5d21d6ea5318c342e8a67991" // September-2024
1616
nvidiaMknod = "mknod --mode 666 /dev/nvidiactl c 195 255 && mknod --mode 666 /dev/nvidia-uvm c 235 0 && mknod --mode 666 /dev/nvidia-uvm-tools c 235 1 && mknod --mode 666 /dev/nvidia0 c 195 0 && nvidia-smi"
1717
sourceVenv = ". .venv/bin/activate"
1818
)
@@ -46,7 +46,7 @@ func Aikit2LLB(c *config.FineTuneConfig) llb.State {
4646
if c.Target == utils.TargetUnsloth {
4747
// installing unsloth and its dependencies
4848
// uv does not support installing xformers via unsloth pyproject
49-
state = state.Run(utils.Shf("pip install --upgrade pip uv && uv venv --system-site-packages && %[1]s && uv pip install packaging torch==2.3.0 ipython ninja packaging bitsandbytes setuptools==69.5.1 wheel psutil && uv pip install flash-attn --no-build-isolation && python -m pip install 'unsloth[cu121_ampere_torch230] @ git+https://github.com/unslothai/unsloth.git@%[2]s'", sourceVenv, unslothCommitOrTag)).Root()
49+
state = state.Run(utils.Shf("pip install --upgrade pip uv && uv venv --system-site-packages && %[1]s && uv pip install --upgrade --force-reinstall packaging torch==2.4.0 ipython ninja packaging bitsandbytes setuptools==69.5.1 wheel psutil transformers==4.44.2 numpy==2.0.2 && uv pip install flash-attn --no-build-isolation && python -m pip install 'unsloth[cu121_ampere_torch240] @ git+https://github.com/unslothai/unsloth.git@%[2]s'", sourceVenv, unslothCommitOrTag)).Root()
5050

5151
version := version.Version
5252
if version == "" {
@@ -66,7 +66,7 @@ func Aikit2LLB(c *config.FineTuneConfig) llb.State {
6666
state = state.Run(utils.Shf("%[1]s && %[2]s && python -m target_unsloth", nvidiaMknod, sourceVenv), llb.Security(llb.SecurityModeInsecure)).Root()
6767

6868
// copy gguf to scratch which will be the output
69-
const inputFile = "*.gguf"
69+
const inputFile = "model/*.gguf"
7070
copyOpts := []llb.CopyOption{}
7171
copyOpts = append(copyOpts, &llb.CopyInfo{AllowWildcard: true})
7272
outputFile := fmt.Sprintf("%s-%s.gguf", c.Output.Name, c.Output.Quantize)

pkg/finetune/target_unsloth.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22

3+
from unsloth import is_bfloat16_supported
4+
from transformers import TrainingArguments, DataCollatorForSeq2Seq
35
from unsloth import FastLanguageModel
46
import torch
57
from trl import SFTTrainer
@@ -71,13 +73,14 @@ def formatting_prompts_func(examples):
7173
else:
7274
dataset = load_dataset(source, split = "train")
7375

74-
dataset = dataset.map(formatting_prompts_func, batched = True)
76+
dataset = dataset.map(formatting_prompts_func, batched=True)
7577

7678
trainer = SFTTrainer(
7779
model=model,
7880
train_dataset=dataset,
7981
dataset_text_field="text",
8082
max_seq_length=max_seq_length,
83+
data_collator=DataCollatorForSeq2Seq(tokenizer=tokenizer),
8184
tokenizer=tokenizer,
8285
dataset_num_proc = 2,
8386
packing = cfg.get('packing'), # Can make training 5x faster for short sequences.
@@ -87,8 +90,8 @@ def formatting_prompts_func(examples):
8790
warmup_steps=cfg.get('warmupSteps'),
8891
max_steps=cfg.get('maxSteps'),
8992
learning_rate = cfg.get('learningRate'),
90-
fp16=not torch.cuda.is_bf16_supported(),
91-
bf16=torch.cuda.is_bf16_supported(),
93+
fp16=not is_bfloat16_supported(),
94+
bf16=is_bfloat16_supported(),
9295
logging_steps=cfg.get('loggingSteps'),
9396
optim=cfg.get('optimizer'),
9497
weight_decay = cfg.get('weightDecay'),

test/aikitfile-unsloth-custom.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ config: |
1818
- name: custom
1919
backend: llama
2020
parameters:
21-
top_k: 80
22-
temperature: 0.8
23-
top_p: 0.7
2421
model: model-q4_k_m.gguf
2522
context_size: 4096
26-
gpu_layers: 35
2723
f16: true
2824
mmap: true
2925
template:

test/aikitfile-unsloth.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#syntax=aikit:test
22
apiVersion: v1alpha1
3-
baseModel: unsloth/llama-3-8b-bnb-4bit
3+
baseModel: unsloth/Meta-Llama-3.1-8B
44
datasets:
55
- source: "yahma/alpaca-cleaned"
66
type: alpaca

0 commit comments

Comments
 (0)