Skip to main content

TRLoom

TRLoom

PyPI Python CI Docs GitHub stars License

TRLoom weaves a single YAML config into an end-to-end Hugging Face TRL fine-tuning job.

Configure the model, dataset, trainer, Weights & Biases, and optional Modal GPU execution — then run one command.

Docs: https://saqlain2204.github.io/trloom/

Features

  • TRL-native — discovers trainers/configs from your installed TRL version (SFT, DPO, GRPO, KTO, Reward, RLOO, and experimental methods)
  • YAML-first — model, dataset, training args, W&B, and Modal all live in one file
  • Datasets — Hugging Face Hub, local files (json/jsonl/csv/parquet/…), saved datasets directories, and mixtures
  • Formatting — Jinja2 prompt templates, YAML-referenced map_fn / formatting_func, bundled to Modal with the job
  • W&B — enable and configure logging entirely from YAML
  • Modal — launch the same YAML on remote GPUs with volume-backed outputs
  • CLI + Python APItrloom run config.yaml or FineTuneJob.from_yaml(...)

Installation

Requires Python 3.10+ and a working TRL / PyTorch environment for actual training.

From PyPI (recommended)

pip install trloom

# Optional extras
pip install "trloom[wandb]"
pip install "trloom[modal]"
pip install "trloom[bitsandbytes]"
pip install "trloom[all]"      # wandb + modal + bitsandbytes
pip install "trloom[dev]"      # pytest, ruff
pip install "trloom[docs]"     # mkdocs

From Git

pip install git+https://github.com/saqlain2204/trloom.git

# With extras
pip install "trloom[modal] @ git+https://github.com/saqlain2204/trloom.git"
pip install "trloom[all] @ git+https://github.com/saqlain2204/trloom.git"

From source (editable)

Clone the repo, then either bootstrap or install manually:

git clone https://github.com/saqlain2204/trloom.git
cd trloom

# One-command bootstrap (creates .venv if needed)
python scripts/bootstrap.py
# Optional: --modal, --wandb, --dev, --all, --skip-modal-setup

# Or editable install
pip install -e .
pip install -e ".[wandb]"
pip install -e ".[modal]"
pip install -e ".[docs]"
pip install -e ".[all]"
pip install -e ".[dev]"

Activate the venv after bootstrap:

# macOS / Linux
source .venv/bin/activate

# Windows PowerShell
.venv\Scripts\Activate.ps1

Quickstart

1. Write a config

# sft.yaml
method: sft

model:
  model_name_or_path: Qwen/Qwen2.5-0.5B-Instruct
  use_peft: true
  lora_r: 16
  lora_alpha: 32

dataset:
  path: trl-lib/Capybara
  train_split: train

training:
  output_dir: ./outputs/sft
  learning_rate: 2.0e-4
  num_train_epochs: 1
  per_device_train_batch_size: 2
  gradient_accumulation_steps: 4
  report_to: none

wandb:
  enabled: false

modal:
  enabled: false

2. Run

trloom validate sft.yaml
trloom run sft.yaml

Or from Python:

from trloom import FineTuneJob, run_from_yaml

# One-liner
run_from_yaml("sft.yaml")

# Or step through the API
job = FineTuneJob.from_yaml("sft.yaml")
job.run()

Documentation

Full guides and API reference:

pip install -e ".[docs]"
mkdocs serve

Coverage includes configuration reference, datasets, W&B, Modal, CLI, and the Python API.

Configuration reference

Section Purpose
method TRL method key: sft, dpo, grpo, kto, reward, rloo, …
model Model id + PEFT/quantization (aligned with TRL ModelConfig)
dataset Hub repo, local path, or datasets: mixture
training Forwarded to the TRL *Config class (SFTConfig, DPOConfig, …)
wandb Weights & Biases project/entity/tags/mode
modal Remote GPU execution on Modal
reward_funcs Names or import paths for GRPO/RLOO-style rewards
trainer_kwargs Extra kwargs passed to the Trainer constructor
push_to_hub / hub_model_id Optional Hub upload after training

List methods available in your environment:

trloom methods

Dataset examples

Hub

dataset:
  path: trl-lib/Capybara
  train_split: train

Local JSONL

dataset:
  path: ./data/train.jsonl
  train_split: train

Mixture

dataset:
  train_split: train
  datasets:
    - path: stanfordnlp/imdb
      split: train
      weight: 0.5
    - path: ./data/extra.jsonl
      weight: 0.5

Weights & Biases

training:
  report_to: wandb   # optional; set automatically when wandb.enabled is true

wandb:
  enabled: true
  project: my-project
  entity: my-team
  run_name: qwen-sft-01
  tags: [sft, lora]
  mode: online       # online | offline | disabled

Modal

  1. Install and authenticate: pip install 'trloom[modal]' && modal setup
  2. Create secrets named in the config (default: huggingface, wandb)
  3. Set modal.enabled: true (or pass --modal)
trloom run examples/grpo_modal.yaml --modal
# or generate a standalone script
trloom modal-script examples/grpo_modal.yaml -o run_modal.py
modal run run_modal.py

Python API

from trloom import FineTuneJob, available_methods, load_config

print(available_methods())

config = load_config("sft.yaml")
job = FineTuneJob(config)
trainer = job.build()   # construct TRL trainer
job.run()               # train + save (+ optional Hub push)
Method Description
FineTuneJob.from_yaml(path) Load YAML into a job
FineTuneJob.from_dict(data) Load an in-memory config
job.build() Construct the TRL trainer
job.train() / job.run() Run training end-to-end
run_from_yaml(path) Load + run (honors modal.enabled)
load_config(path) Validate and return FineTuneConfig
available_methods() List TRL methods for this install

Examples

See the examples/ directory:

  • modal_smoke/complete end-to-end Modal walkthrough (tiny GPT-2, 3 steps, T4)
  • sft_hub.yaml — SFT from the Hub
  • sft_local.yaml — SFT from local JSONL
  • dpo_wandb.yaml — DPO with W&B
  • grpo_modal.yaml — GRPO on Modal

Development

pip install -e ".[dev]"
pytest

# Documentation
pip install -e ".[docs]"
mkdocs serve
mkdocs build --strict

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trloom-0.1.3.tar.gz (829.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trloom-0.1.3-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file trloom-0.1.3.tar.gz.

File metadata

  • Download URL: trloom-0.1.3.tar.gz
  • Upload date:
  • Size: 829.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trloom-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dd218fc9b444ae714fe722038d5c0a9f20fa4e2ad974cc2dd159ce431b8f2f75
MD5 bc5f963a241f61f2d5b0f343bedd01c6
BLAKE2b-256 fc5488471829633527e03b203832669ff64fb2ac76eaecaccb1c16c7e22b4127

See more details on using hashes here.

Provenance

The following attestation bundles were made for trloom-0.1.3.tar.gz:

Publisher: release.yml on saqlain2204/trloom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trloom-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: trloom-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trloom-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dc1ac9f1efd250bbc680cb9a8439c542da300415370f1a5086833d30014335c6
MD5 a6e25e14b4e0e91b43913f9135bdb60c
BLAKE2b-256 8fb673d82845335635b46cd5a3d090fc8794f991aa8044e7519a21e98e8e7e93

See more details on using hashes here.

Provenance

The following attestation bundles were made for trloom-0.1.3-py3-none-any.whl:

Publisher: release.yml on saqlain2204/trloom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page