Official Codebase of 3DCodeVerse
Python
finetune: index the configs, retire 51 generated and superseded files
gaoypeng81a618e737d4
diff --git a/finetune/configs/README.md b/finetune/configs/README.mdnew file mode 100644index 00000000..caa555ee--- /dev/null+++ b/finetune/configs/README.md@@ -0,0 +1,156 @@+# `configs/` — what is in here and which files matter++Every training run in this project is one YAML consumed by unmodified+[LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) (upstream `c4e09c7`, 0.9.6.dev0).+There is no custom trainer. If you want to reproduce a number from+[`docs/REPORT.md`](../docs/REPORT.md) or the results table in+[`llm_finetune_exps.md`](../llm_finetune_exps.md), you need exactly one file from here.++**Start with the eight configs in [§1](#1-the-configs-that-produced-the-headline-models).** Everything+else is an ablation, a failed branch, or a disposable merge recipe.++---++## 0. How one experiment flows++```+configs/lf/lora_<name>.yaml ──lf_train.sh──▶ runs/lf_<model>_<name>/ (adapter + train_results.json)+configs/lf/export_<name>.yaml ──lf_export.sh─▶ runs/lf_<model>_<name>/merged/ (adapter merged into the base)+ │+ eval/eval_all_run2.sh ──▶ eval/out/<tag>/summary.json+```++* `scripts/lf_train.sh <cfg>` — train. `GPUS=0,1,2,3` selects devices; extra `key=value` args override the YAML.+* `scripts/lf_export.sh <cfg>` — merge a LoRA adapter into its base model so vLLM can load it.+* `eval/eval_all_run2.sh <merged_dir> <tag>` — run all six dialect suites. **This is the current evaluator**;+ `eval/eval_all.sh` is the older one, kept only because `scripts/run_27b.sh` still calls it.++## Naming scheme++```+lora_[<base>_]<experiment>.yaml SFT. No base tag = Qwen3.5-9B. `27b_` = Qwen3.8-27B. `9b_` is used+ on the later 9B runs once 27B runs existed and the prefix stopped being implicit.+dpo_<experiment>.yaml Preference tuning on top of an already-merged SFT model.+export_<experiment>.yaml Merge recipe: which adapter, into which base, to which directory.+full_*.yaml / qwen35_9b_full_*.yaml Full-parameter SFT (no LoRA).+```++The `<experiment>` suffix is stable across the three families: `lora_md_xl.yaml` trains it,+`export_md_xl.yaml` merges it, `dpo_geo_md_xl.yaml` tunes it further. The run directory is+`runs/lf_qwen35_9b_<experiment>` (9B) or `runs/lf_qwen38_27b_<experiment>` (27B).++---++## 1. The configs that produced the headline models++Numbers are 3DCodeBench exec-rate / [email protected](all) unless noted; full table in+[`llm_finetune_exps.md`](../llm_finetune_exps.md) §0.++| config | base | what it is | result |+|---|---|---|---|+| **`lora_27b_v2.yaml`** | 27B | 6-dialect LoRA, 104k pairs, Blender raised to 40% + 15.7k execution-verified bootstrapped samples | **93.4% / 0.380** — best geometric fidelity anywhere (Blender [email protected] 0.890, Chamfer 0.049) |+| **`dpo_27b.yaml`** | ← that, merged | execution-feedback DPO, 756 pairs | three.js 92.5% → **100%**, OpenSCAD +2, GLSL +2, 3DCodeBench −1.9 |+| **`lora_md_xl.yaml`** | 9B | 6-dialect LoRA, 270k pairs — the largest 9B mix | 90.1% / 0.346; **CadQuery 97.5%**, the best of any model |+| **`dpo_geo_md_xl.yaml`** | ← that, merged | geometry-feedback DPO (pairs ranked by F-score) | first lever that moved *fidelity*: Blender [email protected](ok) 0.387 → **0.800**, Chamfer −12% |+| **`lora_v1.yaml`** | 9B | the first run: LoRA on 5.2k Blender samples | 0% → 75–82%. The single biggest jump in the project |+| **`dpo_exec_v1.yaml`** → **`dpo_exec_v2.yaml`** | ← that, merged | two rounds of execution-feedback DPO | 75% → 93.9% → **96.2%**, the highest executability reached |+| **`lora_md_big.yaml`** + `dpo_md_big.yaml` | 9B | 102k-pair mix, then DPO | 84.9%; the mid-size point on the data-scaling curve |+| **`lora_27b_v3.yaml`** | 27B | CadQuery doubled (36k→65k), rank 32, cutoff 3072 | **negative result worth keeping**: CadQuery flat (86.5→85.0) and every other suite got worse |++Two configs record the results that stopped a line of work, and are worth reading before repeating it:+`lora_md_max_9b.yaml` (caption augmentation — 90.1% → 34.4% at equal token budget) and+`qwen35_9b_full_sft.yaml` / `full_md_bal.yaml` (full-parameter FT — equal to LoRA at 3× the memory).++## 2. The families++### `lora_*.yaml` — 52 files, supervised finetuning++One per experiment, each with a `runs/` directory. They fall into groups:++* **`lora_v1` … `lora_v13_boot`** — the 9B Blender-only ladder: repeats (`v1_rep`), in-distribution data+ (`v2_indist`, `v2b_indist16k`), other sources (`v3_bio`, `v4_cq`), prompt style (`v5_instr`, `v6_detail`),+ hyperparameters (`v7_ep4`, `v8_r16`, `v9_lr2e4`), other bases (`v10_4b`, `v12_qwen3_8b`), and+ self-training (`v11_selftrain`, `v11b_selfprompts`, `v13_boot`).+* **`lora_md_*`** — the six-dialect mixes, in size order `md_mixed` (26k) → `md_big` (102k) → `md_xl` (270k),+ plus single-dialect probes (`md_blender`, `md_cadquery`, `md_glsl`, `md_openscad`, `md_threejs`) and+ rebalancing attempts (`md_bal`, `md_max_9b`, `md_v3`).+* **`lora_9b_*`** — the later 9B work: leakage control (`noleak`, `clean`), learning-rate sweep+ (`bal_lr1e4`, `bal_lr3e5`), multimodal (`mm_img`, `mm_text`, `mm_img_text`, `mm1_img_text`, `mmvis`,+ `mmmix2`, `img`, `img4`, `imgmix`), and full-parameter (`full`, `full_resume`).+* **`lora_27b_*`** — the 27B line: `md_z3` / `ddp` (ZeRO-3 vs DDP — DDP is 7.8× faster for LoRA),+ then `v2` … `v5`, `clean`, `mm_img_text`.++### `dpo_*.yaml` — 10 files, preference tuning++Always applied on top of an already-merged SFT model (`model_name_or_path` points at a `runs/*/merged`+directory, not at a base model). Three kinds, distinguished by how the preference pairs were built:++* **execution feedback** — sample K completions, run them, pair (OK, FAIL): `dpo_exec_v1`, `dpo_exec_v2`,+ `dpo_md_mixed`, `dpo_md_big`, `dpo_md_xl`, `dpo_27b`.+* **geometry feedback** — pairs ranked by F-score against the ground-truth mesh: `dpo_geo_md_xl`.+* **stop-token / truncation repair** — `dpo_stop`, `dpo_stop_r2`, `dpo_best_stop`.++### `export_*.yaml` — 34 files, disposable merge recipes++**These are generated artefacts, not authored configs.** Each is `export_lora_template.yaml` with three+lines rewritten by `sed` inside the runner script that needs it, e.g. in `scripts/run_27b_v3.sh`:++```bash+sed -e "s|model_name_or_path:.*|model_name_or_path: /wekafs/.../Qwen3.8-27B|" \+ -e "s|adapter_name_or_path:.*|adapter_name_or_path: $(readlink -f $RUN)|" \+ -e "s|export_dir:.*|export_dir: $(readlink -f $RUN)/merged|" \+ configs/lf/export_lora_template.yaml > configs/lf/export_27b_v3.yaml+```++They carry no experimental information beyond "which adapter was merged where" — which the run directory+name already tells you. Any of them can be recreated by re-running its script.+The 34 kept here are the ones still named by a script; **`export_lora_template.yaml` must never be+deleted** — 49 scripts derive their merge config from it.++A few export configs are read by a script that does *not* also write them (`export_v1.yaml`,+`export_v6_detail.yaml`, `export_md_xl.yaml`, `export_md_mixed.yaml`, `export_md_big.yaml`,+`export_md_threejs.yaml`, `export_27b_max.yaml`, `export_27b_v2.yaml`, `export_dpo_exec_v1_r2.yaml`,+`export_dpo_exec_v2.yaml`, `export_9b_full.yaml`). Deleting one of those *does* break its caller.++### Other files++| file | purpose |+|---|---|+| `ds_zero2.json`, `ds_zero3.json`, `lf/ds_z3_offload.json` | DeepSpeed stage configs. `ds_z3_offload.json` is the 2-GPU fallback (ZeRO-3 + CPU optimizer offload) used by the full-FT scripts. |+| `qwen35_9b_full_sft{,_3gpu,_4gpu}.yaml`, `full_md_bal.yaml` | full-parameter SFT, 1/3/4-GPU variants |+| `qwen35_9b_lora_sft.yaml` | the original hand-written LoRA config; superseded by `lora_v1.yaml` but referenced by `README.md` and `scripts/after_lora_v2.sh` |+| `qwen35_9b_preprocess.yaml` | tokenise-and-cache only, no training |++### `lf/archive/` — 42 unreferenced generated export configs++Merge recipes for experiments that are finished, whose script no longer names them. Kept rather than+deleted because they are the only record of *which checkpoint step* was merged in the two checkpoint+sweeps (`export_md_xl_ck450` … `ck3600`, `export_md_big_ck2200` … `ck3292`). Nothing reads them; they are+safe to delete outright if the folder ever needs to shrink again.++---++## 3. Known quirks++* **`overwrite_output_dir` is set to a path instead of `true`** in `dpo_27b`, `dpo_exec_v2`, `dpo_md_big`,+ `dpo_md_mixed`, `dpo_md_xl`. LLaMA-Factory reads it as truthy so the runs behaved as intended, but the+ value is meaningless — do not copy it into a new config.+* **Six configs point at `runs/*/merged` directories that no longer exist** (`dpo_md_big`, `dpo_md_mixed`,+ `dpo_md_xl` and their `export_dpo_*` counterparts). The merged models were deleted to reclaim disk. This+ is handled: each caller re-creates the merge first, e.g.+ `[ -d $BASE ] || scripts/lf_export.sh configs/lf/export_md_big.yaml`.+* **`scripts/run_27b_v2.sh` does not train `lora_27b_v2.yaml`.** It trains `lora_27b_ddp.yaml` into+ `runs/lf_qwen38_27b_lora_md_max`. The config called `v2` is trained by **`scripts/run_27b_v2b.sh`**.+* **`export_9b_full.yaml` and `export_mmvis.yaml` are named by scripts but absent** from this directory.+ Both are written by their own script before use, so this is harmless.+* Configs are near-identical by design: every `export_*` differs from its siblings in 2 lines, and+ `lora_v1` / `lora_v1_rep` / `lora_v7_ep4` / `lora_v9_lr2e4` differ in 1–2 hyperparameters. That is the+ point — one variable per experiment.++## 4. Editing rules++1. **Never edit a config while a job is reading it.** Check `pgrep -af llamafactory-cli` first. The same+ applies doubly to shell scripts: bash reads a script incrementally as it executes, so editing a running+ one corrupts it mid-run. This has already broken two evaluations in this project.+2. New experiment = new file. Do not mutate an existing config — it is the record of a run in `runs/`.+3. Do not hand-write an `export_*.yaml`. Copy the `sed` block from a neighbouring runner script.diff --git a/finetune/configs/lf/export_9b_mm1_img_text.yaml b/finetune/configs/lf/archive/export_9b_mm1_img_text.yamlsimilarity index 100%rename from finetune/configs/lf/export_9b_mm1_img_text.yamlrename to finetune/configs/lf/archive/export_9b_mm1_img_text.yamldiff --git a/finetune/configs/lf/export_bal_lr1e4.yaml b/finetune/configs/lf/archive/export_bal_lr1e4.yamlsimilarity index 100%rename from finetune/configs/lf/export_bal_lr1e4.yamlrename to finetune/configs/lf/archive/export_bal_lr1e4.yamldiff --git a/finetune/configs/lf/export_md_bal.yaml b/finetune/configs/lf/archive/export_md_bal.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_bal.yamlrename to finetune/configs/lf/archive/export_md_bal.yamldiff --git a/finetune/configs/lf/export_md_big_ck2200.yaml b/finetune/configs/lf/archive/export_md_big_ck2200.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck2200.yamlrename to finetune/configs/lf/archive/export_md_big_ck2200.yamldiff --git a/finetune/configs/lf/export_md_big_ck2420.yaml b/finetune/configs/lf/archive/export_md_big_ck2420.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck2420.yamlrename to finetune/configs/lf/archive/export_md_big_ck2420.yamldiff --git a/finetune/configs/lf/export_md_big_ck2640.yaml b/finetune/configs/lf/archive/export_md_big_ck2640.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck2640.yamlrename to finetune/configs/lf/archive/export_md_big_ck2640.yamldiff --git a/finetune/configs/lf/export_md_big_ck2860.yaml b/finetune/configs/lf/archive/export_md_big_ck2860.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck2860.yamlrename to finetune/configs/lf/archive/export_md_big_ck2860.yamldiff --git a/finetune/configs/lf/export_md_big_ck3080.yaml b/finetune/configs/lf/archive/export_md_big_ck3080.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck3080.yamlrename to finetune/configs/lf/archive/export_md_big_ck3080.yamldiff --git a/finetune/configs/lf/export_md_big_ck3292.yaml b/finetune/configs/lf/archive/export_md_big_ck3292.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_big_ck3292.yamlrename to finetune/configs/lf/archive/export_md_big_ck3292.yamldiff --git a/finetune/configs/lf/export_md_blender.yaml b/finetune/configs/lf/archive/export_md_blender.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_blender.yamlrename to finetune/configs/lf/archive/export_md_blender.yamldiff --git a/finetune/configs/lf/export_md_cadquery.yaml b/finetune/configs/lf/archive/export_md_cadquery.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_cadquery.yamlrename to finetune/configs/lf/archive/export_md_cadquery.yamldiff --git a/finetune/configs/lf/export_md_glsl.yaml b/finetune/configs/lf/archive/export_md_glsl.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_glsl.yamlrename to finetune/configs/lf/archive/export_md_glsl.yamldiff --git a/finetune/configs/lf/export_md_openscad.yaml b/finetune/configs/lf/archive/export_md_openscad.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_openscad.yamlrename to finetune/configs/lf/archive/export_md_openscad.yamldiff --git a/finetune/configs/lf/export_md_xl_ck1350.yaml b/finetune/configs/lf/archive/export_md_xl_ck1350.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck1350.yamlrename to finetune/configs/lf/archive/export_md_xl_ck1350.yamldiff --git a/finetune/configs/lf/export_md_xl_ck1800.yaml b/finetune/configs/lf/archive/export_md_xl_ck1800.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck1800.yamlrename to finetune/configs/lf/archive/export_md_xl_ck1800.yamldiff --git a/finetune/configs/lf/export_md_xl_ck2250.yaml b/finetune/configs/lf/archive/export_md_xl_ck2250.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck2250.yamlrename to finetune/configs/lf/archive/export_md_xl_ck2250.yamldiff --git a/finetune/configs/lf/export_md_xl_ck2700.yaml b/finetune/configs/lf/archive/export_md_xl_ck2700.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck2700.yamlrename to finetune/configs/lf/archive/export_md_xl_ck2700.yamldiff --git a/finetune/configs/lf/export_md_xl_ck3150.yaml b/finetune/configs/lf/archive/export_md_xl_ck3150.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck3150.yamlrename to finetune/configs/lf/archive/export_md_xl_ck3150.yamldiff --git a/finetune/configs/lf/export_md_xl_ck3600.yaml b/finetune/configs/lf/archive/export_md_xl_ck3600.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck3600.yamlrename to finetune/configs/lf/archive/export_md_xl_ck3600.yamldiff --git a/finetune/configs/lf/export_md_xl_ck450.yaml b/finetune/configs/lf/archive/export_md_xl_ck450.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck450.yamlrename to finetune/configs/lf/archive/export_md_xl_ck450.yamldiff --git a/finetune/configs/lf/export_md_xl_ck900.yaml b/finetune/configs/lf/archive/export_md_xl_ck900.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_ck900.yamlrename to finetune/configs/lf/archive/export_md_xl_ck900.yamldiff --git a/finetune/configs/lf/export_md_xl_geo.yaml b/finetune/configs/lf/archive/export_md_xl_geo.yamlsimilarity index 100%rename from finetune/configs/lf/export_md_xl_geo.yamlrename to finetune/configs/lf/archive/export_md_xl_geo.yamldiff --git a/finetune/configs/lf/export_mm_img.yaml b/finetune/configs/lf/archive/export_mm_img.yamlsimilarity index 100%rename from finetune/configs/lf/export_mm_img.yamlrename to finetune/configs/lf/archive/export_mm_img.yamldiff --git a/finetune/configs/lf/export_mm_img_text.yaml b/finetune/configs/lf/archive/export_mm_img_text.yamlsimilarity index 100%rename from finetune/configs/lf/export_mm_img_text.yamlrename to finetune/configs/lf/archive/export_mm_img_text.yamldiff --git a/finetune/configs/lf/export_mm_text.yaml b/finetune/configs/lf/archive/export_mm_text.yamlsimilarity index 100%rename from finetune/configs/lf/export_mm_text.yamlrename to finetune/configs/lf/archive/export_mm_text.yamldiff --git a/finetune/configs/lf/export_v10_4b.yaml b/finetune/configs/lf/archive/export_v10_4b.yamlsimilarity index 100%rename from finetune/configs/lf/export_v10_4b.yamlrename to finetune/configs/lf/archive/export_v10_4b.yamldiff --git a/finetune/configs/lf/export_v11_selftrain.yaml b/finetune/configs/lf/archive/export_v11_selftrain.yamlsimilarity index 100%rename from finetune/configs/lf/export_v11_selftrain.yamlrename to finetune/configs/lf/archive/export_v11_selftrain.yamldiff --git a/finetune/configs/lf/export_v11b_selfprompts.yaml b/finetune/configs/lf/archive/export_v11b_selfprompts.yamlsimilarity index 100%rename from finetune/configs/lf/export_v11b_selfprompts.yamlrename to finetune/configs/lf/archive/export_v11b_selfprompts.yamldiff --git a/finetune/configs/lf/export_v12_qwen3_8b.yaml b/finetune/configs/lf/archive/export_v12_qwen3_8b.yamlsimilarity index 100%rename from finetune/configs/lf/export_v12_qwen3_8b.yamlrename to finetune/configs/lf/archive/export_v12_qwen3_8b.yamldiff --git a/finetune/configs/lf/export_v13_boot.yaml b/finetune/configs/lf/archive/export_v13_boot.yamlsimilarity index 100%rename from finetune/configs/lf/export_v13_boot.yamlrename to finetune/configs/lf/archive/export_v13_boot.yamldiff --git a/finetune/configs/lf/export_v1_ckpt100.yaml b/finetune/configs/lf/archive/export_v1_ckpt100.yamlsimilarity index 100%rename from finetune/configs/lf/export_v1_ckpt100.yamlrename to finetune/configs/lf/archive/export_v1_ckpt100.yamldiff --git a/finetune/configs/lf/export_v1_rep.yaml b/finetune/configs/lf/archive/export_v1_rep.yamlsimilarity index 100%rename from finetune/configs/lf/export_v1_rep.yamlrename to finetune/configs/lf/archive/export_v1_rep.yamldiff --git a/finetune/configs/lf/export_v2_indist.yaml b/finetune/configs/lf/archive/export_v2_indist.yamlsimilarity index 100%rename from finetune/configs/lf/export_v2_indist.yamlrename to finetune/configs/lf/archive/export_v2_indist.yamldiff --git a/finetune/configs/lf/export_v2b_indist16k.yaml b/finetune/configs/lf/archive/export_v2b_indist16k.yamlsimilarity index 100%rename from finetune/configs/lf/export_v2b_indist16k.yamlrename to finetune/configs/lf/archive/export_v2b_indist16k.yamldiff --git a/finetune/configs/lf/export_v3_bio.yaml b/finetune/configs/lf/archive/export_v3_bio.yamlsimilarity index 100%rename from finetune/configs/lf/export_v3_bio.yamlrename to finetune/configs/lf/archive/export_v3_bio.yamldiff --git a/finetune/configs/lf/export_v3_bio_ckpt100.yaml b/finetune/configs/lf/archive/export_v3_bio_ckpt100.yamlsimilarity index 100%rename from finetune/configs/lf/export_v3_bio_ckpt100.yamlrename to finetune/configs/lf/archive/export_v3_bio_ckpt100.yamldiff --git a/finetune/configs/lf/export_v3_bio_ckpt50.yaml b/finetune/configs/lf/archive/export_v3_bio_ckpt50.yamlsimilarity index 100%rename from finetune/configs/lf/export_v3_bio_ckpt50.yamlrename to finetune/configs/lf/archive/export_v3_bio_ckpt50.yamldiff --git a/finetune/configs/lf/export_v4_cq.yaml b/finetune/configs/lf/archive/export_v4_cq.yamlsimilarity index 100%rename from finetune/configs/lf/export_v4_cq.yamlrename to finetune/configs/lf/archive/export_v4_cq.yamldiff --git a/finetune/configs/lf/export_v5_instr.yaml b/finetune/configs/lf/archive/export_v5_instr.yamlsimilarity index 100%rename from finetune/configs/lf/export_v5_instr.yamlrename to finetune/configs/lf/archive/export_v5_instr.yamldiff --git a/finetune/configs/lf/export_v7_ep4.yaml b/finetune/configs/lf/archive/export_v7_ep4.yamlsimilarity index 100%rename from finetune/configs/lf/export_v7_ep4.yamlrename to finetune/configs/lf/archive/export_v7_ep4.yamldiff --git a/finetune/configs/lf/export_v8_r16.yaml b/finetune/configs/lf/archive/export_v8_r16.yamlsimilarity index 100%rename from finetune/configs/lf/export_v8_r16.yamlrename to finetune/configs/lf/archive/export_v8_r16.yamldiff --git a/finetune/configs/lf/export_v9_lr2e4.yaml b/finetune/configs/lf/archive/export_v9_lr2e4.yamlsimilarity index 100%rename from finetune/configs/lf/export_v9_lr2e4.yamlrename to finetune/configs/lf/archive/export_v9_lr2e4.yamldiff --git a/finetune/configs/lf/dpo_best_stop.yaml b/finetune/configs/lf/dpo_best_stop.yamlnew file mode 100644index 00000000..fe9ca378--- /dev/null+++ b/finetune/configs/lf/dpo_best_stop.yaml@@ -0,0 +1,42 @@+### DPO with execution-feedback preference pairs, on top of LoRA-v1 (merged)+model_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_dpo_exec_v2/merged+trust_remote_code: true+flash_attn: fa2+stage: dpo+do_train: true+finetuning_type: lora+lora_rank: 16+lora_alpha: 32+lora_dropout: 0.05+lora_target: all+freeze_vision_tower: true+freeze_multi_modal_projector: true+pref_beta: 0.1+pref_loss: sigmoid+dataset_dir: /wekafs/ict/hx_624/llm-ft/data/lf+dataset: stop_dpo_pairs+template: qwen3_5+enable_thinking: false+cutoff_len: 2048+preprocessing_num_workers: 16+dataloader_num_workers: 2+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_best_stop+logging_steps: 5+save_steps: 1000+save_only_model: true+plot_loss: true+overwrite_output_dir: true+report_to: tensorboard+per_device_train_batch_size: 1+gradient_accumulation_steps: 8+learning_rate: 5.0e-6+num_train_epochs: 2.0+lr_scheduler_type: cosine+warmup_ratio: 0.1+bf16: true+gradient_checkpointing: true+ddp_timeout: 180000000+val_size: 0.02+per_device_eval_batch_size: 1+eval_strategy: steps+eval_steps: 100diff --git a/finetune/configs/lf/dpo_stop.yaml b/finetune/configs/lf/dpo_stop.yamlindex fe0a66ae..20b73652 100644--- a/finetune/configs/lf/dpo_stop.yaml+++ b/finetune/configs/lf/dpo_stop.yaml@@ -17,7 +17,7 @@ dataset_dir: /wekafs/ict/hx_624/llm-ft/data/lfdataset: stop_dpo_pairstemplate: qwen3_5enable_thinking: false-cutoff_len: 4096+cutoff_len: 2048preprocessing_num_workers: 16dataloader_num_workers: 2output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpodiff --git a/finetune/configs/lf/dpo_stop_r2.yaml b/finetune/configs/lf/dpo_stop_r2.yamlnew file mode 100644index 00000000..e193045e--- /dev/null+++ b/finetune/configs/lf/dpo_stop_r2.yaml@@ -0,0 +1,42 @@+### DPO with execution-feedback preference pairs, on top of LoRA-v1 (merged)+model_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo/merged+trust_remote_code: true+flash_attn: fa2+stage: dpo+do_train: true+finetuning_type: lora+lora_rank: 16+lora_alpha: 32+lora_dropout: 0.05+lora_target: all+freeze_vision_tower: true+freeze_multi_modal_projector: true+pref_beta: 0.1+pref_loss: sigmoid+dataset_dir: /wekafs/ict/hx_624/llm-ft/data/lf+dataset: stop_dpo_pairs_r2+template: qwen3_5+enable_thinking: false+cutoff_len: 4096+preprocessing_num_workers: 16+dataloader_num_workers: 2+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo_r2+logging_steps: 5+save_steps: 1000+save_only_model: true+plot_loss: true+overwrite_output_dir: true+report_to: tensorboard+per_device_train_batch_size: 1+gradient_accumulation_steps: 8+learning_rate: 5.0e-6+num_train_epochs: 2.0+lr_scheduler_type: cosine+warmup_ratio: 0.1+bf16: true+gradient_checkpointing: true+ddp_timeout: 180000000+val_size: 0.02+per_device_eval_batch_size: 1+eval_strategy: steps+eval_steps: 100diff --git a/finetune/configs/lf/export_best_stop.yaml b/finetune/configs/lf/export_best_stop.yamlnew file mode 100644index 00000000..aed922bf--- /dev/null+++ b/finetune/configs/lf/export_best_stop.yaml@@ -0,0 +1,12 @@+### Merge a LoRA adapter into the base model (LLaMA-Factory): llamafactory-cli export <this file>+model_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_dpo_exec_v2/merged+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_best_stop+template: qwen3_5+enable_thinking: false+trust_remote_code: true+finetuning_type: lora++export_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_best_stop/merged+export_size: 5+export_device: cpu+export_legacy_format: falsediff --git a/finetune/configs/lf/export_stopdpo_r2.yaml b/finetune/configs/lf/export_stopdpo_r2.yamlnew file mode 100644index 00000000..8fa21d26--- /dev/null+++ b/finetune/configs/lf/export_stopdpo_r2.yaml@@ -0,0 +1,12 @@+### Merge a LoRA adapter into the base model (LLaMA-Factory): llamafactory-cli export <this file>+model_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo/merged+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo_r2+template: qwen3_5+enable_thinking: false+trust_remote_code: true+finetuning_type: lora++export_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo_r2/merged+export_size: 5+export_device: cpu+export_legacy_format: falsediff --git a/finetune/configs/lf/lora_9b_full_resume.yaml b/finetune/configs/lf/lora_9b_full_resume.yamlnew file mode 100644index 00000000..9827b215--- /dev/null+++ b/finetune/configs/lf/lora_9b_full_resume.yaml@@ -0,0 +1,44 @@+model_name_or_path: /wekafs/ict/hx_624/models/Qwen3.5-9B+trust_remote_code: true+flash_attn: fa2+stage: sft+do_train: true+finetuning_type: lora+lora_rank: 64+lora_alpha: 128+lora_dropout: 0.05+lora_target: all+freeze_vision_tower: true+freeze_multi_modal_projector: true+dataset_dir: /wekafs/ict/hx_624/llm-ft/data/full9b+dataset: 3dcv_mm_img_text_train,3dcv_mm_img_train,md_full9b_train+eval_dataset: 3dcv_mm_img_text_val+template: qwen3_5+enable_thinking: false+cutoff_len: 8192+preprocessing_num_workers: 16+dataloader_num_workers: 16+neat_packing: false+packing: false+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_full9b_len8192+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_full+logging_steps: 5+save_steps: 600+save_only_model: true+plot_loss: true+overwrite_output_dir: true+report_to: tensorboard+per_device_train_batch_size: 1+gradient_accumulation_steps: 7+learning_rate: 0.0001+num_train_epochs: 1.0+lr_scheduler_type: cosine+warmup_ratio: 0.05+bf16: true+gradient_checkpointing: true+ddp_timeout: 180000000+resume_from_checkpoint: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_full/checkpoint-4200+per_device_eval_batch_size: 1+eval_strategy: steps+eval_steps: 600+save_total_limit: 4diff --git a/finetune/scripts/README.md b/finetune/scripts/README.mdnew file mode 100644index 00000000..9c0da89f--- /dev/null+++ b/finetune/scripts/README.md@@ -0,0 +1,62 @@+# `scripts/` — index++88 shell scripts and 32 Python scripts. Most are **one-off runners**: a single experiment's+"train → merge → evaluate" recipe, kept so the run in `runs/` can be reproduced. You almost never need to+read one unless you are reproducing that specific experiment.++The files below are the ones that are actually infrastructure.++## The five you will use++| script | what it does |+|---|---|+| `lf_train.sh <cfg> [k=v ...]` | train. `GPUS=0,1,2,3` picks devices; extra `key=value` args override the YAML. Called by 53 other scripts. |+| `lf_export.sh <cfg>` | merge a LoRA adapter into its base so vLLM can load it. Called by 57 other scripts. |+| `free_gpus.sh [min_free_mb]` | list GPUs with enough free memory. The scheduling primitive everything waits on. |+| `supervisor2.sh` | the job queue. Reads `queue.txt` (`<label>\|<command>` per line), runs one job at a time when the GPUs are free, records completions in `logs/.supervisor_done`, logs to `logs/supervisor.log`. |+| `sync_repo.sh ["msg"]` | mirror `scripts/ configs/ eval/` + docs into `repos/3dcodeverse/finetune/` and push. |++`queue.txt` is the live work list — append a line to schedule a job; `supervisor2.sh` picks it up.++## Runner naming++```+run_<model>_<experiment>.sh train + merge + evaluate one experiment end to end+run_exp*.sh, run_md_exp.sh parameterised runners: pass an experiment name, they generate the config+*_dpo_round.sh build preference pairs by executing samples, then DPO, then evaluate+*_ckpt_sweep.sh merge and evaluate every checkpoint of one run+eval_*.sh, *_eval.sh evaluation only, against an already-merged model+build_*.py dataset construction (see `docs/REPORT.md` §2)+```++Generation of a merge config is inlined in each runner as a `sed` over+`configs/lf/export_lora_template.yaml` — see [`configs/README.md`](../configs/README.md) §2.++## Two pairs that look like duplicates++* **`supervisor2.sh` supersedes `archive/supervisor.sh`.** Identical except that `supervisor2.sh`+ re-checks the done-list after its GPU wait, which can last hours. Without that check a job whose+ label was completed by another process meanwhile got run a second time (this happened to+ `mm_multisuite`). Use `supervisor2.sh`.+* **`eval/eval_all_run2.sh` supersedes `eval/eval_all.sh`** and is what all 20 current callers use.+ `eval_all.sh` is kept only because `run_27b.sh` still names it, and because `docs/REPORT.md` quotes it+ when reporting the zero-shot baselines. The two differ by one comment line; they are functionally+ identical.++## `archive/`++Nine scripts, referenced by nothing and superseded:++* `supervisor.sh` — see above.+* `after_lora.sh` — superseded by `after_lora_v2.sh` (vLLM merge-and-eval path with an HF fallback).+ `logs/after_lora.log` is 0 bytes: it never produced output.+* `explore_sched.sh` — the first 8-hour scheduling plan, replaced by `explore_sched2.sh` the same day+ when GPU availability changed. `logs/explore_sched.log` is 0 bytes; `explore_sched2.log` is not.+* `run_full_ft2.sh` … `run_full_ft7.sh` — six successive one-off edits of `run_full_ft.sh`, each changing+ only which log line it waits for before starting. They produced no run of their own.++## Do not edit a running script++Bash reads a script incrementally *as it executes it*, so editing one mid-run corrupts the run. This has+already broken two 9B evaluations in this project. Check `pgrep -af 'scripts/'` before touching anything,+and copy to a new filename instead of editing in place.diff --git a/finetune/scripts/after_lora.sh b/finetune/scripts/archive/after_lora.shsimilarity index 100%rename from finetune/scripts/after_lora.shrename to finetune/scripts/archive/after_lora.shdiff --git a/finetune/scripts/explore_sched.sh b/finetune/scripts/archive/explore_sched.shsimilarity index 100%rename from finetune/scripts/explore_sched.shrename to finetune/scripts/archive/explore_sched.shdiff --git a/finetune/scripts/run_full_ft2.sh b/finetune/scripts/archive/run_full_ft2.shsimilarity index 100%rename from finetune/scripts/run_full_ft2.shrename to finetune/scripts/archive/run_full_ft2.shdiff --git a/finetune/scripts/run_full_ft3.sh b/finetune/scripts/archive/run_full_ft3.shsimilarity index 100%rename from finetune/scripts/run_full_ft3.shrename to finetune/scripts/archive/run_full_ft3.shdiff --git a/finetune/scripts/run_full_ft4.sh b/finetune/scripts/archive/run_full_ft4.shsimilarity index 100%rename from finetune/scripts/run_full_ft4.shrename to finetune/scripts/archive/run_full_ft4.shdiff --git a/finetune/scripts/run_full_ft5.sh b/finetune/scripts/archive/run_full_ft5.shsimilarity index 100%rename from finetune/scripts/run_full_ft5.shrename to finetune/scripts/archive/run_full_ft5.shdiff --git a/finetune/scripts/run_full_ft6.sh b/finetune/scripts/archive/run_full_ft6.shsimilarity index 100%rename from finetune/scripts/run_full_ft6.shrename to finetune/scripts/archive/run_full_ft6.shdiff --git a/finetune/scripts/run_full_ft7.sh b/finetune/scripts/archive/run_full_ft7.shsimilarity index 100%rename from finetune/scripts/run_full_ft7.shrename to finetune/scripts/archive/run_full_ft7.shdiff --git a/finetune/scripts/supervisor.sh b/finetune/scripts/archive/supervisor.shsimilarity index 100%rename from finetune/scripts/supervisor.shrename to finetune/scripts/archive/supervisor.shdiff --git a/finetune/scripts/build_pairs_3dcodebench.py b/finetune/scripts/build_pairs_3dcodebench.pynew file mode 100644index 00000000..fa204655--- /dev/null+++ b/finetune/scripts/build_pairs_3dcodebench.py@@ -0,0 +1,208 @@+"""Build all three pair types for a 3DCodeVerse subdirectory: text->code, image->code, image+text->code.++The corpus so far only carries text->code, and its row count is inflated ~3x because every caption variant is a+separate row -- an augmentation three independent runs showed does not help. Here each SAMPLE appears once per+pair type with one caption, and the renders come from the sample's own slice of the tar (metadata carries+`tar`/`byte_start`/`byte_len`, so a ranged read fetches one sample without downloading a 2 GB shard).++ python scripts/build_pairs_3dcodebench.py --subdir 3dcodebench/factories_geo --out DIR [--views 4] [--workers 8]+ [--limit N] [--local_tars DIR]++Writes <out>/<name>_{text,img,imgtext}/train.parquet + dataset_info.json + qc.json.+"""+import argparse+import collections+import io+import json+import os+import tarfile+import time++import pandas as pd+import pyarrow.parquet as pq+import requests++META = "/wekafs/ict/hx_624/data/3dcodeverse_meta"+REPO = "ilabai/3dcodeverse"+SYS = {+ "blender": "You are an expert in procedural 3D modeling with Blender Python (bpy). Write a complete, standalone Blender 5 Python script that builds the requested object from scratch (clear the default scene first). Output ONLY the code in one ```python block.",+ "glsl": "You are an expert GLSL shader programmer. Write a complete Shadertoy-style fragment shader. Output ONLY the code in one ```glsl block.",+}+FENCE = {"blender": "python", "glsl": "glsl"}+ASK_TEXT = {"blender": "Write the Blender Python code that builds this object: ",+ "glsl": "Write the shader described here: "}+ASK_IMG = {"blender": "These are reference renders of one object. Write the Blender Python code that builds it.",+ "glsl": "These are frames rendered by one shader. Write the shader that produces them."}+ASK_BOTH = {"blender": "These are reference renders of one object. Write the Blender Python code that builds it.\n\nThe object: ",+ "glsl": "These are frames rendered by one shader. Write the shader that produces them.\n\nThe shader: "}+IMPERATIVE = ("write", "create", "implement", "make", "build", "generate", "design", "produce")+++def caption_of(caps):+ """the best human description, reduced to a noun phrase because the ASK_* strings already supply the verb"""+ for k in ("user_instruction", "instruction", "detailed", "brief", "factory"):+ v = (caps.get(k) or "").strip()+ if not v or len(v) < 15:+ continue+ low = v.lower()+ if low.startswith(IMPERATIVE):+ for sep in (" that builds ", " that renders ", " that reproduces ", " of ", " for "):+ if sep in low:+ return v[low.index(sep) + len(sep):].strip()[:1200]+ continue+ return v[:1200]+ return None+++def fetch_sample(row, token, local_tars=None):+ """-> list of render bytes for one sample, via a local tar if we have it, else a ranged read"""+ tar_rel, start, length = row["tar"], int(row["byte_start"]), int(row["byte_len"])+ if local_tars:+ p = os.path.join(local_tars, os.path.basename(tar_rel))+ if os.path.exists(p):+ with open(p, "rb") as f:+ f.seek(start)+ blob = f.read(length)+ return read_renders(blob)+ url = f"https://huggingface.co/datasets/{REPO}/resolve/main/{tar_rel}"+ hdr = {"Authorization": f"Bearer {token}", "Range": f"bytes={start}-{start + length - 1}"}+ # under a dozen concurrent readers the Hub throttles and times out; returning [] on the first failure looks+ # exactly like "this sample has no renders", which silently cost 70% of the image pairs on the first run+ for attempt in range(4):+ try:+ r = requests.get(url, headers=hdr, timeout=300)+ if r.status_code in (200, 206):+ return read_renders(r.content)+ last = f"HTTP {r.status_code}"+ except Exception as e:+ last = type(e).__name__+ time.sleep(2 ** attempt)+ raise FetchError(last)+++class FetchError(Exception):+ """the sample could not be read at all — distinct from a sample that genuinely carries no renders"""+++def read_renders(blob):+ """A byte slice out of the middle of a tar has no end-of-archive marker, so tarfile treats it as truncated —+ and it raises in getmembers(), not in open(), which is why guarding only the open() let one bad sample kill a+ whole run. Append the two zero blocks tar expects, and scan defensively."""+ blob = blob + b"\0" * 1024+ try:+ tf = tarfile.open(fileobj=io.BytesIO(blob))+ except Exception:+ return []+ out = []+ try:+ members = sorted(tf.getmembers(), key=lambda m: m.name)+ except Exception:+ return []+ for m in members:+ if m.isfile() and "/renders/" in m.name and m.name.endswith(".png"):+ try:+ f = tf.extractfile(m)+ if f:+ out.append((os.path.basename(m.name), f.read()))+ except Exception:+ pass+ return out+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--subdir", required=True)+ ap.add_argument("--out", required=True)+ ap.add_argument("--views", type=int, default=4)+ ap.add_argument("--workers", type=int, default=8)+ ap.add_argument("--limit", type=int, default=None)+ ap.add_argument("--local_tars", default=None)+ ap.add_argument("--img_root", default="/wekafs/ict/hx_624/data/pair_images")+ ap.add_argument("--dialect", default="blender")+ a = ap.parse_args()+ token = os.environ.get("HF_TOKEN", "")+ rows = pq.read_table(f"{META}/{a.subdir}/metadata.parquet").to_pylist()+ if a.limit:+ rows = rows[: a.limit]+ print(f"[pairs] {a.subdir}: {len(rows):,} source samples", flush=True)++ from concurrent.futures import ThreadPoolExecutor+ name = a.subdir.replace("/", "__")+ img_dir = os.path.join(a.img_root, a.subdir)+ os.makedirs(img_dir, exist_ok=True)+ qc = collections.Counter()++ def one(r):+ code = r.get("code") or ""+ if len(code.strip()) < 40:+ qc["short_code"] += 1+ return None+ caps = r.get("captions")+ caps = dict(caps) if isinstance(caps, dict) else (json.loads(caps) if isinstance(caps, str) else {})+ cap = caption_of(caps)+ try:+ renders = fetch_sample(r, token, a.local_tars)[: a.views]+ except FetchError as e:+ qc[f"fetch_failed"] += 1+ renders = []+ paths = []+ for fname, blob in renders:+ d = os.path.join(img_dir, str(r["id"]).replace("/", "_"))+ os.makedirs(d, exist_ok=True)+ p = os.path.join(d, fname)+ if not os.path.exists(p):+ open(p, "wb").write(blob)+ paths.append(p)+ if not paths:+ qc["no_renders"] += 1+ if not cap:+ qc["no_caption"] += 1+ return {"id": str(r["id"]), "code": code, "caption": cap, "images": paths}++ with ThreadPoolExecutor(a.workers) as ex:+ got = [x for x in ex.map(one, rows) if x]+ print(f"[pairs] usable samples: {len(got):,} | qc={dict(qc)}", flush=True)+ if qc["fetch_failed"]:+ print(f"[pairs] WARNING {qc['fetch_failed']:,} samples could not be fetched after 4 attempts — their image "+ f"pairs are MISSING, not absent by nature. Re-run to fill them in.", flush=True)++ d, fence = a.dialect, FENCE.get(a.dialect, "python")+ out = {"text": [], "img": [], "imgtext": []}+ for g in got:+ gpt = {"from": "gpt", "value": f"```{fence}\n{g['code'].strip()}\n```"}+ base = {"id": g["id"], "system": SYS[d]}+ if g["caption"]:+ out["text"].append(dict(base, conversations=[{"from": "human", "value": ASK_TEXT[d] + g["caption"]}, gpt]))+ if g["images"]:+ ph = "<image>" * len(g["images"])+ out["img"].append(dict(base, images=list(g["images"]),+ conversations=[{"from": "human", "value": ph + "\n" + ASK_IMG[d]}, gpt]))+ if g["caption"]:+ out["imgtext"].append(dict(base, images=list(g["images"]),+ conversations=[{"from": "human", "value": ph + "\n" + ASK_BOTH[d] + g["caption"]}, gpt]))+ info = {}+ for kind, rowsk in out.items():+ if not rowsk:+ print(f"[pairs] {kind}: 0 rows — not written", flush=True)+ continue+ folder = os.path.join(a.out, f"{os.path.basename(a.subdir)}_llamafactory_{kind}")+ os.makedirs(folder, exist_ok=True)+ pd.DataFrame(rowsk).to_parquet(os.path.join(folder, "train.parquet"), index=False)+ cols = {"messages": "conversations", "system": "system"}+ if kind != "text":+ cols["images"] = "images"+ entry = {"file_name": "train.parquet", "formatting": "sharegpt", "columns": cols}+ json.dump({f"3dcv_{name}_{kind}": entry}, open(os.path.join(folder, "dataset_info.json"), "w"), indent=2)+ json.dump({"subdir": a.subdir, "pair_type": kind, "rows": len(rowsk),+ "source_samples": len(rows), "usable": len(got), **{k: v for k, v in qc.items()}},+ open(os.path.join(folder, "qc.json"), "w"), indent=2)+ info[kind] = len(rowsk)+ print(f"[pairs] {kind:8s} {len(rowsk):>7,} rows -> {folder}", flush=True)+ # the invariant LLaMA-Factory enforces on multimodal rows+ bad = sum(1 for k in ("img", "imgtext") for r in out[k]+ if r["conversations"][0]["value"].count("<image>") != len(r["images"]))+ print(f"[pairs] placeholder/image mismatches: {bad} (must be 0)", flush=True)+++if __name__ == "__main__":+ main()diff --git a/finetune/scripts/convert_subdirs.py b/finetune/scripts/convert_subdirs.pyindex 739f04e8..c63f1a7a 100644--- a/finetune/scripts/convert_subdirs.py+++ b/finetune/scripts/convert_subdirs.py@@ -193,8 +193,10 @@ def convert_one(args):code = MEDIA.sub(lambda m: f"<{m.group(1)} >", code)norm_name = r["name"].replace("Factory", "").replace("_geo", "").replace("_tex", "")if r["name"] in bench_factories or r["name"].rsplit("_", 1)[0] in bench_factories or norm_name in bench_factories:- qc["benchmark_overlap"] += 1 # flagged, and excluded below- continue+ # counted, never dropped: which samples a benchmark forbids is a decision for whoever defines the+ # benchmark, and a converter that quietly removes 100% of a subdirectory (as this once did for both+ # 3dcodebench/instances_*) is the wrong place to make it+ qc["benchmark_overlap"] += 1caps = normalize_caps(r["caps"])n_before = len(out)for kind in ("instruction", "detailed", "factory"):@@ -222,7 +224,7 @@ def convert_one(args):open(os.path.join(d, "dataset_info.json"), "w"), indent=2)tok_lens.sort()stat = {"subdir": sub, "dialect": dialect, "source_samples": len(rows), "exported_pairs": len(out),- "unique_samples_exported": len(seen_code) - qc["benchmark_overlap"],+ "unique_samples_exported": len(seen_code),"images_per_sample_median": (sorted(img_counts)[len(img_counts) // 2] if img_counts else 0),"tokens_p50": tok_lens[len(tok_lens) // 2] if tok_lens else 0,"tokens_p90": tok_lens[int(len(tok_lens) * 0.9)] if tok_lens else 0,@@ -248,7 +250,8 @@ Generated by `finetune/scripts/convert_subdirs.py` from `{sub}/metadata.parquet`{issues}`syntax_bad` rows are still exported (a shader can be valid without balanced braces in our crude check); every-other counter means the sample was dropped. `benchmark_overlap` = the sample belongs to one of the 212+other counter means the sample was dropped, EXCEPT `benchmark_overlap`, which is counted and kept: the+sample belongs to one of the 2123DCodeBench evaluation factories and is excluded to avoid test leakage.## Use@@ -266,10 +269,14 @@ def main():ap.add_argument("--out", default="/wekafs/ict/hx_624/hf_subdirs")ap.add_argument("--workers", type=int, default=16)ap.add_argument("--limit_subdirs", type=int, default=None)+ ap.add_argument("--only", default=None, help="comma-separated subdirs to convert")a = ap.parse_args()bench = frozenset(os.path.basename(p).replace("_seed0", "") for p in glob.glob(f"{BENCH_DIR}/*_seed0"))subs = ["/".join(p.split("/")[-3:-1]) for p in sorted(glob.glob(f"{META}/*/*/metadata.parquet"))]subs += ["blender_distill", "threejs_distill", "animation2code"]+ if a.only:+ want = {x.strip() for x in a.only.split(",") if x.strip()}+ subs = [x for x in subs if x in want]if a.limit_subdirs:subs = subs[: a.limit_subdirs]print(f"[conv] {len(subs)} subdirs -> {a.out}", flush=True)diff --git a/finetune/scripts/queue.txt b/finetune/scripts/queue.txtindex 3d47f99d..af0da6aa 100644--- a/finetune/scripts/queue.txt+++ b/finetune/scripts/queue.txt@@ -14,4 +14,7 @@ bal9b|bash scripts/run_9b_balanced.shstopdpo_train|bash scripts/run_stop_dpo_train.shbest_dual|bash scripts/run_best_dual_decode.sh27b_dual|bash scripts/run_27b_dual_decode.sh-stopdpo_r2|bash scripts/run_stop_dpo.sh+stopdpo_r2|bash scripts/run_stop_dpo_r2.sh+mmvis_eval|bash scripts/run_mmvis_eval.sh+rescore|bash scripts/run_rescore_sampled.sh+stop_transfer|bash scripts/run_stopdpo_transfer.shdiff --git a/finetune/scripts/run_3dcb_pairs.sh b/finetune/scripts/run_3dcb_pairs.shnew file mode 100755index 00000000..1ebbe6ac--- /dev/null+++ b/finetune/scripts/run_3dcb_pairs.sh@@ -0,0 +1,32 @@+#!/bin/bash+# Build text->code, image->code and image+text->code for every 3DCodeBench subdirectory, cheapest first:+# the two factories have their tars on local disk, the instances are read from the Hub by byte range.+# The two *_full subdirs are the before-dedup variants (12,720 / 12,708 rows against 1,953 / 1,951 after).+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+source /wekafs/ict/hx_624/anaconda3/etc/profile.d/conda.sh; conda activate llmft+OUT=/wekafs/ict/hx_624/hf_pairs+TARS=/wekafs/ict/hx_624/data/3dcodeverse_tars/3dcodebench+for SPEC in "factories_geo:$TARS/factories_geo" "factories_tex:$TARS/factories_tex" \+ "instances_geo:" "instances_tex:" "instances_geo_full:" "instances_tex_full:"; do+ SUB="${SPEC%%:*}"; LOCAL="${SPEC#*:}"+ if [ -d "$OUT/${SUB}_llamafactory_imgtext" ]; then echo "[3dcb] $SUB already built — skipping"; continue; fi+ # the *_full metadata is only on the Hub; fetch it once into the place the builder reads from+ M=/wekafs/ict/hx_624/data/3dcodeverse_meta/3dcodebench/$SUB/metadata.parquet+ if [ ! -f "$M" ]; then+ echo "[3dcb] fetching metadata for $SUB"+ python - "$SUB" <<'PY'+import os, sys, shutil+from huggingface_hub import hf_hub_download+sub = sys.argv[1]+p = hf_hub_download("ilabai/3dcodeverse", f"3dcodebench/{sub}/metadata.parquet", repo_type="dataset", token=os.environ["HF_TOKEN"])+d = f"/wekafs/ict/hx_624/data/3dcodeverse_meta/3dcodebench/{sub}"+os.makedirs(d, exist_ok=True); shutil.copy(p, f"{d}/metadata.parquet")+print(" fetched", sub)+PY+ fi+ echo "[3dcb] $(date) building $SUB"+ ARGS="--subdir 3dcodebench/$SUB --out $OUT --workers 12 --views 4"+ [ -n "$LOCAL" ] && ARGS="$ARGS --local_tars $LOCAL"+ python scripts/build_pairs_3dcodebench.py $ARGS 2>&1 | tail -8+done+echo "[3dcb] ALL DONE"diff --git a/finetune/scripts/run_9b_full_resume.sh b/finetune/scripts/run_9b_full_resume.shnew file mode 100755index 00000000..05523fd5--- /dev/null+++ b/finetune/scripts/run_9b_full_resume.sh@@ -0,0 +1,18 @@+#!/bin/bash+# Continue the 271k-sample 9B from checkpoint-4200 after dgx01 had to be given back. Four cards instead of seven,+# with accumulation raised 4 -> 7 so samples-per-step stays 28 and the resumed step count still means the same+# thing. Scored under both decodings, per section 13.+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+RUN=runs/lf_qwen35_9b_full+G=${GPUS:-$(scripts/free_gpus.sh 60000)}+[ -z "$G" ] && { echo "[full9b] no cards with 60 GB free"; exit 1; }+echo "[full9b] $(date) resuming from checkpoint-4200 on GPUs $G"+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_full_resume.yaml > logs/train_9b_full_resume.log 2>&1+[ -f $RUN/train_results.json ] || { echo "[full9b] TRAIN FAILED: $(grep -iE 'out of memory|Error|Traceback' logs/train_9b_full_resume.log | grep -v errors | tail -1 | cut -c1-190)"; exit 1; }+echo "[full9b] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-150)"+sed -e "s|model_name_or_path:.*|model_name_or_path: /wekafs/ict/hx_624/models/Qwen3.5-9B|" -e "s|adapter_name_or_path:.*|adapter_name_or_path: $(readlink -f $RUN)|" -e "s|export_dir:.*|export_dir: $(readlink -f $RUN)/merged|" configs/lf/export_lora_template.yaml > configs/lf/export_9b_full.yaml+scripts/lf_export.sh configs/lf/export_9b_full.yaml > logs/export_9b_full.log 2>&1 || { echo "[full9b] EXPORT FAILED"; exit 1; }+G1=$(echo $G | cut -d, -f1)+GPUS=$G1 TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_full_greedy 2>&1 | tail -9+GPUS=$G1 TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_full_t07 --temp 0.7 --seed 1 2>&1 | tail -9+echo "[full9b] ALL DONE"diff --git a/finetune/scripts/run_mmvis_eval.sh b/finetune/scripts/run_mmvis_eval.shnew file mode 100755index 00000000..26c0de17--- /dev/null+++ b/finetune/scripts/run_mmvis_eval.sh@@ -0,0 +1,25 @@+#!/bin/bash+# mmvis unfreezes the vision tower; it trained but was never scored. Both decodings, because section 13.+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+RUN=runs/lf_qwen35_9b_mmvis+[ -f $RUN/train_results.json ] || { echo "[mmviseval] training never finished"; exit 0; }+if [ ! -d $RUN/merged ]; then+ sed -e "s|model_name_or_path:.*|model_name_or_path: /wekafs/ict/hx_624/models/Qwen3.5-9B|" -e "s|adapter_name_or_path:.*|adapter_name_or_path: $(readlink -f $RUN)|" -e "s|export_dir:.*|export_dir: $(readlink -f $RUN)/merged|" configs/lf/export_lora_template.yaml > configs/lf/export_mmvis.yaml+ scripts/lf_export.sh configs/lf/export_mmvis.yaml > logs/export_mmvis.log 2>&1 || { echo "[mmviseval] EXPORT FAILED: $(grep -iE 'error' logs/export_mmvis.log | tail -1 | cut -c1-150)"; exit 0; }+fi+G=""; for _ in $(seq 1 60); do G=${GPUS:-$(scripts/free_gpus.sh 40000 | cut -d, -f1)}; [ -n "$G" ] && break; sleep 30; done+[ -z "$G" ] && { echo "[mmviseval] no GPU with 40 GB free"; exit 0; }+echo "[mmviseval] $(date) on GPU $G"+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_mmvis_greedy 2>&1 | tail -9+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_mmvis_t07 --temp 0.7 --seed 1 2>&1 | tail -9+# the image path is the point of unfreezing the vision tower, so score it too+source /wekafs/ict/hx_624/anaconda3/etc/profile.d/conda.sh; conda activate vllm+export VLLM_CACHE_ROOT=/wekafs/ict/hx_624/cache/vllm HF_HOME=/wekafs/ict/hx_624/cache/huggingface VLLM_LOGGING_LEVEL=WARNING CUDA_VISIBLE_DEVICES=$G+OUT=eval/out/q9b_mmvis_img; mkdir -p $OUT+python eval/generate_vllm_img.py --model $RUN/merged --prompts eval/out/_img4text_bench_prompts.jsonl --out $OUT \+ --max_new_tokens 32768 --max_model_len 40960 > logs/gen_mmvis_img.log 2>&1; tail -2 logs/gen_mmvis_img.log+N=$(ls $OUT | grep -vc extract_stats.json || true)+[ "${N:-0}" -lt 5 ] && { echo "[mmviseval] image path PRODUCED NOTHING — not scoring"; exit 0; }+conda activate llmft+python eval/run_bench.py --gen_dir $OUT --workers 24 --timeout 300 2>&1 | grep "status counts" | tail -1+echo "[mmviseval] DONE"diff --git a/finetune/scripts/run_rescore_sampled.sh b/finetune/scripts/run_rescore_sampled.shnew file mode 100755index 00000000..228aea01--- /dev/null+++ b/finetune/scripts/run_rescore_sampled.sh@@ -0,0 +1,14 @@+#!/bin/bash+# Every dialect number in the report was measured greedy, and section 13 showed that understates the long-output+# dialects badly (9B OpenSCAD 6% vs 44%, 27B 34% vs 80%). Re-score the models whose merged weights still exist,+# one after another in a single session so the numbers are comparable to each other (13.7).+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+for SPEC in "runs/lf_qwen35_9b_lora_md_xl:q9b_md_xl_t07" "runs/lf_qwen35_9b_imgmix:q9b_imgmix_t07" "runs/lf_qwen35_9b_lora_v1:q9b_v1_t07"; do+ M="${SPEC%%:*}"; NAME="${SPEC##*:}"+ [ -d "$M/merged" ] || { echo "[rescore] $M has no merged weights — skipping (the DPO scripts delete them)"; continue; }+ G=""; for _ in $(seq 1 90); do G=${GPUS:-$(scripts/free_gpus.sh 40000 | cut -d, -f1)}; [ -n "$G" ] && break; sleep 60; done+ [ -z "$G" ] && { echo "[rescore] no GPU with 40 GB free"; exit 0; }+ echo "[rescore] $(date) $NAME on GPU $G"+ GPUS=$G TP=1 bash eval/eval_all_run2.sh $M/merged $NAME --temp 0.7 --seed 1 2>&1 | tail -9+done+echo "[rescore] DONE"diff --git a/finetune/scripts/run_stop_dpo.sh b/finetune/scripts/run_stop_dpo.shindex cdf2432d..a97305b8 100755--- a/finetune/scripts/run_stop_dpo.sh+++ b/finetune/scripts/run_stop_dpo.sh@@ -6,23 +6,25 @@# (its runaway greedy output) and its own positives (a sampled generation that finishes AND executes), on# TRAINING prompts only -- the dialect suites are held-out and must not be trained on.set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft-W=data/stop_dpo; BASE=runs/lf_qwen35_9b_mmmix2/merged+TAG=${TAG:-mmmix2}; W=data/stop_dpo_$TAG; BASE=${BASE_MODEL:-runs/lf_qwen35_9b_mmmix2/merged}[ -d "$BASE" ] || { echo "[stopdpo] no base model"; exit 0; }+mkdir -p $W; cp -n data/stop_dpo/prompts.jsonl $W/prompts.jsonl 2>/dev/null || true+STOP_TP=${STOP_TP:-1}; STOP_NSEQ=${STOP_NSEQ:-}G=""; for _ in $(seq 1 60); do G=${GPUS:-$(scripts/free_gpus.sh 40000 | cut -d, -f1)}; [ -n "$G" ] && break; sleep 30; done[ -z "$G" ] && { echo "[stopdpo] no GPU with 40 GB free"; exit 0; }source /wekafs/ict/hx_624/anaconda3/etc/profile.d/conda.sh; conda activate vllmexport VLLM_CACHE_ROOT=/wekafs/ict/hx_624/cache/vllm HF_HOME=/wekafs/ict/hx_624/cache/huggingface VLLM_LOGGING_LEVEL=WARNING CUDA_VISIBLE_DEVICES=$G# greedy produces the negatives, sampling the positives -- exactly the two behaviours we want to separate[ -d $W/gen_greedy/. ] || python eval/generate_vllm.py --model $BASE --prompts $W/prompts.jsonl --out $W/gen_greedy \- --tp 1 --no_think --max_new_tokens 16384 --max_model_len 20480 2>&1 | tail -1+ --tp $STOP_TP ${STOP_NSEQ:+--max_num_seqs $STOP_NSEQ} --no_think --max_new_tokens 16384 --max_model_len 20480 2>&1 | tail -1for i in 1 2; do[ -d $W/gen_s$i/. ] || python eval/generate_vllm.py --model $BASE --prompts $W/prompts.jsonl --out $W/gen_s$i \- --tp 1 --no_think --max_new_tokens 16384 --max_model_len 20480 --temperature 0.8 --seed $((700+i)) 2>&1 | tail -1+ --tp $STOP_TP ${STOP_NSEQ:+--max_num_seqs $STOP_NSEQ} --no_think --max_new_tokens 16384 --max_model_len 20480 --temperature 0.8 --seed $((700+i)) 2>&1 | tail -1doneconda activate llmftpython - <<'PY'import json, os, glob, random, collections-random.seed(5); W = "data/stop_dpo"+random.seed(5); W = "data/stop_dpo_" + os.environ.get("TAG", "mmmix2")prompts = {json.loads(l)["task"]: json.loads(l) for l in open(f"{W}/prompts.jsonl")}def load(d):out = {}@@ -54,9 +56,10 @@ for t, g in greedy.items():"dialect": p["dialect"]})why["paired"] += 1random.shuffle(pairs)-json.dump(pairs, open("data/lf/stop_dpo_pairs.json", "w"), ensure_ascii=False)+tag = os.environ.get("TAG", "mmmix2")+json.dump(pairs, open(f"data/lf/stop_dpo_pairs_{tag}.json", "w"), ensure_ascii=False)info = json.load(open("data/lf/dataset_info.json"))-info["stop_dpo_pairs"] = {"file_name": "stop_dpo_pairs.json", "ranking": True, "formatting": "sharegpt",+info[f"stop_dpo_pairs_{tag}"] = {"file_name": f"stop_dpo_pairs_{tag}.json", "ranking": True, "formatting": "sharegpt","columns": {"messages": "conversations", "system": "system", "chosen": "chosen", "rejected": "rejected"}}json.dump(info, open("data/lf/dataset_info.json", "w"), indent=2)print("[stopdpo] pairs:", len(pairs), dict(why))diff --git a/finetune/scripts/run_stop_dpo_r2.sh b/finetune/scripts/run_stop_dpo_r2.shnew file mode 100755index 00000000..f3b208da--- /dev/null+++ b/finetune/scripts/run_stop_dpo_r2.sh@@ -0,0 +1,69 @@+#!/bin/bash+# Round 2 of the same idea, but generated from the round-1 model. The first attempt at this reused round 1's+# directories because of a "skip if it exists" guard and rebuilt an identical pair set in nine seconds while+# reporting success -- a real round has to see what the CURRENT model still gets wrong.+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+W=data/stop_dpo_r2; BASE=runs/lf_qwen35_9b_stopdpo/merged+[ -d "$BASE" ] || { echo "[stop2] round-1 model missing"; exit 0; }+mkdir -p $W; cp data/stop_dpo/prompts.jsonl $W/prompts.jsonl+G=""; for _ in $(seq 1 60); do G=${GPUS:-$(scripts/free_gpus.sh 40000 | cut -d, -f1)}; [ -n "$G" ] && break; sleep 30; done+[ -z "$G" ] && { echo "[stop2] no GPU with 40 GB free"; exit 0; }+source /wekafs/ict/hx_624/anaconda3/etc/profile.d/conda.sh; conda activate vllm+export VLLM_CACHE_ROOT=/wekafs/ict/hx_624/cache/vllm HF_HOME=/wekafs/ict/hx_624/cache/huggingface VLLM_LOGGING_LEVEL=WARNING CUDA_VISIBLE_DEVICES=$G+echo "[stop2] $(date) sampling round-1 model on GPU $G"+python eval/generate_vllm.py --model $BASE --prompts $W/prompts.jsonl --out $W/gen_greedy --tp 1 --no_think \+ --max_new_tokens 16384 --max_model_len 20480 2>&1 | tail -1+for i in 1 2; do+ python eval/generate_vllm.py --model $BASE --prompts $W/prompts.jsonl --out $W/gen_s$i --tp 1 --no_think \+ --max_new_tokens 16384 --max_model_len 20480 --temperature 0.8 --seed $((900+i)) 2>&1 | tail -1+done+conda activate llmft+python - "$W" <<'PY'+import json, os, sys, random, collections+random.seed(9); W = sys.argv[1]+prompts = {json.loads(l)["task"]: json.loads(l) for l in open(f"{W}/prompts.jsonl")}+def load(d):+ out = {}; p = f"{d}/gens_shard0.jsonl"+ if not os.path.exists(p): return out+ for l in open(p):+ r = json.loads(l); t = r["task"]; cp = f"{d}/{t}/code.py"+ if os.path.exists(cp):+ out[t] = {"finished": r.get("finished", True), "ntok": r.get("n_new_tokens", 0),+ "code": open(cp, encoding="utf-8", errors="replace").read().strip()}+ return out+greedy = load(f"{W}/gen_greedy"); samples = [load(f"{W}/gen_s{i}") for i in (1, 2)]+pairs, why = [], collections.Counter()+for t, g in greedy.items():+ if not ((not g["finished"]) or g["ntok"] > 8192): why["greedy_was_fine"] += 1; continue+ cands = [s[t] for s in samples if t in s and s[t]["finished"] and s[t]["ntok"] <= 8192 and len(s[t]["code"]) > 60]+ if not cands: why["no_clean_sample"] += 1; continue+ good = min(cands, key=lambda c: c["ntok"])+ if good["code"] == g["code"]: why["identical"] += 1; continue+ p = prompts[t]+ pairs.append({"conversations": [{"from": "human", "value": p["messages"][1]["content"]}],+ "system": p["messages"][0]["content"],+ "chosen": {"from": "gpt", "value": good["code"]},+ "rejected": {"from": "gpt", "value": g["code"][:60000]}, "dialect": p["dialect"]})+ why["paired"] += 1+random.shuffle(pairs)+json.dump(pairs, open("data/lf/stop_dpo_pairs_r2.json", "w"), ensure_ascii=False)+info = json.load(open("data/lf/dataset_info.json"))+info["stop_dpo_pairs_r2"] = {"file_name": "stop_dpo_pairs_r2.json", "ranking": True, "formatting": "sharegpt",+ "columns": {"messages": "conversations", "system": "system", "chosen": "chosen", "rejected": "rejected"}}+json.dump(info, open("data/lf/dataset_info.json", "w"), indent=2)+print("[stop2] pairs:", len(pairs), dict(why))+print("[stop2] by dialect:", dict(collections.Counter(p["dialect"] for p in pairs)))+PY+N=$(python3 -c "import json;print(len(json.load(open('data/lf/stop_dpo_pairs_r2.json'))))" 2>/dev/null || echo 0)+# round 1 fixed most of the runaways; if few remain there is nothing left to train on, and that is the result+[ "${N:-0}" -lt 100 ] && { echo "[stop2] only $N pairs left after round 1 — the behaviour is largely gone, stopping here"; exit 0; }+sed -e "s|model_name_or_path:.*|model_name_or_path: $(readlink -f $BASE)|" -e "s|dataset: stop_dpo_pairs|dataset: stop_dpo_pairs_r2|" \+ -e "s|^output_dir:.*|output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_stopdpo_r2|" configs/lf/dpo_stop.yaml > configs/lf/dpo_stop_r2.yaml+RUN=runs/lf_qwen35_9b_stopdpo_r2+GPUS=$G scripts/lf_train.sh configs/lf/dpo_stop_r2.yaml > logs/train_stopdpo_r2.log 2>&1+[ -f $RUN/train_results.json ] || { echo "[stop2] TRAIN FAILED: $(grep -iE 'out of memory|Error' logs/train_stopdpo_r2.log | grep -v errors | tail -1 | cut -c1-180)"; exit 0; }+sed -e "s|model_name_or_path:.*|model_name_or_path: $(readlink -f $BASE)|" -e "s|adapter_name_or_path:.*|adapter_name_or_path: $(readlink -f $RUN)|" -e "s|export_dir:.*|export_dir: $(readlink -f $RUN)/merged|" configs/lf/export_lora_template.yaml > configs/lf/export_stopdpo_r2.yaml+scripts/lf_export.sh configs/lf/export_stopdpo_r2.yaml > logs/export_stopdpo_r2.log 2>&1 || { echo "[stop2] EXPORT FAILED"; exit 0; }+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_stopdpo_r2_greedy 2>&1 | tail -9+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_stopdpo_r2_t07 --temp 0.7 --seed 1 2>&1 | tail -9+echo "[stop2] DONE"diff --git a/finetune/scripts/run_stopdpo_transfer.sh b/finetune/scripts/run_stopdpo_transfer.shnew file mode 100755index 00000000..c1eec24f--- /dev/null+++ b/finetune/scripts/run_stopdpo_transfer.sh@@ -0,0 +1,22 @@+#!/bin/bash+# dpo_exec_v2 generates NO runaway pairs of its own (3,247 of 3,687 greedy generations terminate cleanly) -- its+# execution-feedback DPO on Blender prompts already taught termination, which is very likely why it is the best+# model. So it cannot bootstrap its own stop-DPO. Instead transfer the pairs mmmix2 produced: the lesson they+# carry ("stop here, not there") is not specific to the model that generated them. If bench holds at ~96% while+# OpenSCAD/GLSL climb, that combination is the best model in the project.+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft+BASE=runs/lf_qwen35_9b_dpo_exec_v2/merged; RUN=runs/lf_qwen35_9b_best_stop+[ -d "$BASE" ] || { echo "[transfer] best model not exported"; exit 0; }+G=""; for _ in $(seq 1 90); do G=${GPUS:-$(scripts/free_gpus.sh 40000 | cut -d, -f1)}; [ -n "$G" ] && break; sleep 60; done+[ -z "$G" ] && { echo "[transfer] no GPU with 40 GB free"; exit 0; }+sed -e "s|model_name_or_path:.*|model_name_or_path: $(readlink -f $BASE)|" \+ -e "s|^output_dir:.*|output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_best_stop|" configs/lf/dpo_stop.yaml > configs/lf/dpo_best_stop.yaml+echo "[transfer] $(date) train on GPU $G"+GPUS=$G scripts/lf_train.sh configs/lf/dpo_best_stop.yaml > logs/train_best_stop.log 2>&1+[ -f $RUN/train_results.json ] || { echo "[transfer] TRAIN FAILED: $(grep -iE 'out of memory|Error' logs/train_best_stop.log | grep -v errors | tail -1 | cut -c1-180)"; exit 0; }+echo "[transfer] train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-130)"+sed -e "s|model_name_or_path:.*|model_name_or_path: $(readlink -f $BASE)|" -e "s|adapter_name_or_path:.*|adapter_name_or_path: $(readlink -f $RUN)|" -e "s|export_dir:.*|export_dir: $(readlink -f $RUN)/merged|" configs/lf/export_lora_template.yaml > configs/lf/export_best_stop.yaml+scripts/lf_export.sh configs/lf/export_best_stop.yaml > logs/export_best_stop.log 2>&1 || { echo "[transfer] EXPORT FAILED"; exit 0; }+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_best_stop_greedy 2>&1 | tail -9+GPUS=$G TP=1 bash eval/eval_all_run2.sh $RUN/merged q9b_best_stop_t07 --temp 0.7 --seed 1 2>&1 | tail -9+echo "[transfer] DONE"diff --git a/finetune/scripts/sync_repo.sh b/finetune/scripts/sync_repo.shindex 1bff0611..f6f6e130 100755--- a/finetune/scripts/sync_repo.sh+++ b/finetune/scripts/sync_repo.sh@@ -19,7 +19,9 @@ MSG=${1:-"finetune: sync scripts, configs, eval stack and docs"}[ -d "$DST" ] || { echo "repo clone missing at $REPO"; exit 1; }rsync -a --delete --exclude '__pycache__' --exclude '*.pyc' "$SRC/scripts/" "$DST/scripts/"-rsync -a --exclude '__pycache__' "$SRC/configs/" "$DST/configs/"+# --delete on configs too: without it a config retired into configs/lf/archive/ was copied to its new+# location but the old copy lingered in the repo forever, so a tidy-up never actually reached GitHub.+rsync -a --delete --exclude '__pycache__' "$SRC/configs/" "$DST/configs/"rsync -a --delete --exclude '__pycache__' --exclude 'out' --exclude '_test' --exclude 'ref_oracle' --exclude '*.pyc' "$SRC/eval/" "$DST/eval/"cp "$SRC/env.sh" "$DST/env.sh"cp "$SRC/REPORT.md" "$DST/docs/REPORT.md"diff --git a/finetune/scripts/verify_unflattened_glsl.py b/finetune/scripts/verify_unflattened_glsl.pynew file mode 100644index 00000000..5bb8dc33--- /dev/null+++ b/finetune/scripts/verify_unflattened_glsl.py@@ -0,0 +1,108 @@+"""Compile-verify the 44 shadertoy shards that the flattening pass never reached.++Those shards' metadata carries no `shader_json`, so there was no renderpass structure to merge a Common tab+from and `flatten_multifile.py` skipped them — exactly 44 of 112, with zero mismatches. The consequence is that+73,281 shaders are verified (99.04% compile) while 46,680 have never been near a compiler. This runs the same+checker and the same minimal repairs over those, and writes the `compiles` / `repair` columns the flattened+folders already carry, so a training mix can filter the whole corpus by one rule instead of two.++usage: python scripts/verify_unflattened_glsl.py [--workers 40] [--limit_shards N] [--out DIR]+"""+import argparse+import collections+import glob+import json+import os+import re+import sys++import pandas as pd++sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))+from qc_repair import glsl_compile, repair_glsl++SRC = "/wekafs/ict/hx_624/hf_subdirs/shadertoy"+FENCE = re.compile(r"^```[a-zA-Z]*\n|\n?```$")+++def strip_fence(v):+ return FENCE.sub("", v.strip())+++def verify_one(code):+ """-> (compiles, repair_label, code_to_keep). Never returns a program that does not compile as 'repaired'."""+ ok, _ = glsl_compile(code)+ if ok:+ return True, "original", code+ try:+ fixed, recipe = repair_glsl(code)+ except Exception:+ return False, "unfixable", code+ if fixed and fixed != code:+ ok2, _ = glsl_compile(fixed)+ if ok2:+ return True, f"repaired:{recipe or 'other'}", fixed+ return False, "unfixable", code+++def do_shard(args):+ sub, out_root = args+ p = f"{SRC}/{sub}_llamafactory/train.parquet"+ df = pd.read_parquet(p)+ # one shader appears once per caption variant; compile each distinct program once+ by_code = {}+ codes = [strip_fence(c[1]["value"]) for c in df["conversations"]]+ for c in set(codes):+ by_code[c] = verify_one(c)+ okc, howc, conv = [], [], []+ for row, c in zip(df.itertuples(), codes):+ ok, how, keep = by_code[c]+ okc.append(ok); howc.append(how)+ turns = [dict(t) for t in row.conversations]+ turns[1] = dict(turns[1], value=f"```glsl\n{keep}\n```")+ conv.append(turns)+ df["conversations"] = conv+ df["compiles"] = okc+ df["repair"] = howc+ d = os.path.join(out_root, f"{sub}_llamafactory")+ os.makedirs(d, exist_ok=True)+ df.to_parquet(os.path.join(d, "train.parquet"), index=False)+ for extra in ("dataset_info.json", "qc.json", "README.md"):+ s = f"{SRC}/{sub}_llamafactory/{extra}"+ if os.path.exists(s):+ open(os.path.join(d, extra), "w").write(open(s).read())+ st = {"shard": sub, "rows": len(df), "unique_programs": len(by_code),+ "compiles": int(sum(okc)), "repaired": int(sum(1 for h in howc if h.startswith("repaired"))),+ "unfixable": int(sum(1 for h in howc if h == "unfixable"))}+ json.dump(st, open(os.path.join(d, "verify.json"), "w"), indent=2)+ return st+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--workers", type=int, default=40)+ ap.add_argument("--limit_shards", type=int, default=None)+ ap.add_argument("--out", default="/wekafs/ict/hx_624/hf_subdirs_verified/shadertoy")+ a = ap.parse_args()+ flat = {os.path.basename(p)[: -len("_llamafactory_flat")] for p in glob.glob(f"{SRC}/*_llamafactory_flat")}+ allp = {os.path.basename(p)[: -len("_llamafactory")] for p in glob.glob(f"{SRC}/*_llamafactory")}+ todo = sorted(allp - flat)+ if a.limit_shards:+ todo = todo[: a.limit_shards]+ os.makedirs(a.out, exist_ok=True)+ print(f"[verify] {len(todo)} shards never verified -> {a.out}", flush=True)+ from concurrent.futures import ProcessPoolExecutor+ tot = collections.Counter()+ with ProcessPoolExecutor(a.workers) as ex:+ for st in ex.map(do_shard, [(s, a.out) for s in todo]):+ for k in ("rows", "unique_programs", "compiles", "repaired", "unfixable"):+ tot[k] += st[k]+ print(f"[verify] {st['shard']:4s} rows={st['rows']:>6,} uniq={st['unique_programs']:>5,} "+ f"ok={st['compiles']:>6,} repaired={st['repaired']:>4,} unfixable={st['unfixable']:>4,}", flush=True)+ rate = tot["compiles"] / max(tot["rows"], 1) * 100+ print(f"[verify] TOTAL rows={tot['rows']:,} unique={tot['unique_programs']:,} "+ f"compiles={tot['compiles']:,} ({rate:.2f}%) repaired={tot['repaired']:,} unfixable={tot['unfixable']:,}", flush=True)+++if __name__ == "__main__":+ main()