Skip to main content

Troy

Fine-tune LLMs on your MacBook with one YAML file.

Troy is a command-line tool for fine-tuning and preference-tuning language models locally on Apple Silicon. No CUDA, no cloud, no training pipeline — write a config, run one command, and train on the machine you already own.

Built on MLX and mlx-lm, Apple's ML framework for Apple Silicon. Unified memory means a 36 GB MacBook fine-tunes models that need a workstation GPU anywhere else.

Requirements

  • Apple Silicon Mac (M1 or later)
  • macOS 14+
  • Python 3.10–3.12

Install

brew install avirajkhare00/troy/troy
# or: pipx install troy-cli

Quickstart

troy doctor            # check your Mac: chip, memory, MLX, what you can train
troy init              # create troy.yaml + sample data
troy train             # fine-tune (LoRA/QLoRA via MLX)
troy chat              # talk to the result
troy eval              # did it work? base-vs-tuned loss + samples
troy serve             # OpenAI-compatible API at localhost:8080/v1
troy export -f gguf    # ship it to llama.cpp / Ollama / LM Studio
troy push you/model    # upload to the Hugging Face Hub

The config is the interface

base: mlx-community/Qwen3-0.6B-4bit
task: sft            # or: dpo, orpo

data:
  train: ./data/train.jsonl   # alpaca, sharegpt, chat, completions, text — auto-detected
  val_split: 0.1

training:
  epochs: 3
  lr: 1e-5
  batch_size: auto   # sized from your Mac's unified memory
  lora:
    r: 8
    alpha: 16

output: ./output

Commands

Command Purpose
troy init Create a config from a template (chat, dpo, orpo)
troy doctor Hardware + dependency check, with model-size guidance
troy train LoRA fine-tuning: SFT, DPO, or ORPO — text, or vision with [vision] extra
troy chat Interactive REPL (or -p for one-shot) with your adapter
troy eval Base-vs-tuned val loss, perplexity, side-by-side samples
troy serve OpenAI-compatible API server for your model
troy export Fuse the adapter; export MLX or GGUF
troy push Upload adapter or fused model to the Hugging Face Hub
troy data inspect Dataset stats and format detection
troy data synth Synthesize a dataset with a local teacher model
troy mesh serve Coordinate a LAN mesh: iPhones and Macs generate the dataset for you
troy mesh join Join a mesh as a worker from any Mac

The mesh: your idle iPhones generate the dataset

troy data synth runs the teacher on one Mac. troy mesh farms the same job out to every Apple device on your network — the coordinator mints prompts and validates results (identical parsing to local synth), workers run the teacher:

troy mesh serve --from ./docs --n 500     # Mac: prints URL + token
troy mesh join http://mac:8765 --token …  # any other Mac
# iPhones: the TroyWorker app (examples/ios/TroyWorker)

Workers can drop out at any time — leased work requeues automatically, and duplicates are rejected centrally. The output is a normal train.jsonl: validate it, then troy train.

What Troy can train on your Mac

Unified memory Max model (4-bit QLoRA)
8 GB ~1.5B
16 GB ~4B
24 GB ~8B
36 GB ~14B
64 GB ~32B
128 GB ~70B

DPO without a second model

DPO normally keeps a frozen reference copy of the model in memory. Troy zeroes the LoRA scales to recover the reference model from the policy model itself — no second copy, which matters on unified memory.

Data formats

Auto-detected from the first record: Alpaca (instruction/output), ShareGPT (conversations), chat (messages), prompt/completion, plain text, and preference pairs (prompt/chosen/rejected) for DPO. Files: .jsonl, .json, .csv.

License

Apache-2.0

Metadata

Release files for troy-cli 0.5.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 troy-cli 0.5.0
File Size Uploaded Provenance Actions
troy_cli-0.5.0.tar.gz 36.0 kB With provenance Details for troy_cli-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for troy-cli 0.5.0
File Interpreter ABI Platform Actions
troy_cli-0.5.0-py3-none-any.whl Python 3 none any Details for troy_cli-0.5.0-py3-none-any.whl

Total release size: 75.9 kB

Release files / troy_cli-0.5.0.tar.gz

Download URL troy_cli-0.5.0.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dc4a66c1f40d2ae313ce81bf40b4e8d6315d5fe67df5f674bdac8a338450b32d
BLAKE2b-256 checksum
How to use checksums
454d79907927b31cfd6fd26babace5bb46731a73f30307754e5f922cd5e4e01b
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 Sep 13, 2026.

Transparency log

Release files / troy_cli-0.5.0-py3-none-any.whl

Download URL troy_cli-0.5.0-py3-none-any.whl
Size 39.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82918f2f418be1d24fac7c46258e9fefb88b1943ca2a97ffb0a6fb0bd98e0cfc
BLAKE2b-256 checksum
How to use checksums
546e99cede4da5eb31b6c79bed99bcfb0acb0738fd6d736dc58cf26193b763f5
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 Sep 13, 2026.

Transparency log

Security for troy-cli 0.5.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for troy_cli-0.5.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 Sep 13, 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