Faaz commited on
Commit
f04f58b
Β·
1 Parent(s): 1c36b28

Fix setup_mi300x.sh step 2 + add project context summary

Browse files
MINDI_PROJECT_CONTEXT.pdf ADDED
Binary file (11.6 kB). View file
 
MINDI_PROJECT_CONTEXT.txt ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ============================================================
2
+ MINDI 1.5 VISION-CODER β€” FULL PROJECT CONTEXT SUMMARY
3
+ ============================================================
4
+ Last Updated: April 15, 2026
5
+ Use this file to restore context in a new AI chat session.
6
+ Paste this entire file as context when starting a new chat.
7
+ ============================================================
8
+
9
+ PROJECT OVERVIEW
10
+ ================
11
+ - Project: MINDI 1.5 Vision-Coder
12
+ - Startup: MINDIGENOUS.AI
13
+ - Goal: Fine-tune Qwen2.5-Coder-7B-Instruct into an agentic
14
+ vision-capable coding AI with custom MINDI special tokens
15
+ - Local Path: D:\Desktop 31st Jan 2026\MINDI 1.5 vision-coder\
16
+ - Python: 3.11.9, local venv at project root
17
+ - PyTorch: 2.6.0+cu124, transformers 4.40.0, peft 0.10.0
18
+
19
+
20
+ REPOSITORIES
21
+ ============
22
+ GitHub: https://github.com/Faaz345/MINDI-1.5-Vision-Coder.git (master branch)
23
+ HF Model: Mindigenous/MINDI-1.5-Vision-Coder (private)
24
+ HF Dataset: Mindigenous/MINDI-1.5-training-data (private)
25
+
26
+ Latest Git Commit: ff92c5a "Day 3 COMPLETE: Full model architecture"
27
+ All 3 repos are fully synced as of April 15, 2026.
28
+
29
+
30
+ GIT HISTORY
31
+ ===========
32
+ ff92c5a Day 3 COMPLETE: Full model architecture
33
+ 79f7022 Day 2 COMPLETE: 1.48M examples processed, 6GB dataset, WebSight done
34
+ 23c9987 Day 1 Complete: Tokenizer setup β€” Qwen2.5-Coder-7B base + 22 MINDI special tokens
35
+ 8eea373 feat: initial project scaffold for MINDI 1.5 Vision-Coder
36
+
37
+
38
+ ============================================================
39
+ DAY 1 β€” TOKENIZER (COMPLETE)
40
+ ============================================================
41
+ What was done:
42
+ - Downloaded Qwen/Qwen2.5-Coder-7B-Instruct tokenizer as base
43
+ - Added 22 MINDI special tokens for agentic capabilities
44
+ - Final vocab size: 151,685
45
+ - Saved to data/tokenizer/mindi_tokenizer/
46
+ - Base preserved at data/tokenizer/base_tokenizer/
47
+
48
+ 22 MINDI Special Tokens:
49
+ <|mindi_start|> / <|mindi_end|> β€” Main wrapper
50
+ <|thinking_start|> / <|thinking_end|> β€” Chain-of-thought reasoning
51
+ <|file_start|> / <|file_end|> β€” File path references
52
+ <|code_start|> / <|code_end|> β€” Code blocks
53
+ <|critique_start|> / <|critique_end|> β€” Self-critique
54
+ <|suggest_start|> / <|suggest_end|> β€” Suggestions
55
+ <|search_start|> / <|search_end|> β€” Web search queries
56
+ <|error_start|> / <|error_end|> β€” Error handling
57
+ <|fix_start|> / <|fix_end|> β€” Fix proposals
58
+ <|visual_start|> / <|visual_end|> β€” Visual/image processing
59
+ <|sandbox_start|> / <|sandbox_end|> β€” Code sandbox execution
60
+
61
+ Scripts created:
62
+ scripts/download_tokenizer.py β€” Downloads base Qwen tokenizer
63
+ scripts/add_special_tokens.py β€” Adds 22 MINDI tokens
64
+ scripts/test_mindi_format.py β€” Tests full MINDI format
65
+
66
+
67
+ ============================================================
68
+ DAY 2 β€” DATASET PIPELINE (COMPLETE)
69
+ ============================================================
70
+ What was done:
71
+ - Downloaded 10 source datasets from HuggingFace
72
+ - Processed all into unified JSONL chat format
73
+ - Quality filtered (kept 1,449,428 of 1,480,850 = 97.9%)
74
+ - Split into train/val/test (90/5/5)
75
+
76
+ Raw Data Sources (data/raw/):
77
+ starcoder_python.jsonl β€” StarCoder Python
78
+ starcoder_javascript.jsonl β€” StarCoder JavaScript
79
+ starcoder_typescript.jsonl β€” StarCoder TypeScript
80
+ starcoder_css.jsonl β€” StarCoder CSS
81
+ starcoder_html.jsonl β€” StarCoder HTML
82
+ evol_code.jsonl β€” EvolInstruct-Code
83
+ magicoder.jsonl β€” Magicoder OSS-Instruct
84
+ codefeedback.jsonl β€” CodeFeedback-Filtered
85
+ synthetic_nextjs.jsonl β€” Synthetic Next.js/React
86
+ websight.jsonl — WebSight (screenshot→HTML)
87
+
88
+ Processed Data (data/processed/):
89
+ mindi_all.jsonl β€” All combined (1,480,850 examples)
90
+ mindi_filtered.jsonl β€” Quality filtered (1,449,428 examples, ~5GB)
91
+ mindi_rejected.jsonl β€” Rejected examples
92
+ filter_report.json β€” Filter statistics
93
+ train.jsonl β€” Training split (1,304,486 examples, ~4.5GB)
94
+ val.jsonl β€” Validation split (72,471 examples, ~248MB)
95
+ test.jsonl β€” Test split (72,471 examples, ~249MB)
96
+ split_meta.json β€” Split metadata
97
+
98
+ Message Format (each JSONL line):
99
+ {"messages": [
100
+ {"role": "system", "content": "You are MINDI..."},
101
+ {"role": "user", "content": "..."},
102
+ {"role": "assistant", "content": "..."}
103
+ ], "source": "...", "language": "..."}
104
+
105
+ Scripts created:
106
+ scripts/download_datasets.py β€” Downloads all 10 sources
107
+ scripts/process_data.py β€” Processes into unified format
108
+ scripts/quality_filter.py β€” Quality filtering (protects websight/synthetic)
109
+ scripts/split_data.py β€” Train/val/test split
110
+ scripts/data_stats.py β€” Dataset statistics
111
+ scripts/upload_everything_to_hf.py β€” Uploads everything to HuggingFace
112
+
113
+
114
+ ============================================================
115
+ DAY 3 β€” MODEL ARCHITECTURE + TRAINING CODE (COMPLETE)
116
+ ============================================================
117
+
118
+ BASE MODEL SPECS:
119
+ Model: Qwen/Qwen2.5-Coder-7B-Instruct
120
+ Parameters: 7.61B
121
+ Hidden size: 4096
122
+ Layers: 32
123
+ Attention heads: 32 (8 KV heads, GQA)
124
+ Context length: 32,768
125
+
126
+ LoRA CONFIG:
127
+ Rank: 64
128
+ Alpha: 128
129
+ Dropout: 0.05
130
+ Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
131
+ Bias: none
132
+ Task type: CAUSAL_LM
133
+
134
+ VISION ENCODER:
135
+ Model: openai/clip-vit-large-patch14 (CLIP ViT-L/14)
136
+ Backbone: Frozen (not trained)
137
+ Projection: Linear(1024 β†’ 4096) β€” trainable
138
+ Output: 256 patch tokens at dim 4096
139
+
140
+ FUSION:
141
+ Method: Prepend 256 visual tokens before text tokens
142
+ Gate: Linear(4096 β†’ 4096) + LayerNorm(4096) β€” trainable
143
+ ~16.8M trainable parameters
144
+
145
+ TRAINING (3-Phase on MI300X 192GB):
146
+ Phase 1: LoRA only, 5000 steps, LR 2e-4, batch 16, code_only data
147
+ Phase 2: Vision bridge, 2500 steps, LR 1e-5, batch 8, websight_only data
148
+ Phase 3: All components, 2500 steps, LR 5e-5, batch 12, all data
149
+ Precision: bf16 (NOT fp16 β€” AMD requirement)
150
+ Gradient accumulation: 4
151
+ Gradient clipping: max_norm=1.0
152
+ Optimizer: AdamW, betas=(0.9, 0.95)
153
+
154
+ MI300X SPECIFICS:
155
+ GPU: AMD Instinct MI300X, 192GB VRAM
156
+ Platform: DigitalOcean
157
+ ROCm: 6.0 (presents as CUDA to PyTorch β€” torch.cuda.* works)
158
+ Env vars: HSA_OVERRIDE_GFX_VERSION=11.0.0, PYTORCH_ROCM_ARCH=gfx942
159
+ bf16 required (fp16 unstable on AMD MI300X)
160
+ torch.compile optional, gradient checkpointing enabled
161
+
162
+
163
+ FILES CREATED/MODIFIED ON DAY 3:
164
+ =================================
165
+
166
+ File 1: src/model/architecture.py (CREATED ~210 lines)
167
+ - MINDIArchitecture class
168
+ - Loads Qwen2.5-Coder-7B-Instruct with bf16, device_map=auto
169
+ - Applies LoRA with peft (r=64, alpha=128)
170
+ - Methods: _load_model(), apply_lora(), get_trainable_params(),
171
+ print_model_info(), save_lora(), load_lora(), resize_embeddings(), get_model()
172
+ - Has test block that validates loading + forward pass
173
+
174
+ File 2: src/model/vision_encoder.py (REWRITTEN ~250 lines)
175
+ - VisionEncoder class
176
+ - Uses CLIPVisionModel + CLIPImageProcessor (not CLIPModel/CLIPProcessor)
177
+ - Frozen CLIP backbone, trainable Linear(1024β†’4096) projection
178
+ - encode_image() returns (1, 256, 4096) tensor or None
179
+ - encode_batch() handles mixed images/Nones in a batch
180
+ - encode_screenshot() for PIL images
181
+ - save/load_projection() for checkpoint management
182
+ - get_num_visual_tokens() returns 256
183
+
184
+ File 3: src/model/fusion_layer.py (CREATED ~220 lines)
185
+ - VisionLanguageFusion class
186
+ - forward(text_embeds, visual_tokens, attention_mask) β†’ (fused_embeds, fused_mask)
187
+ - Prepends 256 visual tokens before text embeddings
188
+ - Extends attention mask to include visual positions
189
+ - gate_proj Linear(4096,4096) + LayerNorm(4096)
190
+
191
+ File 4: src/model/mindi_model.py (CREATED ~400+ lines)
192
+ - MINDI15 class β€” the complete model combining all components
193
+ - Uses MINDI custom tokenizer from data/tokenizer/mindi_tokenizer/
194
+ - forward() handles text-only and multimodal inputs
195
+ - Extends labels with -100 for visual token positions (no loss on images)
196
+ - generate() tokenizes with MINDI tokenizer, does fused embedding for images
197
+ - parse_output() extracts 8 section types via regex:
198
+ thinking, file, code, critique, suggest, search, error, fix
199
+ Returns dict[str, list[str]]
200
+ - set_trainable_components(lora, vision_projection, fusion) for phase switching
201
+ - save()/load() saves all 3 trainable components
202
+ - MINDI_SECTION_TOKENS dict maps section names to (start_token, end_token) pairs
203
+ - Test block: CPU tests (parse_output) + GPU tests (init, phases, forward, generate, save/load)
204
+
205
+ File 5: src/training/mindi_trainer.py (CREATED ~500+ lines)
206
+ - TrainingConfig dataclass, PhaseConfig dataclass
207
+ - StreamingJSONLDataset (IterableDataset) β€” reads JSONL line-by-line
208
+ with 10K shuffle buffer, formats with tokenizer.apply_chat_template()
209
+ - MINDITrainer class
210
+ - train() runs all 3 phases, train_phase() runs single phase
211
+ - evaluate() computes validation loss
212
+ - _save_checkpoint() and resume_from_checkpoint()
213
+ - Per-phase: AdamW optimizer (betas 0.9/0.95), LinearLR warmup + CosineAnnealingLR
214
+ - DataLoader: num_workers=4, pin_memory=True, prefetch_factor=2
215
+ - Logs to JSONL, tracks best_val_loss, gradient clipping
216
+
217
+ File 6: scripts/train.py (REWRITTEN β€” was a stub)
218
+ - Master training launch script
219
+ - parse_args(): --phase, --resume, --config, --dry_run, --push_to_hub, --no_wandb
220
+ - build_training_config() from YAML
221
+ - init_wandb(), push_checkpoint_to_hub()
222
+ - Signal handler: saves emergency checkpoint on Ctrl+C
223
+ - Crash handler: saves crash_checkpoint on unhandled exceptions
224
+ - Prints GPU info, final summary
225
+
226
+ File 7: configs/training_config.yaml (REWRITTEN)
227
+ - Full MI300X training config
228
+ - Sections: model, lora, vision, training (3 phases), data, logging, output
229
+ - Phase 1: 5000 steps, lr 2e-4, batch 16, code_only
230
+ - Phase 2: 2500 steps, lr 1e-5, batch 8, websight_only
231
+ - Phase 3: 2500 steps, lr 5e-5, batch 12, all
232
+ - data: paths to train/val, max_length 4096, shuffle_buffer 10000
233
+ - output: hf_repo Mindigenous/MINDI-1.5-Vision-Coder, push_every_phase true
234
+
235
+ File 8: setup_mi300x.sh (REWRITTEN)
236
+ - One-command MI300X setup for DigitalOcean
237
+ - 7 steps: ROCm PyTorch install, repo clone/pull (with HF_TOKEN auth),
238
+ pip install, dataset download, env vars, GPU verify + bf16 test, output dirs
239
+ - Step 2 checks if already in repo (requirements.txt exists β†’ git pull)
240
+ or fresh clone with https://Mindigenous:$HF_TOKEN@huggingface.co/...
241
+ - Final message: "Ready to train! Run: python scripts/train.py --phase 1"
242
+
243
+
244
+ EXISTING FILES (from Day 0 scaffold, not modified):
245
+ ====================================================
246
+ src/model/code_model.py β€” Old scaffold (not used by Day 3 code)
247
+ src/training/trainer.py β€” Old scaffold (replaced by mindi_trainer.py)
248
+ src/training/dataset.py β€” Old scaffold (replaced by StreamingJSONLDataset)
249
+ api/ β€” API scaffold (to be built later)
250
+ frontend/ β€” Frontend scaffold (to be built later)
251
+ tests/ β€” Test scaffold
252
+ docs/ β€” Documentation
253
+ src/agents/ β€” Agent system (to be built)
254
+ src/search/ β€” Search integration (to be built)
255
+ src/sandbox/ β€” Sandbox execution (to be built)
256
+ src/inference/ β€” Inference pipeline (to be built)
257
+ src/evaluation/ β€” Evaluation suite (to be built)
258
+
259
+
260
+ FULL PROJECT STRUCTURE
261
+ ======================
262
+ MINDI 1.5 vision-coder/
263
+ β”œβ”€β”€ .env β€” Secrets (git-ignored)
264
+ β”œβ”€β”€ .env.example β€” Template
265
+ β”œβ”€β”€ .gitignore
266
+ β”œβ”€β”€ README.md
267
+ β”œβ”€β”€ requirements.txt
268
+ β”œβ”€β”€ setup.py
269
+ β”œβ”€β”€ activate_mindi.bat
270
+ β”œβ”€β”€ setup_mi300x.sh β€” MI300X one-command setup
271
+ β”œβ”€β”€ configs/
272
+ β”‚ β”œβ”€β”€ model_config.yaml
273
+ β”‚ β”œβ”€β”€ training_config.yaml β€” Full training config (Day 3)
274
+ β”‚ β”œβ”€β”€ data_config.yaml
275
+ β”‚ └── search_config.yaml
276
+ β”œβ”€β”€ scripts/
277
+ β”‚ β”œβ”€β”€ download_tokenizer.py β€” Day 1
278
+ β”‚ β”œβ”€β”€ add_special_tokens.py β€” Day 1
279
+ β”‚ β”œβ”€β”€ test_mindi_format.py β€” Day 1
280
+ β”‚ β”œβ”€β”€ download_datasets.py β€” Day 2
281
+ β”‚ β”œβ”€β”€ process_data.py β€” Day 2
282
+ β”‚ β”œβ”€β”€ quality_filter.py β€” Day 2
283
+ β”‚ β”œβ”€β”€ split_data.py β€” Day 2
284
+ β”‚ β”œβ”€β”€ data_stats.py β€” Day 2
285
+ β”‚ β”œβ”€β”€ upload_everything_to_hf.py β€” Day 2
286
+ β”‚ β”œβ”€β”€ save_everything.py β€” Day 2
287
+ β”‚ β”œβ”€β”€ train.py β€” Day 3 (master launcher)
288
+ β”‚ β”œβ”€β”€ health_check.py β€” Scaffold
289
+ β”‚ β”œβ”€β”€ verify_install.py β€” Scaffold
290
+ β”‚ └── validate_setup.py β€” Scaffold
291
+ β”œβ”€β”€ src/
292
+ β”‚ β”œβ”€β”€ __init__.py
293
+ β”‚ β”œβ”€β”€ model/
294
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
295
+ β”‚ β”‚ β”œβ”€β”€ architecture.py β€” Day 3 (LoRA + Qwen loader)
296
+ β”‚ β”‚ β”œβ”€β”€ vision_encoder.py β€” Day 3 (CLIP ViT-L/14)
297
+ β”‚ β”‚ β”œβ”€β”€ fusion_layer.py β€” Day 3 (vision-language fusion)
298
+ β”‚ β”‚ β”œβ”€β”€ mindi_model.py β€” Day 3 (complete MINDI model)
299
+ β”‚ β”‚ └── code_model.py β€” Scaffold (unused)
300
+ β”‚ β”œβ”€β”€ training/
301
+ β”‚ β”‚ β”œβ”€β”€ __init__.py
302
+ β”‚ β”‚ β”œβ”€β”€ mindi_trainer.py β€” Day 3 (3-phase trainer)
303
+ β”‚ β”‚ β”œβ”€β”€ trainer.py β€” Scaffold (unused)
304
+ β”‚ β”‚ └── dataset.py β€” Scaffold (unused)
305
+ β”‚ β”œβ”€β”€ agents/ β€” To be built
306
+ β”‚ β”œβ”€β”€ search/ β€” To be built
307
+ β”‚ β”œβ”€β”€ sandbox/ β€” To be built
308
+ β”‚ β”œβ”€β”€ inference/ β€” To be built
309
+ β”‚ β”œβ”€β”€ evaluation/ β€” To be built
310
+ β”‚ └── utils/
311
+ β”œβ”€β”€ data/
312
+ β”‚ β”œβ”€β”€ raw/ β€” 10 source JSONL files (~2.4GB total)
313
+ β”‚ β”œβ”€β”€ processed/ β€” Filtered + split data (~10GB total)
314
+ β”‚ β”œβ”€β”€ tokenizer/
315
+ β”‚ β”‚ β”œβ”€β”€ base_tokenizer/ β€” Original Qwen tokenizer
316
+ β”‚ β”‚ └── mindi_tokenizer/ β€” Extended with 22 MINDI tokens
317
+ β”‚ └── knowledge_base/
318
+ β”œβ”€β”€ api/ β€” To be built
319
+ β”œβ”€β”€ frontend/ β€” To be built
320
+ β”œβ”€β”€ tests/ β€” To be built
321
+ β”œβ”€β”€ docs/
322
+ β”œβ”€β”€ logs/
323
+ └── checkpoints/
324
+
325
+
326
+ API KEYS & ACCOUNTS (from .env)
327
+ ================================
328
+ HuggingFace: Mindigenous account, token starts with hf_KK...
329
+ WandB: mindigenous entity, mindi-1.5-vision-coder project
330
+ Tavily: Web search API configured
331
+ E2B: Cloud sandbox API configured
332
+
333
+
334
+ WHAT COMES NEXT
335
+ ===============
336
+ - Day 4+: Spin up DigitalOcean MI300X droplet
337
+ - Run setup_mi300x.sh on the MI300X
338
+ - Start training: python scripts/train.py --phase 1
339
+ - Build agent system (src/agents/)
340
+ - Build inference pipeline (src/inference/)
341
+ - Build evaluation suite (src/evaluation/)
342
+ - Build API layer (api/)
343
+ - Build frontend (frontend/)
344
+
345
+
346
+ IMPORTANT NOTES
347
+ ===============
348
+ 1. ROCm on MI300X presents as CUDA β€” torch.cuda.* works normally
349
+ 2. MUST use bf16 not fp16 on MI300X (fp16 unstable on AMD)
350
+ 3. The MINDI tokenizer (data/tokenizer/mindi_tokenizer/) is what the
351
+ model uses, NOT the raw Qwen tokenizer
352
+ 4. WebSight and synthetic_nextjs are "protected sources" in quality
353
+ filter β€” they bypass length requirements
354
+ 5. The streaming dataset reads JSONL line-by-line to handle large files
355
+ 6. All HuggingFace repos are PRIVATE
356
+ 7. .env is git-ignored β€” never committed
357
+ ============================================================
358
+ END OF CONTEXT SUMMARY
359
+ ============================================================
setup_mi300x.sh CHANGED
@@ -23,15 +23,14 @@ echo "[1/7] Installing ROCm PyTorch (ROCm 6.0) ..."
23
  pip install torch torchvision torchaudio \
24
  --index-url https://download.pytorch.org/whl/rocm6.0
25
 
26
- # ── Step 2: Clone the full project from HF ────────────────────
27
  echo ""
28
- echo "[2/7] Cloning MINDI 1.5 from HuggingFace ..."
29
- if [ -d "MINDI-1.5-Vision-Coder" ]; then
30
- echo " Directory exists β€” pulling latest ..."
31
- cd MINDI-1.5-Vision-Coder
32
  git pull
33
  else
34
- git clone https://${HF_TOKEN}@huggingface.co/Mindigenous/MINDI-1.5-Vision-Coder
35
  cd MINDI-1.5-Vision-Coder
36
  fi
37
 
 
23
  pip install torch torchvision torchaudio \
24
  --index-url https://download.pytorch.org/whl/rocm6.0
25
 
26
+ # ── Step 2: Get the full project from HF ──────────────────────
27
  echo ""
28
+ echo "[2/7] Getting MINDI 1.5 from HuggingFace ..."
29
+ if [ -f "requirements.txt" ]; then
30
+ echo " Already in repo β€” pulling latest ..."
 
31
  git pull
32
  else
33
+ git clone https://Mindigenous:${HF_TOKEN}@huggingface.co/Mindigenous/MINDI-1.5-Vision-Coder
34
  cd MINDI-1.5-Vision-Coder
35
  fi
36