|
1 | 1 | --- |
2 | 2 | layout: home |
3 | | -title: "Forgather: Democratizing Large Model Experimentation" |
4 | | -description: "Alpha-stage ML framework bringing distributed pipeline parallelism to consumer GPUs. Seeking collaborators to help develop the future of accessible AI training." |
| 3 | +title: "Forgather: Configuration-Driven ML Framework for Consumer-GPU Training" |
| 4 | +description: "Forgather is a PyTorch ML framework with template-inheritance configs, framework-portable model export, pipeline parallelism for bandwidth-limited setups, and full-parameter 7B finetuning on a single 24 GB GPU." |
5 | 5 | --- |
6 | 6 |
|
7 | | -# Democratizing Large Model Experimentation |
| 7 | +# Forgather |
8 | 8 |
|
9 | | -[**Forgather**](https://github.com/jdinalt/forgather) is an alpha-stage ML framework that aims to make large model training accessible to hobbyists and researchers with consumer hardware. |
| 9 | +[**Forgather**](https://github.com/jdinalt/forgather) is a configuration-driven ML framework built on template inheritance and code generation. It targets the gap between "research script that grows ten near-copies of itself" and "production framework you can't customise without forking." |
10 | 10 |
|
11 | | -## The Vision |
| 11 | +The framework is open source, runs on PyTorch, and has been in active development since 2023. |
12 | 12 |
|
13 | | -### **Pipeline Parallelism for Consumer GPUs** |
14 | | -Enable training of models larger than single GPU memory by distributing them across multiple consumer-grade cards using [Torch Distributed Pipeline Parallelism](https://docs.pytorch.org/docs/main/distributed.pipelining.html) Our goal is to make 7B+ parameter full model training accessible without enterprise hardware. |
| 13 | +## What's actually in the box |
15 | 14 |
|
16 | | -### **End Configuration Duplication** |
17 | | -Eliminate the copy-paste cycle of ML experiments through a powerful template inheritance system. Specify only what changes between experiments, not entire configurations. |
| 15 | +### Template-inheritance configs, no copy-paste |
18 | 16 |
|
19 | | -### **Framework-Independent Models** |
20 | | -Generate standalone Python code that works without dependencies on Forgather itself. Your trained models remain portable and deployable anywhere. |
| 17 | +A Forgather project config extends a parent. Both are plain YAML with Jinja2 preprocessing, and *every knob* is an explicitly overridable block. To try a longer context window or a different optimizer, you write the override; the rest is inherited. Custom YAML tags (`!partial`, `!factory`, `!singleton`) let you swap in any Python class or function without touching Python source. |
21 | 18 |
|
22 | | -## Current Status: Alpha |
| 19 | +### Models that don't depend on Forgather |
23 | 20 |
|
24 | | -Forgather is in active development with core functionality implemented: |
| 21 | +Each training run writes the equivalent PyTorch source into `output_models/`. The generated code has no Forgather dependency: |
25 | 22 |
|
26 | | -- Template inheritance system working |
27 | | -- Pipeline parallelism implemented |
28 | | -- Code generation pipeline functional |
29 | | -- Multi-GPU distributed training |
30 | | -- Performance optimization ongoing |
31 | | -- Documentation and examples expanding |
| 23 | +```python |
| 24 | +from transformers import AutoModelForCausalLM |
| 25 | +model = AutoModelForCausalLM.from_pretrained( |
| 26 | + "output_models/my_run", |
| 27 | + trust_remote_code=True, |
| 28 | +) |
| 29 | +``` |
32 | 30 |
|
33 | | -## Seeking Collaborators |
| 31 | +`forgather convert --reverse` will additionally emit a canonical Hugging Face checkpoint (Llama / Mistral / Qwen3 / Gemma-3) that loads without `trust_remote_code`. Train in Forgather, deploy anywhere. |
34 | 32 |
|
35 | | -We're looking for contributors who share our vision of democratizing AI: |
| 33 | +### Pipeline parallelism for bandwidth-limited setups |
36 | 34 |
|
37 | | -### **Researchers & Experimenters** |
38 | | -Help test pipeline parallelism with different model architectures and share your findings. |
| 35 | +The pipeline trainer (GPipe, 1F1B, Interleaved-1F1B, zero-bubble schedules) needs dramatically less cross-device communication than DDP or FSDP. Concrete results: |
39 | 36 |
|
40 | | -### **ML Engineers** |
41 | | -Contribute to performance optimization, memory efficiency, and distributed training improvements. |
| 37 | +- **7B-parameter model trained across two machines connected by 1 Gbit Ethernet**, with bandwidth to spare. |
| 38 | +- The same design avoids PCIe stalls that bottleneck FSDP on consumer GPUs without NVLink. |
| 39 | +- DDP (with optional Post-Local-SGD), FSDP-2, and DiLoCo (Distributed Low-Communication Training, [arXiv:2311.08105](https://arxiv.org/abs/2311.08105)) are also first-class. |
42 | 40 |
|
43 | | -### **Documentation & Examples** |
44 | | -Help create tutorials, guides, and example configurations for the community. |
| 41 | +### Full-parameter 7B finetuning on a single 24 GB GPU |
45 | 42 |
|
46 | | -### **Core Development** |
47 | | -Contribute to framework architecture, code generation, and template systems. |
| 43 | +Not LoRA — full parameter, up to **~53 K tokens of context** on a single RTX 4090. Achieved by combining gradient checkpointing, CPU activation offload, fused optimizer step, fused linear + cross-entropy loss (Liger / Apple CCE / `torch.compile`), and packed sequences with Flex Attention. |
48 | 44 |
|
49 | | -## What We're Building |
| 45 | +A documented 9-way ablation of these techniques on a 1.6 B model showed an **81 % peak-memory reduction at ~2.7× throughput** versus the naive baseline. ([peak-memory experiment](https://github.com/jdinalt/forgather/tree/main/examples/tiny_experiments/peak_memory)) |
50 | 46 |
|
51 | | -- **Accessible Training**: 7B+ models on consumer setups |
52 | | -- **Template-Driven**: Systematic experimentation without configuration chaos |
53 | | -- **Pipeline Parallelism**: Much faster than FSDP on hardware lacking a fast interconnect |
54 | | -- **Framework Freedom**: Generated models work independently |
55 | | -- **Research Focus**: Built for exploration and comparison |
| 47 | +### Adafactor + AdamW with bf16 stochastic rounding |
56 | 48 |
|
57 | | -## Early Results |
| 49 | +Forgather ships a fused Triton Adafactor that combines factored second-moment estimation with per-parameter stochastic rounding for bf16 weight updates, in a single kernel. To our knowledge this is the only Adafactor+SR implementation available, and it runs faster than every reference Adafactor we've benchmarked. SR is critical for *pure*-bf16 training (no fp32 master weights) — without it, sub-precision updates round systematically to zero and weight norms drift. |
58 | 50 |
|
59 | | -Initial testing on 4x RTX 4090 setup shows promising results for 7B parameter model training with various pipeline schedules. We're particularly excited about zero-bubble pipeline performance, though optimization work continues. |
| 51 | +### Web UI with GPU-aware job queue |
60 | 52 |
|
61 | | -[Explore the Code →](https://github.com/jdinalt/forgather){: .btn .btn-primary} |
62 | | -[Join Discussions →](https://github.com/jdinalt/forgather/discussions){: .btn .btn-outline} |
63 | | -[Report Issues →](https://github.com/jdinalt/forgather/issues){: .btn .btn-outline} |
| 53 | +A single-user browser frontend over the same APIs as the CLI: project / file browsing, ▶ Run buttons that drop training jobs into a priority + GPU-policy queue, live job cards with TTY and training-stat pills, per-card process attribution, an in-browser editor with Forgather YAML+Jinja2 syntax highlighting, and a chat client wired to served inference jobs. |
64 | 54 |
|
65 | | ---- |
| 55 | +### Live job control across distributed workers |
| 56 | + |
| 57 | +```bash |
| 58 | +forgather control list |
| 59 | +forgather control save JOB_ID # save checkpoint on demand |
| 60 | +forgather control save-stop JOB_ID # save and gracefully stop |
| 61 | +forgather control abort JOB_ID # kill a failed experiment without saving |
| 62 | +``` |
| 63 | + |
| 64 | +Distributed-safe — commands sent to any rank are coordinated across all DDP / FSDP-2 / pipeline workers. |
| 65 | + |
| 66 | +### Reproducibility built in |
| 67 | + |
| 68 | +Every run snapshots its full config *and* the generated model source. Resume restores optimizer state, LR scheduler, dataset position (stateful resume on C4-scale corpora is fast), RNG, and Tensorboard logs. Distributed checkpoints are written as standard HF Safetensors shards readable by `transformers`, vLLM, and llama.cpp conversion tools. |
| 69 | + |
| 70 | +## Worked examples worth reading |
| 71 | + |
| 72 | +These aren't toy demos — each has a README with reproducible commands and headline results: |
| 73 | + |
| 74 | +- **[Long-context Lovecraft finetune + RoPE comparison](https://github.com/jdinalt/forgather/tree/main/examples/tutorials/hp_lovecraft_project)** — Mistral-7B / Llama-2-7B on the complete works of H. P. Lovecraft on a single 24 GB GPU, 53 K context. Companion document compares plain RoPE, YaRN, Llama-3 NTK-by-parts, and bumped `rope_theta`. Headline finding: **bumping `rope_theta` to 500 000 is the single biggest intervention for context extrapolation**. |
| 75 | + |
| 76 | +- **[Optimizer comparison on a 30 M Llama](https://github.com/jdinalt/forgather/tree/main/examples/tiny_experiments/optimizers)** — empirical comparison of ten optimizers (Muon, Apollo, AdamW, Adafactor, SinkGD, SGD, …) on the SmolLM corpus. Headline: **Muon wins at small batch** (eval loss 2.6778 vs AdamW 2.7392), with `beta2` scaling becoming critical at large batch. |
| 77 | + |
| 78 | +- **[Peak-memory ablation on a 1.6 B model](https://github.com/jdinalt/forgather/tree/main/examples/tiny_experiments/peak_memory)** — 9-way systematic ablation of memory-optimisation techniques. **81 % peak-memory reduction at ~2.7× throughput.** Pareto-frontier plots included. |
| 79 | + |
| 80 | +- **[Pretraining at 162 M from scratch](https://github.com/jdinalt/forgather/tree/main/examples/pretrain/small-llm)** — Llama trained on the SmolLM corpus, ten production-ready configs covering 1× and 10× Chinchilla budgets, AdamW / Adafactor / bf16 variants, plus a "Canon-A" custom architecture variant. |
| 81 | + |
| 82 | +- **[Multi-GPU 7B finetuning](https://github.com/jdinalt/forgather/tree/main/examples/finetune/samantha)** — Mistral-7B and Llama-3.2-1B on the Samantha conversational dataset across every trainer backend in the library. ~8.9 K tokens/sec on 4× RTX 4090 pipeline parallel. |
| 83 | + |
| 84 | +## Getting started |
| 85 | + |
| 86 | +```bash |
| 87 | +git clone https://github.com/jdinalt/forgather.git |
| 88 | +cd forgather |
| 89 | +docker/build.sh |
| 90 | +docker/run.sh |
| 91 | + |
| 92 | +# Inside the container: |
| 93 | +forgather server # web UI |
| 94 | +# or |
| 95 | +cd examples/tutorials/tiny_llama |
| 96 | +forgather -t v2.yaml train # 5M-param Llama in ~10 minutes |
| 97 | +``` |
| 98 | + |
| 99 | +The [Tiny Llama tutorial](https://github.com/jdinalt/forgather/tree/main/examples/tutorials/tiny_llama) walks through the full train → monitor → control → eval → inference → export flow. Full documentation lives at [forgather.readthedocs.io](https://forgather.readthedocs.io/en/latest/). |
| 100 | + |
| 101 | +## Project status |
| 102 | + |
| 103 | +Active development since 2023. Used by the author for ongoing ML research; APIs are stable enough that the documentation lags behind the code rather than vice versa. Forgather is solo-maintained — feedback, issues, and pull requests are welcome. |
66 | 104 |
|
67 | | -*Alpha software seeking alpha testers. Help us build the future of accessible AI training.* |
| 105 | +[GitHub repository →](https://github.com/jdinalt/forgather){: .btn .btn-primary} |
| 106 | +[Documentation →](https://forgather.readthedocs.io/en/latest/){: .btn .btn-outline} |
| 107 | +[Discussions →](https://github.com/jdinalt/forgather/discussions){: .btn .btn-outline} |
0 commit comments