An opinionated LLM training and fine-tuning library built on PyTorch.
Recipe-based architecture with a layered API: simple one-liners for beginners, full control for experts.
Documentation | Examples | API Reference
Features
- 3 recipes — fine-tune (full/LoRA/QLoRA), pre-train, align (DPO, GRPO, PPO, ORPO, SimPO, REINFORCE)
- 4 data formats — Alpaca, ShareGPT, chat template, raw text, plus preference pairs
- Automatic tokenization — text data is tokenized and collated automatically; pre-tokenized data passes through unchanged
- Sequence packing — pack short sequences to maximize GPU utilization
- Distributed training — DDP, FSDP, DeepSpeed via
xaytune launch - 4 logging backends — console, TensorBoard, W&B, MLflow
- LR finder — automatic learning rate range test
- Callbacks — event-driven hooks for early stopping, checkpointing, progress, custom logic
- Evaluation — built-in metrics + lm-eval-harness benchmarks
- Export — merge LoRA adapters, GGUF conversion, push to HuggingFace Hub
- Training Studio — Gradio web UI for configuring and launching runs
- 8 CLI commands — train, eval, export, compare, lr-find, list, studio, launch
- Fully typed — Pydantic configs, py.typed, mypy-clean
Install
pip install xaytune
Optional extras:
pip install xaytune[wandb] # Weights & Biases logging
pip install xaytune[mlflow] # MLflow logging
pip install xaytune[deepspeed] # DeepSpeed distributed training
pip install xaytune[eval] # lm-eval-harness benchmarks
pip install xaytune[studio] # Training Studio web UI
pip install xaytune[docs] # MkDocs documentation site
pip install xaytune[all] # Everything
Quickstart
Python API
import xaytune
# LoRA fine-tuning
xaytune.finetune(
model="meta-llama/Llama-3.1-8B",
dataset="data/train.jsonl",
method="lora",
format="alpaca",
num_epochs=3,
)
# Pre-training
xaytune.pretrain(
model="meta-llama/Llama-3.1-8B",
dataset="data/corpus.jsonl",
format="text",
)
# DPO alignment
xaytune.align(
model="output/sft-model",
dataset="data/preferences.jsonl",
method="dpo",
format="preference",
)
# Evaluation
results = xaytune.evaluate(
model="output/my-model",
dataset=[{"input_ids": [1, 2], "labels": [1, 2]}],
metrics=["loss", "perplexity"],
)
CLI
# Train
xaytune train --config configs/lora_finetune.yaml
xaytune train --config configs/lora_finetune.yaml --override model.name=mistralai/Mistral-7B-v0.3
xaytune train --config configs/lora_finetune.yaml --dry-run
# Evaluate
xaytune eval --model output/my-model --benchmarks mmlu,gsm8k --num-fewshot 5
xaytune eval --model output/my-model --dataset data/eval.jsonl --metrics loss,perplexity
# Compare models
xaytune compare model-a/ model-b/ --benchmarks mmlu,gsm8k
# Export
xaytune export merge --checkpoint output/lora-ckpt --output output/merged
xaytune export gguf --model output/merged --output model.gguf --quant Q4_K_M
xaytune export push --model output/merged --repo username/my-model
# LR finder
xaytune lr-find --config configs/lora_finetune.yaml
# Distributed training
xaytune launch --config configs/lora_finetune.yaml --nproc-per-node 4
# Training Studio
xaytune studio --port 7860
# List components
xaytune list recipes
xaytune list formats
xaytune list metrics
Config file
recipe: finetune
method: lora
model:
name: meta-llama/Llama-3.1-8B
data:
path: data/train.jsonl
format: alpaca
eval_split: 0.05
packing: true
max_seq_length: 2048
lora:
rank: 16
alpha: 32
trainer:
batch_size: 4
learning_rate: 2e-4
num_epochs: 3
mixed_precision: bf16
checkpoint_every_n_steps: 500
eval:
every_n_steps: 500
metrics: [loss, perplexity]
logging:
backends: [console, tensorboard]
Recipes
| Recipe | Methods | Use case |
|---|---|---|
finetune |
full, lora, qlora |
Supervised fine-tuning on instruction data |
pretrain |
full |
Pre-training or continued pre-training on raw text |
align |
dpo, grpo, ppo, orpo, simpo, reinforce |
Alignment with human preferences |
Extensibility
Register custom components with decorators:
from xaytune.data import register_format
from xaytune.eval import register_metric
from xaytune.recipes.align import register_reward
from xaytune.trainer import on
@register_format("my-format")
def parse_my_data(sample):
return {"text": f"Q: {sample['q']}\nA: {sample['a']}"}
@register_metric("domain-accuracy")
def domain_accuracy(predictions, references, **kwargs):
return sum(p == r for p, r in zip(predictions, references)) / len(predictions)
@register_reward("brevity")
def brevity_reward(prompt, response, *, max_len=100):
return 1.0 if len(response) <= max_len else 0.0
@on("step_end")
def log_memory(state):
print(f"Step {state.global_step}: loss={state.metrics.get('loss', 'N/A')}")
Export
from xaytune import export
# Merge LoRA adapters into base model
export.merge("output/lora-checkpoint", save_to="output/merged")
# Save with metadata
export.save(model, tokenizer, output_dir="output/final", metadata={"recipe": "finetune"})
# Push to Hugging Face Hub
export.push_to_hub("output/merged", repo="username/my-model")
# Convert to GGUF for local inference
from xaytune.export import to_gguf
to_gguf("output/merged", output="model.gguf", quantization="Q4_K_M")
Architecture
+-----------------------------------------+
| CLI / Config Engine | Layer 3 - Interface
+-----------------------------------------+
| pretrain | finetune | align (recipes) | Layer 2 - Recipes
+--------+--------+---------+--------+----+
| models | data | trainer | eval | exp| Layer 1 - Building Blocks
+--------+--------+---------+--------+----+
PyTorch / HuggingFace / DeepSpeed
License
Apache 2.0
Metadata
Release files for xaytune 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xaytune-0.6.0.tar.gz | 1.1 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xaytune-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.2 MB
Release files / xaytune-0.6.0.tar.gz
| Download URL | xaytune-0.6.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a898d355a6193bdc0c4b55ca1c814a3972858f8b9865e7ccecc2af7eabdff3d
|
|
BLAKE2b-256 checksum How to use checksums |
c21b44a7d89d0bc24da30345e74f389f5565fa959a1a6b4650f9b31df6b81632
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logRelease files / xaytune-0.6.0-py3-none-any.whl
| Download URL | xaytune-0.6.0-py3-none-any.whl |
|---|---|
| Size | 80.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c625bbc013d0b2c957f373fdd20a885f748603307b9bfce8383d607217118fef
|
|
BLAKE2b-256 checksum How to use checksums |
37ac9a07b129d03a7e66934cd8aea726031cac6721ffb40971f5442341c7dd7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logSecurity for xaytune 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xaytune-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.