wheattoast11 commited on
Commit
1dc6e01
·
verified ·
1 Parent(s): d8a1596

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -0
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Unsloth Training Hub - LLM Fine-tuning & RL Platform
3
+ Supports: SFT, GRPO, GSPO, DPO, Dr-GRPO, DAPO, BNPO
4
+ """
5
+ import gradio as gr
6
+ import os
7
+ import json
8
+ from datetime import datetime
9
+
10
+ MODELS = [
11
+ "unsloth/Qwen2.5-7B-Instruct",
12
+ "unsloth/Qwen2.5-3B-Instruct",
13
+ "unsloth/Qwen2.5-14B-Instruct",
14
+ "unsloth/Meta-Llama-3.1-8B-Instruct",
15
+ "unsloth/DeepSeek-R1-Distill-Qwen-7B",
16
+ "unsloth/gemma-3-4b-it",
17
+ "unsloth/Phi-4-mini-instruct",
18
+ ]
19
+
20
+ RL_METHODS = ["grpo", "gspo", "dr_grpo", "dapo", "bnpo", "dpo"]
21
+ PRESETS = ["test_run", "small_run", "medium_run", "large_run", "grokking_run"]
22
+
23
+ def get_status():
24
+ s = {"cuda": False, "gpu": "None", "unsloth": False, "vllm": False}
25
+ try:
26
+ import torch
27
+ s["cuda"] = torch.cuda.is_available()
28
+ if s["cuda"]: s["gpu"] = torch.cuda.get_device_name(0)
29
+ except: pass
30
+ try:
31
+ import unsloth
32
+ s["unsloth"] = True
33
+ except: pass
34
+ try:
35
+ import vllm
36
+ s["vllm"] = True
37
+ except: pass
38
+ return s
39
+
40
+ def create_ui():
41
+ with gr.Blocks(title="Unsloth Training Hub", theme=gr.themes.Soft()) as demo:
42
+ gr.Markdown("# Unsloth Training Hub")
43
+ gr.Markdown("Comprehensive LLM Fine-tuning & RL Platform")
44
+
45
+ status = get_status()
46
+ gr.Markdown(f"**CUDA**: {status['cuda']} | **GPU**: {status['gpu']} | **Unsloth**: {status['unsloth']} | **vLLM**: {status['vllm']}")
47
+
48
+ with gr.Tabs():
49
+ with gr.Tab("Model & Mode"):
50
+ model = gr.Dropdown(choices=MODELS, value=MODELS[0], label="Model")
51
+ mode = gr.Radio(choices=["sft", "rl"], value="sft", label="Training Mode")
52
+ rl_method = gr.Dropdown(choices=RL_METHODS, value="grpo", label="RL Method", visible=False)
53
+ mode.change(lambda m: gr.Dropdown(visible=m=="rl"), mode, rl_method)
54
+
55
+ with gr.Tab("Training Config"):
56
+ preset = gr.Radio(choices=PRESETS, value="small_run", label="Preset")
57
+ lora_rank = gr.Dropdown(choices=[8,16,32,64,128], value=32, label="LoRA Rank")
58
+ lr = gr.Number(value=5e-6, label="Learning Rate")
59
+
60
+ with gr.Tab("Output"):
61
+ hub_id = gr.Textbox(value="wheattoast11/trained-model", label="Hub Model ID")
62
+ push = gr.Checkbox(value=True, label="Push to Hub")
63
+
64
+ output = gr.Markdown("Configure and click Generate")
65
+ btn = gr.Button("Generate Training Script", variant="primary")
66
+
67
+ def generate(model, mode, rl_method, preset, lora_rank, lr, hub_id, push):
68
+ return f"**Model**: {model}
69
+ **Mode**: {mode}
70
+ **Preset**: {preset}
71
+ **LoRA**: {lora_rank}
72
+ **LR**: {lr}"
73
+
74
+ btn.click(generate, [model, mode, rl_method, preset, lora_rank, lr, hub_id, push], output)
75
+ gr.Markdown("---
76
+ **Intuition Labs** | L40S ~$1.80/hr - PAUSE when not training!")
77
+ return demo
78
+
79
+ if __name__ == "__main__":
80
+ demo = create_ui()
81
+ demo.launch(server_name="0.0.0.0", server_port=7860)