Skip to content

Official Codebase of 3DCodeVerse

Python

finetune: REPORT 12 — corpus cleaning with compiler+renderer verification, URDF recovery, leakage probe (contamination did not inflate the score), image-conditioned generation (69.3% from a single render)

gaoypeng1aa3abcf2058
diff --git a/finetune/configs/lf/export_27b_v5.yaml b/finetune/configs/lf/export_27b_v5.yaml
new file mode 100644
index 00000000..f7a2d6f3
--- /dev/null
+++ b/finetune/configs/lf/export_27b_v5.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/models/Qwen3.8-27B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen38_27b_lora_v5
+template: qwen3_5
+enable_thinking: false
+trust_remote_code: true
+finetuning_type: lora
+
+export_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen38_27b_lora_v5/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/export_9b_clean.yaml b/finetune/configs/lf/export_9b_clean.yaml
new file mode 100644
index 00000000..6122a4bc
--- /dev/null
+++ b/finetune/configs/lf/export_9b_clean.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/models/Qwen3.5-9B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_lora_clean
+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_lora_clean/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/export_9b_img.yaml b/finetune/configs/lf/export_9b_img.yaml
new file mode 100644
index 00000000..4f4f9b5a
--- /dev/null
+++ b/finetune/configs/lf/export_9b_img.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/models/Qwen3.5-9B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_img
+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_img/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/export_9b_img4.yaml b/finetune/configs/lf/export_9b_img4.yaml
new file mode 100644
index 00000000..771d965b
--- /dev/null
+++ b/finetune/configs/lf/export_9b_img4.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/models/Qwen3.5-9B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_img4
+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_img4/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/export_9b_imgmix.yaml b/finetune/configs/lf/export_9b_imgmix.yaml
new file mode 100644
index 00000000..8cfeb3be
--- /dev/null
+++ b/finetune/configs/lf/export_9b_imgmix.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/models/Qwen3.5-9B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_imgmix
+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_imgmix/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/export_9b_noleak.yaml b/finetune/configs/lf/export_9b_noleak.yaml
new file mode 100644
index 00000000..2ba495a6
--- /dev/null
+++ b/finetune/configs/lf/export_9b_noleak.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/models/Qwen3.5-9B
+adapter_name_or_path: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_noleak
+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_noleak/merged
+export_size: 5
+export_device: cpu
+export_legacy_format: false
diff --git a/finetune/configs/lf/lora_27b_clean.yaml b/finetune/configs/lf/lora_27b_clean.yaml
new file mode 100644
index 00000000..56122f4e
--- /dev/null
+++ b/finetune/configs/lf/lora_27b_clean.yaml
@@ -0,0 +1,44 @@
+model_name_or_path: /wekafs/ict/hx_624/models/Qwen3.8-27B
+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/lf
+dataset: md_9b_noleak_train
+eval_dataset: md_9b_clean_val
+template: qwen3_5
+enable_thinking: false
+cutoff_len: 3072
+preprocessing_num_workers: 16
+dataloader_num_workers: 4
+neat_packing: true
+packing: true
+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_27b_clean_3072
+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen38_27b_clean
+logging_steps: 5
+save_steps: 300
+save_only_model: true
+plot_loss: true
+overwrite_output_dir: true
+report_to: tensorboard
+per_device_train_batch_size: 1
+gradient_accumulation_steps: 6
+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: null
+per_device_eval_batch_size: 1
+eval_strategy: steps
+eval_steps: 300
+save_total_limit: 8
diff --git a/finetune/configs/lf/lora_9b_img.yaml b/finetune/configs/lf/lora_9b_img.yaml
new file mode 100644
index 00000000..d8ee482a
--- /dev/null
+++ b/finetune/configs/lf/lora_9b_img.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/img_code
+dataset: img_code_train
+eval_dataset: img_code_val
+template: qwen3_5
+enable_thinking: false
+cutoff_len: 8192
+preprocessing_num_workers: 16
+dataloader_num_workers: 4
+neat_packing: false
+packing: false
+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_img_code
+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_img
+logging_steps: 5
+save_steps: 200
+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: 0.0001
+num_train_epochs: 2.0
+lr_scheduler_type: cosine
+warmup_ratio: 0.05
+bf16: true
+gradient_checkpointing: true
+ddp_timeout: 180000000
+resume_from_checkpoint: null
+per_device_eval_batch_size: 1
+eval_strategy: steps
+eval_steps: 200
+save_total_limit: 4
diff --git a/finetune/configs/lf/lora_9b_img4.yaml b/finetune/configs/lf/lora_9b_img4.yaml
new file mode 100644
index 00000000..55b1c32a
--- /dev/null
+++ b/finetune/configs/lf/lora_9b_img4.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/img_code4
+dataset: img_code_train
+eval_dataset: img_code_val
+template: qwen3_5
+enable_thinking: false
+cutoff_len: 8192
+preprocessing_num_workers: 16
+dataloader_num_workers: 4
+neat_packing: false
+packing: false
+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_img_code4
+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_img4
+logging_steps: 5
+save_steps: 200
+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: 0.0001
+num_train_epochs: 2.0
+lr_scheduler_type: cosine
+warmup_ratio: 0.05
+bf16: true
+gradient_checkpointing: true
+ddp_timeout: 180000000
+resume_from_checkpoint: null
+per_device_eval_batch_size: 1
+eval_strategy: steps
+eval_steps: 200
+save_total_limit: 4
diff --git a/finetune/configs/lf/lora_9b_imgmix.yaml b/finetune/configs/lf/lora_9b_imgmix.yaml
new file mode 100644
index 00000000..66e1b19f
--- /dev/null
+++ b/finetune/configs/lf/lora_9b_imgmix.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/img_mix
+dataset: img_code_train,md_9b_noleak_train
+eval_dataset: md_9b_clean_val
+template: qwen3_5
+enable_thinking: false
+cutoff_len: 8192
+preprocessing_num_workers: 16
+dataloader_num_workers: 4
+neat_packing: false
+packing: false
+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_img_mix
+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_imgmix
+logging_steps: 5
+save_steps: 500
+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: 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: null
+per_device_eval_batch_size: 1
+eval_strategy: steps
+eval_steps: 500
+save_total_limit: 4
diff --git a/finetune/configs/lf/lora_9b_noleak.yaml b/finetune/configs/lf/lora_9b_noleak.yaml
new file mode 100644
index 00000000..b2ec18fd
--- /dev/null
+++ b/finetune/configs/lf/lora_9b_noleak.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/lf
+dataset: md_9b_noleak_train
+eval_dataset: md_9b_clean_val
+template: qwen3_5
+enable_thinking: false
+cutoff_len: 8192
+preprocessing_num_workers: 16
+dataloader_num_workers: 4
+neat_packing: true
+packing: true
+tokenized_path: /wekafs/ict/hx_624/llm-ft/data/lf/tok_9b_noleak_8192
+output_dir: /wekafs/ict/hx_624/llm-ft/runs/lf_qwen35_9b_noleak
+logging_steps: 5
+save_steps: 400
+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: 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: null
+per_device_eval_batch_size: 1
+eval_strategy: steps
+eval_steps: 400
+save_total_limit: 8
diff --git a/finetune/data_specs/dataset_info.json b/finetune/data_specs/dataset_info.json
index ec4b72e6..d204a8f9 100644
--- a/finetune/data_specs/dataset_info.json
+++ b/finetune/data_specs/dataset_info.json
@@ -555,5 +555,21 @@
"messages": "conversations",
"system": "system"
}
+ },
+ "md_9b_noleak_train": {
+ "file_name": "md_9b_noleak_train.json",
+ "formatting": "sharegpt",
+ "columns": {
+ "messages": "conversations",
+ "system": "system"
+ }
+ },
+ "md_9b_noleak_val": {
+ "file_name": "md_9b_noleak_val.json",
+ "formatting": "sharegpt",
+ "columns": {
+ "messages": "conversations",
+ "system": "system"
+ }
}
}
\ No newline at end of file
diff --git a/finetune/eval/generate_vllm_img.py b/finetune/eval/generate_vllm_img.py
new file mode 100644
index 00000000..8b661d6d
--- /dev/null
+++ b/finetune/eval/generate_vllm_img.py
@@ -0,0 +1,62 @@
+"""vLLM generation with image inputs (multimodal prompts), same outputs as generate_vllm.py.
+
+Prompt file rows: {"task", "images": [paths], "messages": [{role, content}]} where the user content contains one
+`<image>` per image. The images are attached as multi_modal_data so the model actually sees them.
+"""
+import argparse, json, os, sys, time
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from extract import extract, summarize
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--model", required=True); ap.add_argument("--prompts", required=True); ap.add_argument("--out", required=True)
+ ap.add_argument("--max_new_tokens", type=int, default=6144); ap.add_argument("--max_model_len", type=int, default=12288)
+ ap.add_argument("--temperature", type=float, default=0.0); ap.add_argument("--seed", type=int, default=0)
+ ap.add_argument("--tp", type=int, default=1); ap.add_argument("--gpu_mem", type=float, default=0.88)
+ ap.add_argument("--dialect", default="blender"); ap.add_argument("--limit", type=int, default=None)
+ a = ap.parse_args()
+ from vllm import LLM, SamplingParams
+ from PIL import Image
+ rows = [json.loads(l) for l in open(a.prompts) if l.strip()]
+ if a.limit: rows = rows[:a.limit]
+ os.makedirs(a.out, exist_ok=True)
+ llm = LLM(model=a.model, dtype="bfloat16", tensor_parallel_size=a.tp, max_model_len=a.max_model_len,
+ gpu_memory_utilization=a.gpu_mem, limit_mm_per_prompt={"image": 4, "video": 0}, trust_remote_code=True)
+ sp = SamplingParams(temperature=a.temperature, top_p=0.95 if a.temperature > 0 else 1.0,
+ max_tokens=a.max_new_tokens, seed=a.seed)
+ import base64, io
+ def data_url(path):
+ im = Image.open(path).convert("RGB")
+ im.thumbnail((768, 768))
+ b = io.BytesIO(); im.save(b, "JPEG", quality=88)
+ return "data:image/jpeg;base64," + base64.b64encode(b.getvalue()).decode()
+ convs = []
+ for r in rows:
+ msgs = []
+ for m in r["messages"]:
+ if m["role"] == "user" and r.get("images"):
+ parts = [{"type": "image_url", "image_url": {"url": data_url(p)}} for p in r["images"]]
+ parts.append({"type": "text", "text": m["content"].replace("<image>", "").strip()})
+ msgs.append({"role": "user", "content": parts})
+ else:
+ msgs.append(m)
+ convs.append(msgs)
+ t0 = time.time()
+ outs = llm.chat(convs, sp, use_tqdm=True, chat_template_kwargs={"enable_thinking": False})
+ el = time.time() - t0; ntok = 0; metas = []
+ with open(f"{a.out}/gens_shard0.jsonl", "w") as f:
+ for r, o in zip(rows, outs):
+ text = o.outputs[0].text; n = len(o.outputs[0].token_ids); ntok += n
+ d = f"{a.out}/{r['task']}"; os.makedirs(d, exist_ok=True)
+ code, meta = extract(text, a.dialect); metas.append(meta)
+ open(f"{d}/code.py", "w").write(code + "\n"); open(f"{d}/raw.txt", "w").write(text)
+ f.write(json.dumps({"task": r["task"], "n_new_tokens": n,
+ "finished": o.outputs[0].finish_reason == "stop",
+ "has_code_block": "```" in text, "extract": meta}) + "\n")
+ st = summarize(metas); st.update({"model": a.model, "images": True, "tok_per_s": round(ntok/max(el,1e-6), 1),
+ "mean_new_tokens": round(ntok/max(1, len(rows)), 1)})
+ json.dump(st, open(f"{a.out}/extract_stats.json", "w"), indent=2)
+ print(f"[gen-vllm-img] {len(rows)} prompts | {ntok} tok | {ntok/el:.0f} tok/s | {el/60:.1f} min", flush=True)
+
+if __name__ == "__main__":
+ main()
diff --git a/finetune/scripts/build_md_max.py b/finetune/scripts/build_md_max.py
index 6e207ec1..409192f2 100644
--- a/finetune/scripts/build_md_max.py
+++ b/finetune/scripts/build_md_max.py
@@ -79,7 +79,8 @@ def load_parquet_rows(dialect, sub, drop_names=frozenset()):
out = []
for r in df.itertuples():
name = str(getattr(r, "name", "") or "")
- if name in drop_names or name.rsplit("_", 1)[0] in drop_names:
+ norm = name.replace("Factory", "").replace("_geo", "").replace("_tex", "")
+ if name in drop_names or name.rsplit("_", 1)[0] in drop_names or norm in drop_names:
continue
code = getattr(r, "code", None) or ""
if not isinstance(code, str) or len(code.strip()) < 40:
diff --git a/finetune/scripts/convert_subdirs.py b/finetune/scripts/convert_subdirs.py
index e0446619..739f04e8 100644
--- a/finetune/scripts/convert_subdirs.py
+++ b/finetune/scripts/convert_subdirs.py
@@ -191,7 +191,8 @@ def convert_one(args):
if MEDIA.search(code) or any(MEDIA.search(v) for v in r["caps"].values() if isinstance(v, str)):
qc["media_placeholder"] += 1
code = MEDIA.sub(lambda m: f"<{m.group(1)} >", code)
- if r["name"] in bench_factories or r["name"].rsplit("_", 1)[0] in bench_factories:
+ 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
caps = normalize_caps(r["caps"])
diff --git a/finetune/scripts/eval_9b_img.sh b/finetune/scripts/eval_9b_img.sh
new file mode 100755
index 00000000..f175c037
--- /dev/null
+++ b/finetune/scripts/eval_9b_img.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Evaluate the image-conditioned model on 3DCodeBench by feeding each task's own reference render instead of the
+# text prompt. Same executor and geometry metrics, so the score is directly comparable to the text-only runs.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+G=$(scripts/free_gpus.sh | cut -d, -f1)
+RUN=runs/lf_qwen35_9b_img4; OUT=eval/out/q9b_img_bench; mkdir -p $OUT
+python - <<'PY'
+import json, glob, os
+rows=[]
+for d in sorted(glob.glob("/wekafs/ict/hx_624/data/3dcodebench/data/*_seed0")):
+ imgs=sorted(glob.glob(os.path.join(d,"images","*.png")))[:1]
+ if not imgs: continue
+ rows.append({"task": os.path.basename(d), "images": imgs,
+ "messages":[{"role":"system","content":"You are an expert in procedural 3D modeling with Blender Python (bpy). Given reference renders of an object, write a complete, standalone Blender 5 Python script that reproduces it (clear the default scene first). Output ONLY the code in one ```python block."},
+ {"role":"user","content":"<image>\nReproduce this 3D object with Blender Python code."}]})
+open("eval/out/_img_bench_prompts.jsonl","w").write("\n".join(json.dumps(r) for r in rows))
+print("image prompts:", len(rows))
+PY
+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
+python eval/generate_vllm_img.py --model $RUN/merged --prompts eval/out/_img_bench_prompts.jsonl --out $OUT --max_new_tokens 6144 2>&1 | tail -2
+conda activate llmft
+python eval/run_bench.py --gen_dir $OUT --workers 24 --timeout 300 2>&1 | grep "status counts" | tail -1
+python eval/metrics.py --gen_dir $OUT 2>&1 | tail -1
+echo "[imgeval] DONE"
diff --git a/finetune/scripts/eval_9b_noleak.sh b/finetune/scripts/eval_9b_noleak.sh
new file mode 100755
index 00000000..7b6ed604
--- /dev/null
+++ b/finetune/scripts/eval_9b_noleak.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+RUN=runs/lf_qwen35_9b_noleak; G=$(scripts/free_gpus.sh)
+[ -f $RUN/merged/config.json ] || {
+ 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_noleak.yaml
+ scripts/lf_export.sh configs/lf/export_9b_noleak.yaml > logs/export_9b_noleak.log 2>&1 || { echo "[noleak] EXPORT FAILED"; exit 1; }; }
+echo "[noleak] $(date) eval (leakage probe: same mix minus the 164 benchmark-factory rows)"
+GPUS=$(echo $G|cut -d, -f1) TP=1 eval/eval_all_run2.sh $RUN/merged q9b_noleak --max_new 8192 --suites bench blender cadquery 2>&1 | grep -E "status counts|dialect|DONE" | tail -6
+echo "[noleak] ALL DONE"
diff --git a/finetune/scripts/eval_img4_views.sh b/finetune/scripts/eval_img4_views.sh
new file mode 100755
index 00000000..e777da86
--- /dev/null
+++ b/finetune/scripts/eval_img4_views.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Does giving the model all four reference views beat a single view? Same tasks, same executor.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+RUN=runs/lf_qwen35_9b_img4; G=$(scripts/free_gpus.sh | cut -d, -f1)
+python - <<'PY'
+import json, glob, os
+rows=[]
+SYS="You are an expert in procedural 3D modeling with Blender Python (bpy). Given reference renders of an object, write a complete, standalone Blender 5 Python script that reproduces it (clear the default scene first). Output ONLY the code in one ```python block."
+for d in sorted(glob.glob("/wekafs/ict/hx_624/data/3dcodebench/data/*_seed0")):
+ imgs=sorted(glob.glob(os.path.join(d,"images","*.png")))[:4]
+ if not imgs: continue
+ rows.append({"task": os.path.basename(d), "images": imgs,
+ "messages":[{"role":"system","content":SYS},
+ {"role":"user","content":"<image>"*len(imgs)+"\nReproduce this 3D object with Blender Python code."}]})
+open("eval/out/_img4_bench_prompts.jsonl","w").write("\n".join(json.dumps(r) for r in rows))
+print("4-view prompts:", len(rows), "| views per task:", len(rows[0]["images"]))
+PY
+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_img4_bench; mkdir -p $OUT
+python eval/generate_vllm_img.py --model $RUN/merged --prompts eval/out/_img4_bench_prompts.jsonl --out $OUT --max_new_tokens 6144 2>&1 | tail -1
+conda activate llmft
+python eval/run_bench.py --gen_dir $OUT --workers 24 --timeout 300 2>&1 | grep "status counts" | tail -1
+python eval/metrics.py --gen_dir $OUT 2>&1 | tail -1
+echo "[img4eval] ALL DONE"
diff --git a/finetune/scripts/eval_imgmix.sh b/finetune/scripts/eval_imgmix.sh
new file mode 100755
index 00000000..cfb9417f
--- /dev/null
+++ b/finetune/scripts/eval_imgmix.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# The image+text model must be checked on BOTH paths: does adding vision cost anything on plain text prompts,
+# and does joint training beat the image-only model when given a render?
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+RUN=runs/lf_qwen35_9b_imgmix; G=$(scripts/free_gpus.sh)
+[ -f $RUN/merged/config.json ] || { echo "[imgmix] merged model missing"; exit 1; }
+echo "[imgmixeval] $(date) text path"
+GPUS=$(echo $G|cut -d, -f1) TP=1 eval/eval_all_run2.sh $RUN/merged q9b_imgmix --max_new 8192 --suites bench blender cadquery 2>&1 | grep -E "status counts|dialect|DONE" | tail -6
+echo "[imgmixeval] $(date) image path"
+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=$(echo $G|cut -d, -f1)
+OUT=eval/out/q9b_imgmix_img_bench; mkdir -p $OUT
+python eval/generate_vllm_img.py --model $RUN/merged --prompts eval/out/_img_bench_prompts.jsonl --out $OUT --max_new_tokens 6144 2>&1 | tail -1
+conda activate llmft
+python eval/run_bench.py --gen_dir $OUT --workers 24 --timeout 300 2>&1 | grep "status counts" | tail -1
+python eval/metrics.py --gen_dir $OUT 2>&1 | tail -1
+echo "[imgmixeval] ALL DONE"
diff --git a/finetune/scripts/queue.txt b/finetune/scripts/queue.txt
index cfceb234..be2b0fac 100644
--- a/finetune/scripts/queue.txt
+++ b/finetune/scripts/queue.txt
@@ -1,2 +1,3 @@
-v5|scripts/run_27b_v5.sh
-9b_clean|scripts/run_9b_clean.sh
+img4_views|scripts/eval_img4_views.sh
+imgmix_eval|scripts/eval_imgmix.sh
+27b_clean|scripts/run_27b_clean.sh
diff --git a/finetune/scripts/run_27b_clean.sh b/finetune/scripts/run_27b_clean.sh
new file mode 100755
index 00000000..788dce43
--- /dev/null
+++ b/finetune/scripts/run_27b_clean.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+# 27B v4: v2's winning blender-heavy core + CadQuery raised 33k -> 105k unique samples (one caption each).
+# Question: can a single 27B top both 3DCodeBench (v2: 93.4%) and CadQuery (9B md_xl: 97.5%)?
+#
+# 27B LoRA on 80 GB cards sits right at the memory edge — the identical recipe that trained v2 OOMs on other
+# days. So instead of guessing, try a ladder of settings (keeping lora_rank 64, the quality-relevant knob;
+# every sample in this mix is <=3400 tokens, so a smaller cutoff truncates nothing) and take the first that
+# survives 4 real steps.
+set -uo pipefail
+cd /wekafs/ict/hx_624/llm-ft
+GPUS_USE=$(scripts/free_gpus.sh); NGPU=$(echo "$GPUS_USE" | awk -F, '{print NF}')
+[ -z "$GPUS_USE" ] && { echo "[27bclean] no free GPUs"; exit 1; }
+RUN=runs/lf_qwen38_27b_clean
+
+WIN=""
+for SPEC in "3584 5 adamw_torch" "3072 6 adamw_torch" "3072 6 adamw_8bit" "2560 8 adamw_8bit"; do
+ set -- $SPEC; CUT=$1; ACC=$2; OPT=$3
+ echo "[27bclean] $(date) probing cutoff=$CUT accum=$ACC optim=$OPT"
+ EXTRA=""; [ "$OPT" = "adamw_8bit" ] && EXTRA="optim=adamw_8bit"
+ GPUS=$GPUS_USE scripts/lf_train.sh configs/lf/lora_27b_clean.yaml max_steps=4 save_steps=100000 eval_steps=100000 \
+ cutoff_len=$CUT gradient_accumulation_steps=$ACC $EXTRA \
+ tokenized_path=/wekafs/ict/hx_624/llm-ft/data/lf/tok_27bclean_$CUT \
+ output_dir=/wekafs/ict/hx_624/llm-ft/runs/_probe_v4 > logs/probe_v4_$CUT$OPT.log 2>&1
+ rm -rf runs/_probe_v4
+ if grep -q "train_runtime" logs/probe_v4_$CUT$OPT.log; then
+ S=$(grep -oE "[0-9]/4 \[[0-9:]+<[0-9:]+, *[0-9.]+s/it" logs/probe_v4_$CUT$OPT.log | tail -1)
+ echo "[27bclean] OK at cutoff=$CUT accum=$ACC optim=$OPT ($S)"; WIN="$CUT $ACC $OPT"; break
+ fi
+ ERR=$(grep -oE "torch.OutOfMemoryError[^\"]*|Triton Error \[CUDA\]: out of memory|RuntimeError: [^\"]{0,120}" logs/probe_v4_$CUT$OPT.log | tail -1)
+ echo "[27bclean] FAILED at cutoff=$CUT accum=$ACC optim=$OPT -> ${ERR:-unknown error, see logs/probe_v4_$CUT$OPT.log}"
+ case "$ERR" in *"Triton >= 3.4"*|*"tilelang"*) echo "[27bclean] ABORT: the lf env's triton was downgraded (Hopper needs 3.7.1) — fix the env, not the config"; exit 2;; esac
+done
+[ -z "$WIN" ] && { echo "[27bclean] every setting OOMed — needs more GPUs or a sharded optimizer"; exit 1; }
+set -- $WIN; CUT=$1; ACC=$2; OPT=$3
+EXTRA=""; [ "$OPT" = "adamw_8bit" ] && EXTRA="optim=adamw_8bit"
+
+echo "[27bclean] $(date) train (191.7k pairs / 177M tok, leak-free, cutoff=$CUT accum=$ACC optim=$OPT, GPUs $GPUS_USE)"
+GPUS=$GPUS_USE scripts/lf_train.sh configs/lf/lora_27b_clean.yaml cutoff_len=$CUT gradient_accumulation_steps=$ACC $EXTRA \
+ tokenized_path=/wekafs/ict/hx_624/llm-ft/data/lf/tok_27bclean_$CUT > logs/train_27b_v4.log 2>&1
+[ -f $RUN/train_results.json ] || { echo "[27bclean] TRAIN FAILED: $(grep -E 'out of memory|Error' logs/train_27b_v4.log | grep -v errors | tail -1 | cut -c1-160)"; exit 1; }
+echo "[27bclean] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-160)"
+
+sed -e "s|model_name_or_path:.*|model_name_or_path: /wekafs/ict/hx_624/models/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_clean.yaml
+scripts/lf_export.sh configs/lf/export_27b_clean.yaml > logs/export_27b_clean.log 2>&1 || { echo "[27bclean] EXPORT FAILED"; exit 1; }
+echo "[27bclean] $(date) eval greedy"
+GPUS=$GPUS_USE TP=2 eval/eval_all_run2.sh $RUN/merged q27b_clean --max_new 8192 2>&1 | grep -E "gen-multi|status counts|dialect|DONE" | tail -20
+echo "[27bclean] $(date) eval sampled (openscad/glsl)"
+GPUS=$GPUS_USE TP=2 eval/eval_all_run2.sh $RUN/merged q27b_clean_T07 --temp 0.7 --seed 1 --max_new 8192 --suites openscad glsl 2>&1 | grep -E "dialect|DONE" | tail -4
+echo "[27bclean] ALL DONE"
diff --git a/finetune/scripts/run_9b_img.sh b/finetune/scripts/run_9b_img.sh
new file mode 100755
index 00000000..b3a4f59e
--- /dev/null
+++ b/finetune/scripts/run_9b_img.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Image-conditioned pilot: render -> code. The qwen3_5 template already carries the qwen3_vl multimodal plugin,
+# so this is the first run in the project that feeds the model what a caption cannot express — the target's shape.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+G=$(scripts/free_gpus.sh); N=$(echo "$G" | awk -F, '{print NF}')
+echo "[9bimg] $(date) smoke on GPUs $G"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_img.yaml max_steps=6 save_steps=100000 eval_steps=100000 \
+ output_dir=/wekafs/ict/hx_624/llm-ft/runs/_smoke_img > logs/smoke_img.log 2>&1
+if ! grep -q train_runtime logs/smoke_img.log; then
+ echo "[9bimg] SMOKE FAILED: $(grep -iE 'error|Traceback' logs/smoke_img.log | grep -v errors | tail -2 | head -1 | cut -c1-200)"; exit 1
+fi
+rm -rf runs/_smoke_img; echo "[9bimg] smoke ok: $(grep -oE "'train_runtime': [0-9.]+" logs/smoke_img.log | tail -1)"
+echo "[9bimg] $(date) train (7,997 render->code samples, 2 epochs)"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_img.yaml > logs/train_9b_img.log 2>&1
+RUN=runs/lf_qwen35_9b_img
+[ -f $RUN/train_results.json ] || { echo "[9bimg] TRAIN FAILED: $(grep -iE 'out of memory|error' logs/train_9b_img.log | grep -v errors | tail -1 | cut -c1-180)"; exit 1; }
+echo "[9bimg] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-160)"
+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_img.yaml
+scripts/lf_export.sh configs/lf/export_9b_img.yaml > logs/export_9b_img.log 2>&1 || { echo "[9bimg] EXPORT FAILED"; exit 1; }
+echo "[9bimg] ALL DONE"
diff --git a/finetune/scripts/run_9b_img4.sh b/finetune/scripts/run_9b_img4.sh
new file mode 100755
index 00000000..4a551eea
--- /dev/null
+++ b/finetune/scripts/run_9b_img4.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Image-conditioned pilot: render -> code. The qwen3_5 template already carries the qwen3_vl multimodal plugin,
+# so this is the first run in the project that feeds the model what a caption cannot express — the target's shape.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+G=$(scripts/free_gpus.sh); N=$(echo "$G" | awk -F, '{print NF}')
+echo "[9bimg4] $(date) smoke on GPUs $G"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_img4.yaml max_steps=6 save_steps=100000 eval_steps=100000 \
+ output_dir=/wekafs/ict/hx_624/llm-ft/runs/_smoke_img44 > logs/smoke_img4.log 2>&1
+if ! grep -q train_runtime logs/smoke_img4.log; then
+ echo "[9bimg4] SMOKE FAILED: $(grep -iE 'error|Traceback' logs/smoke_img4.log | grep -v errors | tail -2 | head -1 | cut -c1-200)"; exit 1
+fi
+rm -rf runs/_smoke_img44; echo "[9bimg4] smoke ok: $(grep -oE "'train_runtime': [0-9.]+" logs/smoke_img4.log | tail -1)"
+echo "[9bimg4] $(date) train (7,997 4-view render->code samples, 2 epochs)"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_img4.yaml > logs/train_9b_img4.log 2>&1
+RUN=runs/lf_qwen35_9b_img4
+[ -f $RUN/train_results.json ] || { echo "[9bimg4] TRAIN FAILED: $(grep -iE 'out of memory|error' logs/train_9b_img4.log | grep -v errors | tail -1 | cut -c1-180)"; exit 1; }
+echo "[9bimg4] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-160)"
+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_img4.yaml
+scripts/lf_export.sh configs/lf/export_9b_img4.yaml > logs/export_9b_img4.log 2>&1 || { echo "[9bimg4] EXPORT FAILED"; exit 1; }
+echo "[9bimg4] ALL DONE"
diff --git a/finetune/scripts/run_9b_imgmix.sh b/finetune/scripts/run_9b_imgmix.sh
new file mode 100755
index 00000000..51fd3729
--- /dev/null
+++ b/finetune/scripts/run_9b_imgmix.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Image-conditioned pilot: render -> code. The qwen3_5 template already carries the qwen3_vl multimodal plugin,
+# so this is the first run in the project that feeds the model what a caption cannot express — the target's shape.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+G=$(scripts/free_gpus.sh); N=$(echo "$G" | awk -F, '{print NF}')
+echo "[9bimgmix] $(date) smoke on GPUs $G"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_imgmix.yaml max_steps=6 save_steps=100000 eval_steps=100000 \
+ output_dir=/wekafs/ict/hx_624/llm-ft/runs/_smoke_imgmix4 > logs/smoke_imgmix.log 2>&1
+if ! grep -q train_runtime logs/smoke_imgmix.log; then
+ echo "[9bimgmix] SMOKE FAILED: $(grep -iE 'error|Traceback' logs/smoke_imgmix.log | grep -v errors | tail -2 | head -1 | cut -c1-200)"; exit 1
+fi
+rm -rf runs/_smoke_imgmix4; echo "[9bimgmix] smoke ok: $(grep -oE "'train_runtime': [0-9.]+" logs/smoke_imgmix.log | tail -1)"
+echo "[9bimgmix] $(date) train (7,997 4-view render->code samples, 2 epochs)"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_imgmix.yaml > logs/train_9b_imgmix.log 2>&1
+RUN=runs/lf_qwen35_9b_imgmix
+[ -f $RUN/train_results.json ] || { echo "[9bimgmix] TRAIN FAILED: $(grep -iE 'out of memory|error' logs/train_9b_imgmix.log | grep -v errors | tail -1 | cut -c1-180)"; exit 1; }
+echo "[9bimgmix] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-160)"
+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_imgmix.yaml
+scripts/lf_export.sh configs/lf/export_9b_imgmix.yaml > logs/export_9b_imgmix.log 2>&1 || { echo "[9bimgmix] EXPORT FAILED"; exit 1; }
+echo "[9bimgmix] ALL DONE"
diff --git a/finetune/scripts/run_9b_noleak.sh b/finetune/scripts/run_9b_noleak.sh
new file mode 100755
index 00000000..27a51669
--- /dev/null
+++ b/finetune/scripts/run_9b_noleak.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Leakage probe: identical to the md_9b_clean run except the 164 rows whose source is a 3DCodeBench factory.
+# Measures what that 0.09% of contamination is actually worth on the benchmark.
+set -uo pipefail; cd /wekafs/ict/hx_624/llm-ft
+G=$(scripts/free_gpus.sh)
+echo "[noleak] $(date) train on GPUs $G"
+GPUS=$G scripts/lf_train.sh configs/lf/lora_9b_noleak.yaml > logs/train_9b_noleak.log 2>&1
+RUN=runs/lf_qwen35_9b_lora_noleak
+[ -f $RUN/train_results.json ] || { echo "[noleak] TRAIN FAILED: $(grep -iE 'out of memory|error' logs/train_9b_noleak.log | grep -v errors | tail -1 | cut -c1-160)"; exit 1; }
+echo "[noleak] $(date) train done: $(tr -d '\n' < $RUN/train_results.json | cut -c1-140)"
+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_noleak.yaml
+scripts/lf_export.sh configs/lf/export_9b_noleak.yaml > logs/export_9b_noleak.log 2>&1 || { echo "[noleak] EXPORT FAILED"; exit 1; }
+GPUS=0 TP=1 eval/eval_all_run2.sh $RUN/merged q9b_noleak --max_new 8192 --suites bench blender cadquery 2>&1 | grep -E "status counts|dialect|DONE" | tail -8
+echo "[noleak] ALL DONE"