Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
env:
UV_NO_SOURCES: "1"
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down Expand Up @@ -38,4 +40,4 @@ jobs:
run: uv run ruff format --check openadapt_ml/

- name: Run pytest
run: uv run pytest tests/ -v
run: uv run pytest tests/ -v --ignore=tests/integration
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ _trash/
# Auto-generated files
RESOURCES.md
azure_logs/

# User-specific screenshot mappings (contains absolute paths)
screenshot_mapping.json
32 changes: 32 additions & 0 deletions configs/qwen3vl_demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
model:
name: Qwen/Qwen3-VL-2B-Instruct # 2B for fast iteration; upgrade to 8B once pipeline is validated
load_in_4bit: true

lora:
r: 16
lora_alpha: 32
lora_dropout: 0.0
bias: none
target_modules:
- q_proj
- v_proj
- k_proj
- o_proj
# task_type is always CAUSAL_LM (set in trl_trainer.py, not configurable)
weights_path: checkpoints/qwen3vl2b_demo_lora

training:
num_train_epochs: 10 # 20 samples, need more passes
per_device_train_batch_size: 1
gradient_accumulation_steps: 4
learning_rate: 5.0e-5
lr_scheduler_type: cosine
warmup_ratio: 0.1
weight_decay: 0.01
max_grad_norm: 0.5
logging_steps: 1
save_strategy: epoch
early_stop_loss: 1.0
early_stop_patience: 5
early_stop_min_delta: 0.1 # Stop if loss doesn't improve by at least 0.1
early_stop_plateau_patience: 5 # for 5 consecutive steps
138 changes: 138 additions & 0 deletions docs/gpu_hosting_options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# GPU Compute Hosting Options for OpenAdapt.ai

**Context**: Fine-tuning Qwen3-VL (2B-8B), MIT-licensed open source project, no budget.

**Hardware requirements**:
- Qwen3-VL 2B with QLoRA: ~8-10 GB VRAM (fits on T4 16GB)
- Qwen3-VL 8B with QLoRA: ~16-24 GB VRAM (needs A10/A100/L4)
- Unsloth reduces VRAM by ~60% and speeds training 1.7x

---

## TIER 1: Apply Immediately (Highest Value)

### 1. AWS Cloud Credits for Open Source
- **Status**: ACTIVE (running since 2019, reaffirmed April 2025)
- **Credits**: Varies per project; AWS has given millions across 200+ OSS projects
- **GPUs**: Full AWS fleet (P4d/P5 with A100/H100, G5 with A10G, G6 with L4)
- **Eligibility**: OSI-approved license (MIT qualifies), active AWS account, valid payment method
- **Strings attached**: Credits for project infrastructure, not personal use
- **How to apply**: https://aws.amazon.com/blogs/opensource/aws-promotional-credits-open-source-projects/
- **Why #1**: Most directly relevant. MIT-licensed, established on GitHub — this program was designed for projects like OpenAdapt.

### 2. Google TPU Research Cloud (TRC)
- **Status**: ACTIVE (rolling admissions)
- **Credits**: Free access to 1,000+ Cloud TPU devices
- **Hardware**: Cloud TPUs (v2, v3, v4) — not GPUs, but excellent for VLM training via JAX/PyTorch XLA
- **Eligibility**: Anyone can apply; no academic affiliation required
- **Strings attached**: Must share research publicly (blog posts, open-source code, or papers)
- **How to apply**: https://sites.research.google/trc/
- **Why #2**: Completely free, rolling admissions. Sharing publicly is already met by MIT license.

### 3. NVIDIA Inception Program (Unlocks Multi-Platform Credits)
- **Status**: ACTIVE, free to join
- **Direct benefits**: Free DLI training credits, SDK access, preferred hardware pricing
- **Indirect benefits**:
- AWS Activate credits: $25,000-$100,000
- Nebius AI Lift: up to $150,000 in cloud credits
- DGX Cloud Innovation Lab: 2 months of DGX Cloud access (select members)
- **Eligibility**: At least one developer, working website, officially incorporated, <10 years old
- **Strings attached**: No equity required
- **How to apply**: https://www.nvidia.com/en-us/startups/
- **Why #3**: Force multiplier. Free to join, unlocks $25K-$150K across partners.

### 4. Microsoft for Startups (Azure Credits)
- **Status**: ACTIVE (restructured July 2025)
- **Credits**: $1,000 immediately (no application), up to $5,000 with business verification, up to $150,000 for investor-backed startups
- **GPUs**: Azure NC/ND series (A100, H100, V100, T4)
- **Eligibility**: No funding required for $5K tier
- **Strings attached**: Credits expire (90-180 days)
- **How to apply**: https://www.microsoft.com/en-us/startups (self-service sign-up)
- **Why #4**: $1K-$5K with no funding needed. Quick to get started.

---

## TIER 2: Strong Options (Apply Soon)

### 5. Google for Startups Cloud Program
- **Credits**: $2,000 (pre-funding), up to $100,000 (VC-backed), up to $350,000 (AI-first track)
- **GPUs**: Full GCP fleet (A100, H100, L4, T4, TPU)
- **Eligibility**: Start tier requires no funding
- **How to apply**: https://startup.google.com/cloud/

### 6. Lambda Labs Research Grant
- **Credits**: Up to $5,000 in Cloud Credits plus mentoring
- **GPUs**: Lambda Cloud fleet (A100, H100, A6000)
- **Eligibility**: Academic researchers or published research projects; 50% academic discount also available
- **How to apply**: https://lambda.ai/research

### 7. fal.ai Research Grants
- **Credits**: Free compute (amount per project)
- **Eligibility**: Open to anyone — no formal degree required
- **How to apply**: Email grants@fal.ai with project description. See https://fal.ai/grants

### 8. AMD AI Developer Program & Developer Cloud
- **Credits**: $100 free (~50 hours) to start; additional credits for public projects
- **GPUs**: AMD Instinct MI300X (192GB VRAM)
- **Note**: Check ROCm compatibility with your training stack
- **How to apply**: https://www.amd.com/en/developer/resources/cloud-access/amd-developer-cloud.html

### 9. a16z Open Source AI Grants
- **Type**: Cash grants (not investment, not equity)
- **Eligibility**: Open-source AI developers, hackers, researchers, small teams
- **How to apply**: Watch https://a16z.com/supporting-the-open-source-ai-community/ for batch announcements

---

## TIER 3: Free Platforms (Use Today, No Application)

| Platform | GPU | Free Limits | Best For |
|----------|-----|-------------|----------|
| [Kaggle](https://kaggle.com) | T4/P100 | 30 hrs/week, background exec | **Training Qwen3-VL 2B now** |
| [Google Colab](https://colab.research.google.com) | T4 | 15-30 hrs/week | Backup training |
| [Lightning.ai](https://lightning.ai) | T4 | 22 hrs/month | Development |
| [SageMaker Studio Lab](https://studiolab.sagemaker.aws) | T4 | 4hr sessions, 8hr/day, no credit card | Experimentation |
| [Modal](https://modal.com) | A100/H100 | $30/month credit (~2hr A100) | Burst training |
| [Paperspace Gradient](https://paperspace.com/gradient/free-gpu) | M4000 (8GB) | 6hr sessions, restartable | Too small for VLM training |

---

## TIER 4: Research/Academic Programs

| Program | Credits | Eligibility |
|---------|---------|-------------|
| [NSF ACCESS](https://access-ci.org) | Large GPU allocations (thousands of hours) | US institution PI |
| [Amazon Research Awards](https://amazon.science/research-awards) | $70K funds + $50K AWS credits | Academic institutions |
| [NVIDIA Academic Hardware Grant](https://academicgrants.nvidia.com/academicgrantprogram/s/Application) | Physical GPU hardware | Faculty at PhD-granting institutions |
| [HOSTKEY GPU Grant](https://hostkey.com/about-us/grants-for-scientific-projects-and-startups/) | Free GPU server time | Research/startup proposals (monthly windows) |

---

## TIER 5: Inference Hosting (Post-Training)

| Platform | Free Tier | Notes |
|----------|-----------|-------|
| [HuggingFace ZeroGPU](https://huggingface.co/docs/hub/en/spaces-zerogpu) | H200 inference, daily quota | Best free option for deploying fine-tuned model |
| [Replicate](https://replicate.com) | Limited free runs | Deploying custom models as APIs |
| [Fireworks AI](https://fireworks.ai) | 10 RPM free, $1 credit | Supports Qwen models |
| [Together AI](https://together.ai) | No free tier ($5 min) | Startup accelerator offers up to $50K |

---

## Recommended Action Plan

| Phase | Action | Expected Value | Timeline |
|-------|--------|---------------|----------|
| **Today** | Sign up Microsoft for Startups | $1K-$5K Azure | Same day |
| **Today** | Start training on Kaggle | 30 hrs/week free T4 | Immediate |
| **This week** | Apply AWS OSS Credits | $5K-$50K+ | 2-4 weeks |
| **This week** | Apply Google TRC | Free TPU access | 1-2 weeks |
| **This week** | Email fal.ai (grants@fal.ai) | Free compute | 1-2 weeks |
| **This month** | Join NVIDIA Inception | Unlocks $25K-$150K partner credits | 2-4 weeks |
| **This month** | Apply Google for Startups | $2K-$350K | 1-2 weeks |
| **This month** | Apply Lambda Research Grant | $5K | 2-4 weeks |
| **Post-training** | Deploy on HuggingFace ZeroGPU | Free H200 inference | When model ready |

---

*Research conducted February 2026. Verify program availability before applying.*
90 changes: 90 additions & 0 deletions docs/training_pipeline_gaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Training Pipeline Gaps & Plan

## Current State (Feb 23, 2026)

First successful JSONL training launch on Lambda Labs (Qwen3-VL-8B, A10).
Pipeline works end-to-end: `convert_demos --bundle` -> `train.py --jsonl` -> Lambda launch.

### What Works
- Bundle creation (JSONL + images with relative paths)
- JSONL loader in TRL trainer
- Lambda Labs instance launch, code sync, bundle upload
- Checkpoint save (TRL SFTTrainer auto-saves per epoch + final)
- Dashboard with Lambda cloud badge, cost display, setup progress
- Checkpoint download via rsync

### What's Missing

## Gap 1: TRL Training Callback (logging + early stopping)

**Problem**: `train_from_jsonl()` uses TRL's SFTTrainer which logs to stdout/TensorBoard
but NOT to our `training_log.json`. The Lambda polling loop in `lambda_labs.py` reads
`training_log.json` for dashboard updates — so the dashboard shows 0 progress.

Also, `early_stop_loss` is in YAML config but not wired to a TRL callback.

**Fix**: Add a `TrainerCallback` subclass to `trl_trainer.py`:
- `on_log()`: Write step/epoch/loss/lr to `training_log.json`
- `on_log()`: Check `early_stop_loss` threshold, set `trainer.state.should_training_stop = True`
- ~40 lines

**Files**: `openadapt_ml/training/trl_trainer.py`

## Gap 2: Cost Persistence

**Problem**: Cost is only computed in dashboard JavaScript. Not saved to `training_log.json`.
After instance terminates, cost is lost.

**Fix**: Write `cost_per_hour`, `total_cost`, `instance_type` to `training_log.json` in the
TRL callback (same one from Gap 1). The callback can read instance_type from an env var
or config field.

**Files**: `openadapt_ml/training/trl_trainer.py` (extend callback)

## Gap 3: Post-Training Eval Automation

**Problem**: After training completes on Lambda, there's no automatic evaluation. User must
manually run `eval_policy.py` or `compare.py`.

**Fix**: Add `--eval` flag to `train.py` that runs eval after training completes:
1. Load the saved checkpoint
2. Run prediction on each training sample (sanity check: can it reproduce training data?)
3. Write results to `eval_results.json` alongside checkpoint
4. ~30 lines in `train.py`, reusing `eval_policy.py` logic

For Lambda: add eval step to `run_training()` command string when `--eval` is passed.

**Files**: `openadapt_ml/scripts/train.py`, `openadapt_ml/cloud/lambda_labs.py`

## Gap 4: Training Speed (Unsloth on Lambda)

**Problem**: 8B model without Unsloth = 569s/step on A10. With Unsloth should be ~100-200s/step.
Current Lambda setup installs deps with `uv sync` which doesn't include Unsloth (it's optional
and needs special install: `pip install unsloth`).

**Fix**: Add Unsloth install to Lambda setup script. Remove `--no-unsloth` from default
Lambda train command. Test Unsloth + Qwen3-VL-8B on A10.

Alternative: Use 2B model (`Qwen/Qwen3-VL-2B-Instruct`) which is 4x faster without Unsloth.

**Files**: `openadapt_ml/cloud/lambda_labs.py` (setup_instance), `configs/qwen3vl_demo.yaml`

## Gap 5: Auto-Terminate After Training

**Problem**: When training is launched manually (SSH nohup), the Lambda instance keeps running
after training completes. No auto-terminate.

**Fix**: The automated `train` command already handles this when it's used end-to-end.
The issue is only when we SSH in manually. Not a code gap — operational.

## Priority Order

1. **Gap 4** (speed) — blocking: current run takes 8 hours, wastes money
2. **Gap 1** (callback) — high: dashboard shows nothing during training
3. **Gap 3** (eval) — medium: need eval to know if training worked
4. **Gap 2** (cost) — low: nice-to-have for tracking spend
5. **Gap 5** (terminate) — low: operational

## Immediate Action

Kill current slow run, switch to 2B model, relaunch. Fix Gaps 1+4 first.
Loading