Files
trainer/examples/yaml/hanzo-finetune-qlora.yaml
0b97a47048 feat(runtimes): hanzo-ft-{lora,qlora,full} — env-driven HF fine-tuning runtimes (#2)
Adds one transformers + PEFT + TRL ClusterTrainingRuntime per method that
fine-tunes ANY HuggingFace causal LM. The base model + dataset come from the
TrainJob's model/dataset initializers (hf:// or s3://, secretRef for private/gated
repos); every hyperparameter is read from the trainer container env that the Hanzo
Cloud broker sets. Adapters are merged into the base on completion, so one serving
path (KServe HuggingFace runtime) works for lora/qlora/full alike; output is
written to OUTPUT_DIR (the org's S3 Space when s3://).

- manifests/base/runtimes/hanzo_finetune.yaml  3 ClusterTrainingRuntimes (+kustomization)
- cmd/trainers/hanzo/finetune.py               env-driven entrypoint (LoRA/QLoRA/full)
- cmd/trainers/hanzo/finetune_test.py          pytest for the pure config/format helpers
- cmd/trainers/hanzo/{Dockerfile,requirements.txt,README.md}
- examples/yaml/hanzo-finetune-qlora.yaml      example TrainJob (the broker's output)

kustomize build clean · ruff clean · 14 pytest pass. Image built in CI
(ghcr.io/hanzoai/finetune-runtime), not locally.

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-29 23:53:55 -07:00

60 lines
1.8 KiB
YAML

# Example TrainJob produced by the Hanzo Cloud fine-tuning broker
# (hanzoai/ai `/v1/finetune/jobs`). It QLoRA-fine-tunes a HuggingFace base model on
# a HuggingFace dataset using the `hanzo-ft-qlora` ClusterTrainingRuntime. The
# broker fills the same fields from the console's new-job panel:
# - initializer.model / initializer.dataset .storageUri → the picked HF repos
# (a secretRef is added for private/gated repos, from the in-namespace hf-token
# Secret the broker provisions)
# - trainer.resourcesPerNode → the chosen GPU count
# - trainer.env → the recommended (or custom) hyperparameters + OUTPUT_DIR
# (the org's S3 Space, so checkpoints land in the tenant's bucket)
apiVersion: trainer.kubeflow.org/v1alpha1
kind: TrainJob
metadata:
name: llama-3-1-8b-instruct-demo
namespace: ft-acme
spec:
runtimeRef:
name: hanzo-ft-qlora
apiGroup: trainer.kubeflow.org
kind: ClusterTrainingRuntime
initializer:
model:
storageUri: hf://meta-llama/Llama-3.1-8B-Instruct
secretRef:
name: hf-token
dataset:
storageUri: hf://tatsu-lab/alpaca
secretRef:
name: hf-token
trainer:
numNodes: 1
resourcesPerNode:
limits:
nvidia.com/gpu: "1"
env:
- name: METHOD
value: qlora
- name: TASK
value: instruct
- name: EPOCHS
value: "3"
- name: LEARNING_RATE
value: "0.0002"
- name: BATCH_SIZE
value: "2"
- name: GRAD_ACCUM
value: "8"
- name: MAX_SEQ_LEN
value: "2048"
- name: LORA_RANK
value: "16"
- name: LORA_ALPHA
value: "32"
- name: QUANT_4BIT
value: "true"
- name: GRADIENT_CHECKPOINTING
value: "true"
- name: OUTPUT_DIR
value: s3://hanzo-finetunes/acme/llama-3-1-8b-instruct-demo/