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 or Kaggle 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, Modal, and Kaggle 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/Kaggle with the job
  • W&B — enable and configure logging entirely from YAML
  • Modal — launch the same YAML on remote GPUs with volume-backed outputs
  • Kaggle — run inline in a Kaggle kernel, or generate / push a GPU notebook
  • CLI + Python API — trloom run config.yaml or FineTuneJob.from_yaml(...)

Installation

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

pip install trloom

# Optional extras
pip install "trloom[wandb]"
pip install "trloom[modal]"
pip install "trloom[kaggle]"
pip install "trloom[bitsandbytes]"
pip install "trloom[all]"      # wandb + modal + kaggle + 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[kaggle] @ 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

Metadata

Release files for trloom 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trloom 0.2.0
File Size Uploaded Provenance Actions
trloom-0.2.0.tar.gz 838.6 kB With provenance Details for trloom-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trloom 0.2.0
File Interpreter ABI Platform Actions
trloom-0.2.0-py3-none-any.whl Python 3 none any Details for trloom-0.2.0-py3-none-any.whl

Total release size: 882.0 kB

Release files / trloom-0.2.0.tar.gz

Download URL trloom-0.2.0.tar.gz
Size 838.6 kB
Tags Source
SHA-256 checksum
How to use checksums
688461bdf2ec9426289139b0880eb0b0c00b8c552484b3dccbdc35afc9ea1b18
BLAKE2b-256 checksum
How to use checksums
3d168f68c77bbf304136ee40bb476f7e4f4490177a256eeb2aa22576ec547b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Release files / trloom-0.2.0-py3-none-any.whl

Download URL trloom-0.2.0-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ba949d83ad3341ebd43e0f831d089683307263d3e72ffb8efbaf656159dd81c
BLAKE2b-256 checksum
How to use checksums
7d51caf16a6d7bdb752fc1325e7d1064a981ad4f9a4c0519fc4f883409f8fc63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Security for trloom 0.2.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.

Select from 2 files

Attestation for trloom-0.2.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 Oct 18, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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