FORGE-500M-Chat is a state-of-the-art hybrid sub-billion parameter conversational language model designed from first principles by Soham Pal. It solves the compute accessibility gap in AI research by replacing quadratic self-attention with linear-time recurrent state-space recurrence, paired with hierarchical sparse expert mixture-of-experts (HSE-MoE).
The model was pretrained on 1.66 Billion tokens from scratch across 4× NVIDIA B300 SXM6 MIG compute slices, aligned via Supervised Fine-Tuning (SFT) on multi-turn dialogue with per-token loss masking, and polished using Direct Preference Optimization (DPO).
The full console training trajectory from Step 1 to Step 821 is archived in this repository under training_journey.log.
FORGE employs an asymmetric, multi-layer hybrid topology designed for maximum parameter utility and linear sequence scalability:
| Specification | Value | Technical Description |
|---|---|---|
| Total Parameters | 500,019,616 | 500.0M total weights (FP16/BF16 storage: ~1.0 GB) |
| Active Parameters | ~320,000,000 | Active per-token forward pass via Sparse HSE-MoE |
| Embedding Size | 211,444,736 | 206,464 vocabulary × 1,024 hidden dimension |
| Hidden Dimension ($d_{\text{model}}$) | 1,024 | Intermediate representation width |
| Total Transformer Layers | 18 | Interleaved hybrid recurrence + global attention |
| SSM Recurrence Layers | 15 (83.3%) | Adaptive Recurrent Gating (ARG) linear state space |
| Attention Layers | 3 (16.7%) | Global Multi-Head Attention (MHA) with RoPE + YaRN |
| Attention Heads | 8 | 8 Query heads, 8 Key/Value heads |
| MoE FFN Layers | 9 | Hierarchical Sparse Expert (HSE) (32 experts, top-2 active) |
| Dense FFN Layers | 9 | Dense SwiGLU FFN with $8/3 \times d_{\text{model}}$ expansion |
| Context Window | 4,096 | Native context (scalable to 16,384 with YaRN) |
| Tokenizer | CRAYON Turbo | 206,464 vocabulary (BPE with subword byte-fallback) |
Input Tokens (B, T)
│
▼
[CRAYON Embedding (206k Vocab, 1024 d_model)]
│
┌────┴───────────────────────────────────────┐
│ Layer 0..17: Interleaved Blocks │
│ ├─ 15× ARG Layers: Linear SSM Recurrence │
│ ├─ 3× Global MHA: Long-Range Attention │
│ ├─ 9× SwiGLU Dense FFN │
│ └─ 9× Hierarchical Sparse Expert (MoE) │
└────┬───────────────────────────────────────┘
▼
[Final RMSNorm + Chunked LM Projection Head]
│
▼
Target Logits / Probabilities
The pretraining and post-training of FORGE-500M represents an empirical milestone in lean, high-efficiency AI development:
1g.34gb, 18 SMs each, CUDA 13.2, Driver 595.91).nn.Module dynamic attribute restrictions with custom parameter wrapping (convert_to_attr_dict).chunk_size=1024) on the 206,464-token vocabulary to eliminate VRAM allocation spikes.In accordance with our commitment to total scientific reproducibility, the complete console log file (training_journey.log) containing every training step from Step 1 to Step 821, memory footprints, step durations, and loss curves is provided directly in the repository root:
training_journey.logIn a Google Colab notebook (T4 / A100 GPU), paste and run this single cell:
# 1. Clone repository & enter directory
!git clone https://huggingface.co/Phase-Technologies/FORGE-500M-Chat
%cd FORGE-500M-Chat
# 2. Install dependencies
!pip install -q torch einops triton transformers huggingface_hub
# 3. Generate text immediately
!python run_inference.py --prompt "<|bos|><|usr|>Explain how quantum computers differ from classical computers.<|asst|>" --max_new_tokens 128
import sys
import torch
from pathlib import Path
from huggingface_hub import snapshot_download
import safetensors.torch
# 0. Hardware configurations for Tesla T4
if torch.cuda.is_available():
torch.backends.cudnn.benchmark = False
torch.backends.cuda.enable_math_sdp(True)
# 1. Download Model Repository from Hugging Face
print("Downloading FORGE-500M-Chat repository...")
repo_dir = Path(snapshot_download(
repo_id="Phase-Technologies/FORGE-500M-Chat",
ignore_patterns=["pytorch_model.bin", "*.log"]
))
sys.path.insert(0, str(repo_dir))
# 2. Import FORGE modules
from tokenizer.crayon_wrapper import ForgeTokenizer
from config import ForgeModelConfig
from model.forge_model import build_forge_500m
# 3. Load Tokenizer & Model Configuration
print("Loading tokenizer and config...")
tokenizer = ForgeTokenizer.from_pretrained(str(repo_dir / "tokenizer"))
config_file = repo_dir / "config.json"
if not config_file.exists():
config_file = repo_dir / "model_config.json"
config = ForgeModelConfig.from_json(str(config_file))
config.vocab_size = tokenizer.vocab_size
# 4. Build Model & Load Safetensors Weights
print("Building FORGE model architecture...")
model = build_forge_500m(config)
safetensors_path = repo_dir / "model.safetensors"
if safetensors_path.exists():
print(f"Loading weights from safetensors ({safetensors_path.name})...")
state_dict = safetensors.torch.load_file(str(safetensors_path))
else:
print("Loading weights from pytorch_model.bin...")
state_dict = torch.load(repo_dir / "pytorch_model.bin", map_location="cpu")
model.load_state_dict({k: v.to(torch.bfloat16) for k, v in state_dict.items()}, strict=False)
del state_dict
# 5. Device Setup
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device).to(torch.bfloat16)
model.eval()
model_dtype = next(model.parameters()).dtype
print(f"Model ready on {device} ({model_dtype})!")
# 6. Formatted Chat Prompt & Autoregressive Generation
prompt = "<|bos|><|usr|> Explain how quantum computers differ from classical computers in simple terms.<|asst|>"
print(f"\nUser Prompt: {prompt}\n")
input_ids = torch.tensor(
[tokenizer.encode(prompt, add_bos=False, add_eos=False)],
dtype=torch.long,
device=device
)
print("Generating response...")
with torch.inference_mode():
output_ids = model.generate(
input_ids=input_ids,
max_new_tokens=128,
temperature=0.7,
top_p=0.9,
eos_token_id=tokenizer.special_tokens["<|eos|>"],
pad_token_id=tokenizer.special_tokens["<|pad|>"]
)
response = tokenizer.decode(output_ids[0].tolist(), skip_special_tokens=False)
print("\n" + "=" * 50)
print(response)
print("=" * 50)
| Token | String | Function |
|---|---|---|
| BOS | `< | bos |
| EOS | `< | eos |
| SYS | `< | sys |
| USR | `< | usr |
| ASST | `< | asst |
| PAD | `< | pad |
honestly i really wanted to train this beauty for full 15b tokens..... that was the real plan from day one to see how far this custom architecture could push..... but running multiple top tier gpus burns money so fast and i just ran completely out of budget..... literally had to stop pretraining early at 821 steps..... then quickly did sft and dpo right on the pod before shutting it down..... huge shoutout and love to runpod.io for providing the insane compute and infrastructure that made training this beast possible..... every single cent went into this little 500m model and seeing it come alive from scratch with custom cuda kernels and our own tokenizer was pure magic..... maybe one day with better funding we will train the full 3b or 15b token run..... until then i hope you guys enjoy playing with this model as much as i loved building it..... thank you so much to everyone who supported this crazy journey.....
pytorch_model.bin 1.3 GiBmodel.safetensors 1.3 GiB