Guac is an experimental research codebase for training and experimenting with heterogeneous transformer architectures, featuring mixed layer types and a custom prompt formatting system designed for complex sequence-to-sequence tasks. It's active research code, not a polished library — expect rough edges.
- Python 3.8+
- PyTorch (CUDA-capable GPU recommended)
- HuggingFace
transformers
git clone github.com/stanier/guac
cd guac
make install
# (copies site_config.example.yml -> site_config.yml if it doesn't exist yet)Note:
make installrunspip install -r requirements.txt, but this repo does not currently ship arequirements.txt. Create one (or installtorch/transformers/pyyaml/sentencepiece/jinja2manually) before runningmake install.
Then edit site_config.yml with your paths and dataset preferences — this file is git-ignored so each environment can have its own local configuration.
# Recommended: three-stage pipeline (pre-training -> mid-training -> post-training)
make pipeline # Full pipeline, default guac-3b config
make pipeline CONFIG=guac-590m # With a specific model size
make pipeline TASK=arithmetic # With a mid-training task specialization
make pipeline DEBUG=true # Smaller datasets for a fast debug run
# Individual stages
make pretrain
make midtrain
make posttrain
# Legacy shortcuts (still wired to the pipeline scripts)
make debug # guac-3b config, debug mode
make stable # guac-590m configGuac introduces Mixed Layer Architectures - models that use different computational patterns within the same network. For example, the smaller presets in model_configs.yaml repeat a conv, conv, mamba2, conv block, while larger presets add mixture-of-experts and mixture-of-heads layers on top.
Defined in scripts/training/core/custom_architectures.py:
full_attention: Standard multi-head attentionflash_attention: Memory-efficient, tiling-based attentionconv: 1D convolution for local pattern recognitionmamba2: Selective state space modelingbased: Linear attention via feature mapsmlp_only: Feed-forward only (no sequence mixing)moh_attention: Mixture-of-Heads attentionshared_expert_moe: Mixture-of-Experts with shared experts
- Combine different computational patterns in a single model via
MixedLayerConfig - Enables studying different inductive biases within one model
- Jinja2-based templating (
scripts/training/core/prompt_templates.py) - Custom tokens for multi-sequence boundaries and inference control
- Scalable model size progression:
guac-106m(512 hidden, 4 layers) up throughguac-48b(8192 hidden, 64 layers) — see the full table below - Environment-agnostic
site_config.yml, resolved viaPathManager
- Gradient checkpointing for memory efficiency
- Dataset caching for faster iteration
- Live inference during training
- Streaming dataset support
- Architecture Guide: Detailed architecture explanations
- Training Guide: Training workflows and best practices
- API Reference: Code API documentation
- Contributing: How to contribute to Guac
Guac is built to explore:
- Heterogeneous Architectures: How do different layer types interact?
- Computational Complexity: Optimal ordering of computation patterns
- Sequence-to-Sequence Learning: Multi-modal and multi-sequence tasks
- Efficient Attention: Comparing attention mechanisms within one model
- Mathematical Reasoning: Arithmetic and symbolic computation tasks
Guac provides pre-configured model sizes in model_configs.yaml (all use the mixed_layer architecture unless noted):
| Config | Hidden Size | Layers | Attention Heads |
|---|---|---|---|
guac-106m |
512 | 4 | 4 |
guac-280m |
1024 | 8 | 8 |
guac-590m |
1536 | 12 | 12 |
guac-1.1b |
2048 | 16 | 16 |
guac-1.9b |
2560 | 20 | 20 |
guac-3b |
3072 | 24 | 24 |
guac-4.5b |
3584 | 28 | 28 |
guac-6.5b |
4096 | 32 | 32 |
guac-9b |
4608 | 36 | 36 |
guac-12b |
5120 | 40 | 40 |
guac-16b |
5632 | 44 | 44 |
guac-21b |
6144 | 48 | 48 |
guac-26b |
6656 | 52 | 52 |
guac-32b |
7168 | 56 | 56 |
guac-39b |
7680 | 60 | 60 |
guac-48b |
8192 | 64 | 64 |
There's also a guac-106m-1080ti variant of guac-106m tuned for smaller GPUs. guac-3b is the default development config referenced throughout CLAUDE.md and the Makefile.
# Full pipeline with cached/tokenized datasets (default)
make pipeline CONFIG=guac-3b
# Force re-tokenization
make pipeline FORCE_RETOKENIZE=true
# Different mid-training task specialization
make pipeline TASK=code
make pipeline TASK=reasoning
# Debug mode with smaller datasets
make pipeline DEBUG=truemake train-tokenizer VOCAB_SIZE=60000 DATASETS=fineweb
make tokenize-datasets TOKENIZER_PATH=scratch/tokenizers/sentencepiece/shared_60kmake status # Pipeline status and available models
make configs # Show available model configs
make cache # Show cached dataset info
make clean # Clean all outputsGuac's mixed-layer architectures build on the following work:
- Dao, T. & Gu, A. (2024). Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality (Mamba-2). arXiv:2405.21060.
- Arora, S., Eyuboglu, S., Timalsina, A., Johnson, I., Poli, M., Zou, J., Rudra, A., & Ré, C. (2024). Simple linear attention language models balance the recall-throughput tradeoff (BASED). arXiv:2402.18668.
- Dao, T., Fu, D. Y., Ermon, S., Rudra, A., & Ré, C. (2022). FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. arXiv:2205.14135.
- Wolf, T. et al. (2020). Transformers: State-of-the-Art Natural Language Processing (HuggingFace
transformers). arXiv:1910.03771.