chore: add .gitignore
This commit is contained in:
6597
runpod/data/pmsi_eval.jsonl
Normal file
6597
runpod/data/pmsi_eval.jsonl
Normal file
File diff suppressed because it is too large
Load Diff
59379
runpod/data/pmsi_train.jsonl
Normal file
59379
runpod/data/pmsi_train.jsonl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,17 +2,15 @@
|
||||
"""
|
||||
Fine-tuning QLoRA de gemma3:12b sur RunPod (A100 40/80GB).
|
||||
|
||||
Différences vs local (RTX 5070 12GB) :
|
||||
- max_seq_length=2048 (vs 512) — prompts pipeline non tronqués
|
||||
- batch_size=4 (vs 1) — convergence plus stable
|
||||
- 3 epochs (vs 1) — meilleure mémorisation
|
||||
- Dataset complet sans sous-échantillonnage
|
||||
Dataset V2 : 15.9K train, 53% raisonnement structuré (vs 95% lookups V1).
|
||||
Sources : referentiels, pipeline, cocoa, ccam, cim10, reasoning,
|
||||
negative, discrimination, fascicule_reasoning, guide_metho.
|
||||
|
||||
Usage sur RunPod :
|
||||
1. Créer un pod avec template PyTorch 2.4+ / CUDA 12.x
|
||||
2. rsync -avz runpod/ runpod_host:/workspace/t2a-finetune/
|
||||
3. bash /workspace/t2a-finetune/setup.sh
|
||||
4. python /workspace/t2a-finetune/train_runpod.py [--epochs 3] [--export-gguf]
|
||||
1. Créer un pod A100 80GB (template PyTorch 2.4+ / CUDA 12.x)
|
||||
2. Uploader les fichiers (train_runpod.py, setup.sh, data/)
|
||||
3. bash setup.sh
|
||||
4. python train_runpod.py [--epochs 3] [--export-gguf]
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@@ -149,7 +147,7 @@ def train(model, tokenizer, train_ds, eval_ds, args):
|
||||
callbacks = []
|
||||
try:
|
||||
import wandb
|
||||
wandb.init(project="pmsi-coder", name=f"runpod-{args.epochs}ep-seq{args.max_seq_length}")
|
||||
wandb.init(project="pmsi-coder", name=f"v2-runpod-{args.epochs}ep-seq{args.max_seq_length}")
|
||||
report = "wandb"
|
||||
print(" Tracking : wandb")
|
||||
except ImportError:
|
||||
@@ -205,34 +203,61 @@ def train(model, tokenizer, train_ds, eval_ds, args):
|
||||
return trainer, final_dir
|
||||
|
||||
|
||||
def export_merged_hf(model, tokenizer):
|
||||
"""Sauvegarder le modèle mergé en 16-bit (HF format) pour conversion GGUF ultérieure."""
|
||||
print(f"\nExport modèle mergé (16-bit HF)...")
|
||||
|
||||
merged_dir = OUTPUT / "pmsi-merged-hf"
|
||||
merged_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
model.save_pretrained_merged(
|
||||
str(merged_dir),
|
||||
tokenizer,
|
||||
save_method="merged_16bit",
|
||||
)
|
||||
|
||||
size_gb = sum(f.stat().st_size for f in merged_dir.glob("*.safetensors")) / 1024**3
|
||||
print(f" Modèle mergé : {merged_dir} ({size_gb:.1f} Go)")
|
||||
print(f"\n Pour convertir en GGUF :")
|
||||
print(f" python llama.cpp/convert_hf_to_gguf.py {merged_dir} --outfile pmsi-v2-q8.gguf --outtype q8_0")
|
||||
print(f" llama-quantize pmsi-v2-q8.gguf pmsi-v2-q4km.gguf Q4_K_M")
|
||||
return merged_dir
|
||||
|
||||
|
||||
def export_gguf(model, tokenizer, final_dir, quantization="q4_k_m"):
|
||||
"""Export GGUF via Unsloth (peut échouer — fallback sur export_merged_hf)."""
|
||||
print(f"\nExport GGUF ({quantization})...")
|
||||
|
||||
gguf_dir = OUTPUT / "pmsi-gguf"
|
||||
gguf_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
model.save_pretrained_gguf(
|
||||
str(gguf_dir),
|
||||
tokenizer,
|
||||
quantization_method=quantization,
|
||||
)
|
||||
try:
|
||||
model.save_pretrained_gguf(
|
||||
str(gguf_dir),
|
||||
tokenizer,
|
||||
quantization_method=quantization,
|
||||
)
|
||||
|
||||
gguf_files = list(gguf_dir.glob("*.gguf"))
|
||||
if gguf_files:
|
||||
gguf_path = gguf_files[0]
|
||||
size_gb = gguf_path.stat().st_size / 1024**3
|
||||
print(f" GGUF : {gguf_path.name} ({size_gb:.1f} Go)")
|
||||
gguf_files = list(gguf_dir.glob("*.gguf"))
|
||||
if gguf_files:
|
||||
gguf_path = gguf_files[0]
|
||||
size_gb = gguf_path.stat().st_size / 1024**3
|
||||
print(f" GGUF : {gguf_path.name} ({size_gb:.1f} Go)")
|
||||
|
||||
modelfile_path = gguf_dir / "Modelfile"
|
||||
with open(modelfile_path, "w") as f:
|
||||
f.write(f"FROM {gguf_path.name}\n\n")
|
||||
f.write("PARAMETER temperature 0.3\n")
|
||||
f.write("PARAMETER top_p 0.9\n")
|
||||
f.write("PARAMETER num_ctx 8192\n")
|
||||
modelfile_path = gguf_dir / "Modelfile"
|
||||
with open(modelfile_path, "w") as f:
|
||||
f.write(f"FROM {gguf_path.name}\n\n")
|
||||
f.write("PARAMETER temperature 0.3\n")
|
||||
f.write("PARAMETER top_p 0.9\n")
|
||||
f.write("PARAMETER num_ctx 8192\n")
|
||||
f.write('PARAMETER stop "<end_of_turn>"\n')
|
||||
f.write('PARAMETER stop "<eos>"\n')
|
||||
|
||||
print(f" Modelfile créé")
|
||||
print(f"\n Pour récupérer : scp runpod:{gguf_path} .")
|
||||
print(f" Puis : ollama create pmsi-coder -f Modelfile")
|
||||
print(f" Modelfile créé")
|
||||
except Exception as e:
|
||||
print(f" GGUF export échoué : {e}")
|
||||
print(f" Fallback : export HF mergé...")
|
||||
export_merged_hf(model, tokenizer)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user