ZhaoningYu1996/nanoMolmo2

1

stars

16

commits

Python

primary language

Jan 18, 2026

updated

README

nanoMolmo2

๐ŸŽ“ A Vision-Language Model (VLM) Learning Project

A minimal implementation of Molmo2 VLM from scratch for educational purposes.

Overview

nanoMolmo2 is an educational reimplementation of the Molmo2 Vision-Language Model, designed to help developers learn and understand modern VLM architectures from the ground up. This hands-on project uses Qwen3-0.6B as the base language model while following Molmo2's architecture and training methodology.

๐ŸŽฏ Primary Goal: Provide a clear, educational implementation for learning how Vision-Language Models work - from architecture design to multimodal training.

โš ๏ธ Note: This is a learning-focused educational project, not intended for production use.

Architecture

nanoMolmo2: Educational VLM with frozen vision encoder for efficiency

  • Vision Encoder: Molmo2's CLIP ViT (~300M params) - ๐Ÿ”’ FROZEN during training
  • Connector: Linear/MLP projection (~1M params) - โœ๏ธ TRAINABLE
  • Base LLM: Qwen3-0.6B (~500M params) - โœ๏ธ TRAINABLE
  • Training Objective: Same as Molmo2 (multimodal next-token prediction)

Why frozen vision encoder?

  • โœ… 50% less memory (~20GB vs ~30GB per GPU)
  • โœ… 30-40% faster training (skip vision backward pass)
  • โœ… Stable features (pre-trained CLIP is already excellent)
  • โœ… Focus learning on language understanding

Total trainable: ~501M parameters
Hardware: Runs on 2-4 A100 40GB GPUs

See MODEL_ARCHITECTURE.md for complete details.

Quick Start

Step 1: Install dependencies

pip install -r requirements.txt

Step 2: Download datasets

# Stage 1 pre-training only (~80GB, 5 datasets)
python scripts/download_datasets.py --stage pretrain

# Stage 2 & 3 SFT datasets (~500GB, 29 datasets)
python scripts/download_datasets.py --stage sft

# All stages
python scripts/download_datasets.py --stage all

# Useful options:
python scripts/download_datasets.py --list      # See all datasets
python scripts/download_datasets.py --check     # Check download status
python scripts/download_datasets.py --dry-run   # Preview without downloading

Storage by Stage (based on Molmo2 tech report):

  • Stage 1: ~80GB (5 datasets) - Pre-training with fixed ratios
  • Stage 2 & 3: ~500GB (29 datasets) - SFT (Stage 3 uses same data)

See DATASETS_BY_STAGE.md for complete breakdown.

Step 3: Train

# Stage 1: Pre-training
python examples/train_with_stage_dataloaders.py --stage 1

# Stage 2: SFT
python examples/train_with_stage_dataloaders.py --stage 2

# Stage 3: Long-context (same data, longer sequences)
python examples/train_with_stage_dataloaders.py --stage 3

Project Structure

nanoMolmo2/
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ model_config.yaml         # Model architecture config
โ”‚   โ””โ”€โ”€ train_config.yaml         # Training parameters
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ dataloaders/              # Dataset implementations
โ”‚   โ”‚   โ”œโ”€โ”€ base.py               # Base classes
โ”‚   โ”‚   โ”œโ”€โ”€ image_datasets.py     # Image dataset loaders
โ”‚   โ”‚   โ”œโ”€โ”€ video_datasets.py     # Video dataset loaders
โ”‚   โ”‚   โ””โ”€โ”€ utils.py              # Utilities (packing, weighting)
โ”‚   โ””โ”€โ”€ stage_dataloaders.py      # Stage-specific data modules
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ minimal_pure_pytorch.py   # Minimal VLM implementation
โ”‚   โ””โ”€โ”€ train_with_stage_dataloaders.py  # Training example
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ download_datasets.py      # Dataset downloader
โ”‚   โ”œโ”€โ”€ inspect_molmo2_data.py    # Data inspection tool
โ”‚   โ””โ”€โ”€ verify_model_setup.py     # Setup verification
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_dataloaders.py       # Unit tests
โ”œโ”€โ”€ DATASETS_BY_STAGE.md          # Dataset breakdown by stage
โ”œโ”€โ”€ MODEL_ARCHITECTURE.md         # Architecture details
โ”œโ”€โ”€ MOLMO2_TECH_REPORT_SUMMARY.md # Tech report summary
โ”œโ”€โ”€ PURE_PYTORCH_GUIDE.md         # Pure PyTorch implementation
โ”œโ”€โ”€ QUICKSTART.md                 # Quick start guide
โ”œโ”€โ”€ TRAINING_PIPELINE.md          # Training pipeline details
โ”œโ”€โ”€ YOUR_SETUP.md                 # Your specific setup
โ”œโ”€โ”€ requirements.txt              # Full dependencies
โ””โ”€โ”€ requirements_minimal.txt      # Minimal dependencies

Training Pipeline

Based on Molmo2's 3-stage approach:

Stage 1: Pre-training (5 datasets, ~80GB)
โ”œโ”€โ”€ 60% Dense captioning (PixMo-Cap)
โ”œโ”€โ”€ 30% Image pointing (PixMo-Points, PixMo-Count, CoSyn-Point)
โ””โ”€โ”€ 10% NLP data (Tulu)
    โ†“
Stage 2: Supervised Fine-Tuning (100+ datasets)
โ”œโ”€โ”€ Molmo2 datasets (video cap, QA, pointing, tracking)
โ”œโ”€โ”€ PixMo datasets (image cap, QA, pointing)
โ””โ”€โ”€ Academic datasets (VQA, DocVQA, ChartQA, ...)
    โ†“
Stage 3: Long-Context SFT (same datasets as Stage 2)
โ”œโ”€โ”€ Longer sequences: 36,864 tokens (vs 4,096)
โ””โ”€โ”€ More frames: 384 (vs 128)

Documentation

References

License

MIT License - See LICENSE file for details.


Educational Use Only | Built with โค๏ธ for learning VLM architectures

Contributors

ZhaoningYu1996

16 commits

ZhaoningYu1996/nanoMolmo2

1

stars

16

commits

Python

primary language

Jan 18, 2026

updated

README

nanoMolmo2

๐ŸŽ“ A Vision-Language Model (VLM) Learning Project

A minimal implementation of Molmo2 VLM from scratch for educational purposes.

Overview

nanoMolmo2 is an educational reimplementation of the Molmo2 Vision-Language Model, designed to help developers learn and understand modern VLM architectures from the ground up. This hands-on project uses Qwen3-0.6B as the base language model while following Molmo2's architecture and training methodology.

๐ŸŽฏ Primary Goal: Provide a clear, educational implementation for learning how Vision-Language Models work - from architecture design to multimodal training.

โš ๏ธ Note: This is a learning-focused educational project, not intended for production use.

Architecture

nanoMolmo2: Educational VLM with frozen vision encoder for efficiency

  • Vision Encoder: Molmo2's CLIP ViT (~300M params) - ๐Ÿ”’ FROZEN during training
  • Connector: Linear/MLP projection (~1M params) - โœ๏ธ TRAINABLE
  • Base LLM: Qwen3-0.6B (~500M params) - โœ๏ธ TRAINABLE
  • Training Objective: Same as Molmo2 (multimodal next-token prediction)

Why frozen vision encoder?

  • โœ… 50% less memory (~20GB vs ~30GB per GPU)
  • โœ… 30-40% faster training (skip vision backward pass)
  • โœ… Stable features (pre-trained CLIP is already excellent)
  • โœ… Focus learning on language understanding

Total trainable: ~501M parameters
Hardware: Runs on 2-4 A100 40GB GPUs

See MODEL_ARCHITECTURE.md for complete details.

Quick Start

Step 1: Install dependencies

pip install -r requirements.txt

Step 2: Download datasets

# Stage 1 pre-training only (~80GB, 5 datasets)
python scripts/download_datasets.py --stage pretrain

# Stage 2 & 3 SFT datasets (~500GB, 29 datasets)
python scripts/download_datasets.py --stage sft

# All stages
python scripts/download_datasets.py --stage all

# Useful options:
python scripts/download_datasets.py --list      # See all datasets
python scripts/download_datasets.py --check     # Check download status
python scripts/download_datasets.py --dry-run   # Preview without downloading

Storage by Stage (based on Molmo2 tech report):

  • Stage 1: ~80GB (5 datasets) - Pre-training with fixed ratios
  • Stage 2 & 3: ~500GB (29 datasets) - SFT (Stage 3 uses same data)

See DATASETS_BY_STAGE.md for complete breakdown.

Step 3: Train

# Stage 1: Pre-training
python examples/train_with_stage_dataloaders.py --stage 1

# Stage 2: SFT
python examples/train_with_stage_dataloaders.py --stage 2

# Stage 3: Long-context (same data, longer sequences)
python examples/train_with_stage_dataloaders.py --stage 3

Project Structure

nanoMolmo2/
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ model_config.yaml         # Model architecture config
โ”‚   โ””โ”€โ”€ train_config.yaml         # Training parameters
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ dataloaders/              # Dataset implementations
โ”‚   โ”‚   โ”œโ”€โ”€ base.py               # Base classes
โ”‚   โ”‚   โ”œโ”€โ”€ image_datasets.py     # Image dataset loaders
โ”‚   โ”‚   โ”œโ”€โ”€ video_datasets.py     # Video dataset loaders
โ”‚   โ”‚   โ””โ”€โ”€ utils.py              # Utilities (packing, weighting)
โ”‚   โ””โ”€โ”€ stage_dataloaders.py      # Stage-specific data modules
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ minimal_pure_pytorch.py   # Minimal VLM implementation
โ”‚   โ””โ”€โ”€ train_with_stage_dataloaders.py  # Training example
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ download_datasets.py      # Dataset downloader
โ”‚   โ”œโ”€โ”€ inspect_molmo2_data.py    # Data inspection tool
โ”‚   โ””โ”€โ”€ verify_model_setup.py     # Setup verification
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_dataloaders.py       # Unit tests
โ”œโ”€โ”€ DATASETS_BY_STAGE.md          # Dataset breakdown by stage
โ”œโ”€โ”€ MODEL_ARCHITECTURE.md         # Architecture details
โ”œโ”€โ”€ MOLMO2_TECH_REPORT_SUMMARY.md # Tech report summary
โ”œโ”€โ”€ PURE_PYTORCH_GUIDE.md         # Pure PyTorch implementation
โ”œโ”€โ”€ QUICKSTART.md                 # Quick start guide
โ”œโ”€โ”€ TRAINING_PIPELINE.md          # Training pipeline details
โ”œโ”€โ”€ YOUR_SETUP.md                 # Your specific setup
โ”œโ”€โ”€ requirements.txt              # Full dependencies
โ””โ”€โ”€ requirements_minimal.txt      # Minimal dependencies

Training Pipeline

Based on Molmo2's 3-stage approach:

Stage 1: Pre-training (5 datasets, ~80GB)
โ”œโ”€โ”€ 60% Dense captioning (PixMo-Cap)
โ”œโ”€โ”€ 30% Image pointing (PixMo-Points, PixMo-Count, CoSyn-Point)
โ””โ”€โ”€ 10% NLP data (Tulu)
    โ†“
Stage 2: Supervised Fine-Tuning (100+ datasets)
โ”œโ”€โ”€ Molmo2 datasets (video cap, QA, pointing, tracking)
โ”œโ”€โ”€ PixMo datasets (image cap, QA, pointing)
โ””โ”€โ”€ Academic datasets (VQA, DocVQA, ChartQA, ...)
    โ†“
Stage 3: Long-Context SFT (same datasets as Stage 2)
โ”œโ”€โ”€ Longer sequences: 36,864 tokens (vs 4,096)
โ””โ”€โ”€ More frames: 384 (vs 128)

Documentation

References

License

MIT License - See LICENSE file for details.


Educational Use Only | Built with โค๏ธ for learning VLM architectures

Contributors

ZhaoningYu1996

16 commits

Languages

Python

100.0%