Views
No views yet
| Parameter | Value |
|---|---|
| Hidden dim | 2048 |
| Blocks | 16 (8 channels each) |
| Channel dim | 384 |
| FF dim | 8192 (Fused SwiGLU) |
| Working memory slots | 128 |
| Episodic memory slots | 256 |
| Semantic memory slots | 512 |
| Tokenizer | CharTokenizer (136 vocab) |
| Normalization | RMSNorm |
| Positional encoding | RoPE |
train_ultra.py script includes the complete training pipeline with all optimizations:| Part | Source | Description |
|---|---|---|
| A | HuggingFace datasets | wikitext-103, codeparrot-clean, fineweb, oscar-fr, the-stack-smol, alpaca-cleaned, c4-en |
| B | CogNet HF repo data | Pre-tokenized .pt files from this repository |
| C | AICL repo | JSONL datasets, .aicl examples, source code, spec, tests (10x repeated) |
| D | HF scripts | Python/JSON/MD scripts from this repo (3x weight) |
| E | Synthetic data | Code templates + English + French sentences (~50M chars) |
train_merged.pt file.| # | Optimization | Benefit |
|---|---|---|
| 1 | BF16 mixed precision | 2x throughput vs FP32 |
| 2 | RMSNorm + RoPE | No learned positional table |
| 3 | Vectorized channel processing | No Python for-loops over channels |
| 4 | SDPA/Flash Attention for memory tiers | Fused attention for memory reads |
| 5 | Fused SwiGLU | Single matmul for gate+up |
| 6 | Gradient checkpointing | ~3x memory savings |
| 7 | torch.compile() | Kernel fusion, reduced overhead |
| 8 | FSDP multi-GPU | Near-linear multi-GPU scaling |
| 9 | Fused AdamW | Faster optimizer step |
| 10 | CUDA prefetch pipeline | Overlaps data transfer with compute |
| 11 | Async checkpointing | Saves in background, no training pause |
| 12 | Sequence length warmup | 128 -> target over warmup period |
| 13 | 8-bit optimizer (optional) | 50% less VRAM for optimizer states |
cuda.synchronize()benchmark_results.jsonETA: Xh calculated from the measured speed.| File | Description |
|---|---|
cognet_1b_optimized.py | Optimized model architecture (RMSNorm, RoPE, vectorized, SDPA, FusedSwiGLU) |
train_ultra.py | Main training script (complete A-B-C-D-E pipeline + benchmark + all optimizations) |
run.py | Python launcher (auto-detects GPUs, installs deps, launches torchrun) |
infer_optimized.py | Inference with optimized model (generate, analyze, benchmark) |
benchmark.py | Standalone benchmark (original vs optimized, scalability test) |
convert_checkpoint.py | Convert original checkpoint to optimized format |
requirements.txt | Python dependencies |
setup.sh | Quick start setup script |
| File | Description |
|---|---|
cognet_1b.py | Original model architecture |
runpod_train_1b.py | Original RunPod training script |
train_1b_final.py | Previous training script |
train_1b_v2.py | Previous training script v2 |
train_1b_v3.py | Previous training script v3 |
train_bg.py | Background training script |
train_pipeline.py | Pipeline training script |
infer.py | Original inference script |
chat_infer.py | Chat-style inference |
gen_data_1b.py | Synthetic data generation |
cognet_data_prep.py | Standalone data prep |
config.json | Model config |
tokenizer_v3.json | CharTokenizer vocabulary |
data/ | AICL datasets and examples |
1# 1. Clone
2git clone https://huggingface.co/thefinalboss/CogNet-1B
3cd CogNet-1B
4
5# 2. Install deps
6pip install torch datasets huggingface_hub tokenizers
7
8# 3. Set HF token (for data download)
9export HF_TOKEN=your_token_here
10
11# 4. Train — everything is automatic
12python run.py1# Single GPU with all optimizations
2python train_ultra.py --max-steps 100000 --compile --cuda-prefetch --seq-warmup --async-ckpt
3
4# Multi-GPU with FSDP
5torchrun --nproc_per_node=4 train_ultra.py --use-fsdp --max-steps 100000
6
7# Use the Python launcher (auto-detects GPUs, installs deps)
8python run.py --max-steps 100000 --hf-token hf_xxx
9
10# Just prepare data (no training)
11python run.py --prep-only
12
13# Resume from checkpoint
14python run.py --resume ./checkpoints_1b/cognet_1b_latest.pt
15
16# 350M model (faster for testing)
17python run.py --model-size 350m
18
19# 8-bit optimizer (less VRAM)
20python run.py --8bit1from cognet_1b_optimized import create_cognet_1b_optimized
2import torch
3
4# Create model
5model = create_cognet_1b_optimized(vocab_size=136, max_seq_len=512)
6
7# Load checkpoint
8ckpt = torch.load('checkpoints/cognet_best.pt', map_location='cpu', weights_only=False)
9model.load_state_dict(ckpt['model_state_dict'])
10model.eval()
11
12# Generate
13prompt = torch.tensor([[2]]) # BOS token
14output = model.generate(prompt, max_new_tokens=200, temperature=0.8, top_k=50)
15
16# Decode (CharTokenizer)
17vocab = {0: '', 1: '', 2: '', 3: ''}
18for i in range(4, 136):
19 vocab[i] = chr([*range(32,127), *[
20 192,193,194,195,196,197,199,200,201,202,203,204,205,206,207,
21 210,211,212,213,214,217,218,219,220,224,225,226,227,228,229,
22 231,232,233,234,235,236,237,238,239,242,243,244,245,246,249,
23 250,251,252,253,255
24 ]][i-4])
25
26text = ''.join(vocab.get(t, '') for t in output[0].tolist() if t not in (0,1,2,3))
27print(text)1python infer_optimized.py generate --prompt "The future of AI is" --max-tokens 100
2python infer_optimized.py benchmark1# Full benchmark: original vs optimized + scalability test
2python benchmark.py
3
4# Quick benchmark during training (automatic)
5python train_ultra.py --max-steps 20
6# The first 13 steps are: 3 warmup + 10 benchmark = real speed measurementconfigs/:| Config | Description |
|---|---|
1b_single_gpu.yaml | 1B model, single GPU |
1b_fsdp.yaml | 1B model, multi-GPU FSDP |
350m_fast.yaml | 350M model, fast iteration |