LJYAI commited on
Commit
6566bee
·
verified ·
1 Parent(s): 8d56174

Qwen3-8B Base 50pct replaceme PPL Bench14

Browse files
Files changed (43) hide show
  1. .gitattributes +1 -0
  2. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/abprune_compact.py +284 -0
  3. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/bootstrap_qwen3_base_half2.sh +48 -0
  4. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/come.py +612 -0
  5. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/eval_llama31_8b_12bench.py +194 -0
  6. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/eval_opencompass_ppl_fast.py +231 -0
  7. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/evaluate_hchc_wikitext2_ppl.py +152 -0
  8. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/mka.py +505 -0
  9. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/mka_transport.py +232 -0
  10. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/replaceme_llama_instruction_mask_bf16.patch +46 -0
  11. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/replaceme_qwen_layer_types.patch +25 -0
  12. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_come_pruning.py +115 -0
  13. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_mka_pruning.py +431 -0
  14. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_8b_base_replaceme_depth.sh +132 -0
  15. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_8b_native_span_transport_additive_u.sh +161 -0
  16. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_base_half2.py +254 -0
  17. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/environment.json +15 -0
  18. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_14bench.json +37 -0
  19. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_lmeval9.json +1401 -0
  20. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_opencompass5.json +44 -0
  21. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_ppl.json +17 -0
  22. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/execution.json +33 -0
  23. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/aggregate.log +38 -0
  24. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/lmeval.log +0 -0
  25. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/opencompass.log +80 -0
  26. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/ppl.log +23 -0
  27. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/pruning.log +6 -0
  28. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/train.log +20 -0
  29. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/manifest.json +212 -0
  30. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/chat_template.jinja +85 -0
  31. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/config.json +53 -0
  32. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/generation_config.json +7 -0
  33. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/model.safetensors +3 -0
  34. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/tokenizer.json +3 -0
  35. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/tokenizer_config.json +30 -0
  36. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/offline_eval.json +15 -0
  37. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/protocol.json +78 -0
  38. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/protocol.md +37 -0
  39. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/COMPLETE +0 -0
  40. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/selection.json +2119 -0
  41. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/selection.log +50 -0
  42. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/slimpajama500_seed42.pt +3 -0
  43. runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/summary.json +77 -0
.gitattributes CHANGED
@@ -240,3 +240,4 @@ runs/vast-paper_revision-qwen3-base-race9-54818226-20261008/20261008-qwen3-base-
240
  runs/vast-paper_revision-qwen3-base-race9-54818226-20261008/20261008-qwen3-base-race-lmeval9/transport/race_samples.json filter=lfs diff=lfs merge=lfs -text
241
  runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/come/model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
242
  runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/mka/model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
240
  runs/vast-paper_revision-qwen3-base-race9-54818226-20261008/20261008-qwen3-base-race-lmeval9/transport/race_samples.json filter=lfs diff=lfs merge=lfs -text
241
  runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/come/model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
242
  runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/mka/model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
243
+ runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/abprune_compact.py ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Package and reconstruct compact ABPrune stage checkpoints.
2
+
3
+ ABPrune already writes ``fused_layer.pt`` for every cycle. This utility makes
4
+ those files portable by pairing them with an explicit, immutable stage record;
5
+ the dense base model plus that record is sufficient to reconstruct a student.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import argparse, hashlib, json, shutil
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ import torch
14
+
15
+
16
+ def copy_stage_state(src: Path, dst: Path, *, hard_link: bool = False) -> None:
17
+ """Optionally share immutable stage bytes within one experiment filesystem."""
18
+ if not hard_link:
19
+ shutil.copy2(src, dst)
20
+ elif dst.exists():
21
+ if not src.samefile(dst):
22
+ raise FileExistsError(f"Refusing to replace existing non-linked stage: {dst}")
23
+ else:
24
+ # Fail instead of silently consuming space if cross-device linking is
25
+ # unavailable. The caller explicitly selected the storage strategy.
26
+ dst.hardlink_to(src)
27
+
28
+
29
+ def sha256(path: Path) -> str:
30
+ h = hashlib.sha256()
31
+ with path.open("rb") as f:
32
+ for chunk in iter(lambda: f.read(8 * 1024 * 1024), b""):
33
+ h.update(chunk)
34
+ return h.hexdigest()
35
+
36
+
37
+ def post_merge_scale(source_cycle: Path) -> dict | None:
38
+ """Return the deployable post-merge scale stored for a cycle, if present."""
39
+ metadata_path = source_cycle / "cycle_metadata.json"
40
+ if not metadata_path.is_file():
41
+ return None
42
+ metadata = json.loads(metadata_path.read_text(encoding="utf-8"))
43
+ distill = metadata.get("distill", {})
44
+ scale = distill.get("post_merge_nll_scale") or {}
45
+ source = "post_merge_nll"
46
+ if not scale.get("enabled"):
47
+ scale = (distill.get("reparam_stats") or {}).get("residual_scale") or {}
48
+ source = "scale_aware_fit"
49
+ if not scale.get("enabled"):
50
+ return None
51
+ gamma = scale["gamma"]
52
+ cumulative_gamma = scale["cumulative_gamma"]
53
+ if not isinstance(gamma, list):
54
+ gamma = float(gamma)
55
+ else:
56
+ gamma = [float(value) for value in gamma]
57
+ if not isinstance(cumulative_gamma, list):
58
+ cumulative_gamma = float(cumulative_gamma)
59
+ else:
60
+ cumulative_gamma = [float(value) for value in cumulative_gamma]
61
+ result = {
62
+ "enabled": True,
63
+ "mode": scale.get("mode", "residual"),
64
+ "scale_parameterization": scale.get("scale_parameterization", "scalar"),
65
+ "gamma": gamma,
66
+ "cumulative_gamma": cumulative_gamma,
67
+ "source": source,
68
+ }
69
+ for field in (
70
+ "optimization_mode",
71
+ "gamma_gradient_sources",
72
+ "theta_gradient_sources",
73
+ "nll_used",
74
+ ):
75
+ if field in scale:
76
+ result[field] = scale[field]
77
+ if "cumulative_gamma_statistics" in scale:
78
+ result["cumulative_gamma_statistics"] = scale["cumulative_gamma_statistics"]
79
+ if "raw" in scale and "ppl" in scale["raw"]:
80
+ result["calibration_raw_ppl"] = float(scale["raw"]["ppl"])
81
+ if "fitted" in scale and "ppl" in scale["fitted"]:
82
+ result["calibration_fitted_ppl"] = float(scale["fitted"]["ppl"])
83
+ return result
84
+
85
+
86
+ def read_compact_metadata(compact_stage: Path) -> dict[str, Any]:
87
+ return json.loads((compact_stage / "metadata.json").read_text(encoding="utf-8"))
88
+
89
+
90
+ def compact_scale_targets(metadata: dict[str, Any]) -> list[dict[str, Any]]:
91
+ """Return residual scales and current student indices for a compact stage."""
92
+ if metadata.get("format") == "abprune_compact_stage_v2":
93
+ active = [int(value) for value in metadata["active_original_layers"]]
94
+ current_index = {original: index for index, original in enumerate(active)}
95
+ targets = []
96
+ for state in metadata.get("retained_layer_states", []):
97
+ scale = state.get("post_merge_scale") or {}
98
+ if scale.get("enabled") and scale.get("mode") == "residual":
99
+ original = int(state["original_layer"])
100
+ targets.append(
101
+ {
102
+ "original_layer": original,
103
+ "student_index": current_index[original],
104
+ "scale": scale,
105
+ }
106
+ )
107
+ return targets
108
+
109
+ scale = metadata.get("post_merge_scale") or {}
110
+ if scale.get("enabled") and scale.get("mode") == "residual":
111
+ return [
112
+ {
113
+ "original_layer": int(metadata["anchor_index"]),
114
+ "student_index": int(metadata["anchor_index"]),
115
+ "scale": scale,
116
+ }
117
+ ]
118
+ return []
119
+
120
+
121
+ def _package_topology_aware(args, source: Path, out: Path, order: list[int]) -> None:
122
+ """Package cycles whose recipients may switch between pair boundaries."""
123
+ if int(getattr(args, "start_cycle", 1)) != 1:
124
+ raise ValueError("topology-aware compact packaging must start at cycle 1")
125
+
126
+ removed: set[int] = set()
127
+ latest_states: dict[int, dict[str, Any]] = {}
128
+ stages: list[dict[str, Any]] = []
129
+ original_layer_count: int | None = None
130
+
131
+ for cycle in range(1, args.cycles + 1):
132
+ source_cycle = source / f"cycle_{cycle}"
133
+ src = source_cycle / "fused_layer.pt"
134
+ if not src.is_file():
135
+ raise FileNotFoundError(src)
136
+ cycle_metadata_path = source_cycle / "cycle_metadata.json"
137
+ if not cycle_metadata_path.is_file():
138
+ raise FileNotFoundError(cycle_metadata_path)
139
+ cycle_metadata = json.loads(cycle_metadata_path.read_text(encoding="utf-8"))
140
+ recipient = int(cycle_metadata["recipient_original_layer"])
141
+ removed_original = int(cycle_metadata["removed_original_layer"])
142
+ recipient_side = str(cycle_metadata["recipient_side"])
143
+ if recipient_side not in {"left", "right"}:
144
+ raise ValueError(f"invalid recipient_side at cycle {cycle}: {recipient_side}")
145
+ if original_layer_count is None:
146
+ original_layer_count = int(cycle_metadata["num_layers_before"])
147
+ if removed_original in removed:
148
+ raise ValueError(f"original layer {removed_original} removed more than once")
149
+ if recipient in removed:
150
+ raise ValueError(f"cycle {cycle} selects removed recipient {recipient}")
151
+
152
+ removed.add(removed_original)
153
+ latest_states.pop(removed_original, None)
154
+ latest_states[recipient] = {
155
+ "original_layer": recipient,
156
+ "source_cycle": cycle,
157
+ "recipient_side": recipient_side,
158
+ "source_state": src,
159
+ "post_merge_scale": post_merge_scale(source_cycle),
160
+ }
161
+
162
+ stage_dir = out / f"stage_{cycle:02d}"
163
+ stage_dir.mkdir(exist_ok=True)
164
+ retained_states = []
165
+ for original, record in sorted(latest_states.items()):
166
+ state_name = f"layer_original_{original:04d}.pt"
167
+ state_path = stage_dir / state_name
168
+ copy_stage_state(record["source_state"], state_path, hard_link=bool(getattr(args, "hard_link", False)))
169
+ packaged = {
170
+ "original_layer": original,
171
+ "state_file": state_name,
172
+ "sha256": sha256(state_path),
173
+ "source_cycle": int(record["source_cycle"]),
174
+ "recipient_side": record["recipient_side"],
175
+ }
176
+ if record["post_merge_scale"] is not None:
177
+ packaged["post_merge_scale"] = record["post_merge_scale"]
178
+ retained_states.append(packaged)
179
+
180
+ assert original_layer_count is not None
181
+ active = [
182
+ original
183
+ for original in range(original_layer_count)
184
+ if original not in removed
185
+ ]
186
+ meta = {
187
+ "format": "abprune_compact_stage_v2",
188
+ "model": args.model,
189
+ "base_model_revision": args.base_revision,
190
+ "run_id": args.run_id,
191
+ "target_prune_count": args.cycles,
192
+ "stage": cycle,
193
+ "removed_count": len(removed),
194
+ "original_layer_count": original_layer_count,
195
+ "layer_order": order,
196
+ "latest_pair_index": order[cycle - 1],
197
+ "latest_recipient_side": recipient_side,
198
+ "latest_recipient_original_layer": recipient,
199
+ "latest_removed_original_layer": removed_original,
200
+ "removed_original_layers": sorted(removed),
201
+ "active_original_layers": active,
202
+ "retained_layer_states": retained_states,
203
+ "source_cycle": f"cycle_{cycle}",
204
+ }
205
+ (stage_dir / "metadata.json").write_text(
206
+ json.dumps(meta, indent=2) + "\n", encoding="utf-8"
207
+ )
208
+ stages.append(meta)
209
+
210
+ manifest = {
211
+ "format": "abprune_compact_manifest_v2",
212
+ "model": args.model,
213
+ "base_model_revision": args.base_revision,
214
+ "run_id": args.run_id,
215
+ "target_prune_count": args.cycles,
216
+ "original_layer_count": original_layer_count,
217
+ "layer_order": order,
218
+ "stages": stages,
219
+ }
220
+ (out / "manifest.json").write_text(
221
+ json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
222
+ )
223
+
224
+
225
+ def package(args):
226
+ source = Path(args.run_root); out = Path(args.output_root); out.mkdir(parents=True, exist_ok=True)
227
+ order = [int(x) for x in args.layer_order.replace(',', ' ').split()]
228
+ start_cycle = int(getattr(args, "start_cycle", 1))
229
+ expected_order = args.cycles - start_cycle + 1
230
+ if not 1 <= start_cycle <= args.cycles:
231
+ raise ValueError("start_cycle must be between 1 and cycles")
232
+ if len(order) != expected_order:
233
+ raise ValueError("layer_order length must equal cycles - start_cycle + 1")
234
+ first_metadata_path = source / f"cycle_{start_cycle}" / "cycle_metadata.json"
235
+ if first_metadata_path.is_file():
236
+ first_metadata = json.loads(first_metadata_path.read_text(encoding="utf-8"))
237
+ topology_fields = {
238
+ "recipient_side",
239
+ "recipient_original_layer",
240
+ "removed_original_layer",
241
+ }
242
+ if topology_fields.issubset(first_metadata):
243
+ _package_topology_aware(args, source, out, order)
244
+ return
245
+ stages = []
246
+ for cycle in range(start_cycle, args.cycles + 1):
247
+ order_index = cycle - start_cycle
248
+ source_cycle = source / f"cycle_{cycle}"
249
+ src = source_cycle / "fused_layer.pt"
250
+ if not src.exists(): raise FileNotFoundError(src)
251
+ dst_dir = out / f"stage_{cycle:02d}"; dst_dir.mkdir(exist_ok=True)
252
+ dst = dst_dir / "anchor_layer.pt"; copy_stage_state(src, dst, hard_link=bool(getattr(args, "hard_link", False)))
253
+ meta = {
254
+ "format": "abprune_compact_stage_v1", "model": args.model,
255
+ "base_model_revision": args.base_revision, "run_id": args.run_id,
256
+ "target_prune_count": args.cycles, "stage": cycle,
257
+ "removed_count": cycle, "anchor_index": order[order_index],
258
+ "layer_order": order,
259
+ "packaged_stage_range": [start_cycle, args.cycles],
260
+ "removed_original_layers": list(range(order[order_index] + 1, order[order_index] + cycle + 1)),
261
+ "source_cycle": f"cycle_{cycle}", "anchor_state_file": "anchor_layer.pt",
262
+ "sha256": sha256(dst),
263
+ }
264
+ scale = post_merge_scale(source_cycle)
265
+ if scale is not None:
266
+ meta["post_merge_scale"] = scale
267
+ (dst_dir / "metadata.json").write_text(json.dumps(meta, indent=2) + "\n", encoding="utf-8")
268
+ stages.append(meta)
269
+ manifest = {"format": "abprune_compact_manifest_v1", "model": args.model,
270
+ "base_model_revision": args.base_revision, "run_id": args.run_id,
271
+ "target_prune_count": args.cycles, "layer_order": order, "stages": stages}
272
+ (out / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
273
+
274
+
275
+ def main():
276
+ p = argparse.ArgumentParser(); p.add_argument("--run-root", required=True); p.add_argument("--output-root", required=True)
277
+ p.add_argument("--model", required=True); p.add_argument("--base-revision", required=True); p.add_argument("--run-id", required=True)
278
+ p.add_argument("--cycles", type=int, required=True); p.add_argument("--layer-order", required=True)
279
+ p.add_argument("--start-cycle", type=int, default=1)
280
+ p.add_argument("--hard-link", action="store_true", help="Hard-link immutable stage weights on the same filesystem")
281
+ package(p.parse_args())
282
+
283
+
284
+ if __name__ == "__main__": main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/bootstrap_qwen3_base_half2.sh ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ project="$1"; external="$2"; root="$3"; model="$4"
4
+ export HF_HOME=/workspace/.hf_home HF_TOKEN_PATH=/root/.cache/huggingface/token
5
+ export HF_DATASETS_CACHE=/workspace/.hf_datasets36 HF_DATASETS_TRUST_REMOTE_CODE=1
6
+ export PYTHONUNBUFFERED=1 TOKENIZERS_PARALLELISM=false OMP_NUM_THREADS=4
7
+ export PYTHONPATH="$project/src:$external/src:$project"
8
+ mkdir -p "$root"
9
+ trap 'rc=$?; if ((rc)); then touch "$root/BOOTSTRAP_FAILED"; fi' EXIT
10
+ bash "$project/scripts/bootstrap_qwen3_8b_mergeinit_fit2.sh" "$project" "$external" "$root" "$model"
11
+ python -m pip install peft einops threadpoolctl
12
+ touch "$model/.model_download_complete"
13
+ # Original selector and ReplaceMe are isolated from the patched training engine.
14
+ legacy="${external}-legacy"
15
+ if [[ ! -d "$legacy/.git" ]]; then
16
+ git clone "$project/vendor/abprune_experiment_base_39e.bundle" "$legacy"
17
+ git -C "$legacy" remote remove origin
18
+ fi
19
+ git -C "$legacy" apply "$project/patches/replaceme_llama_instruction_mask_bf16.patch"
20
+ git -C "$legacy" apply "$project/patches/replaceme_qwen_layer_types.patch"
21
+ python - "$root" <<'PY'
22
+ import importlib.metadata as m, json, platform, sys
23
+ from pathlib import Path
24
+ import torch
25
+ r=Path(sys.argv[1])
26
+ e={'python':platform.python_version(),'torch':torch.__version__,'cuda':torch.version.cuda,
27
+ 'packages':{n:m.version(n) for n in ['transformers','datasets','huggingface_hub','lm_eval','accelerate','scipy','scikit-learn','peft']}}
28
+ (r/'environment.json').write_text(json.dumps(e,indent=2)+'\n')
29
+ print('ENVIRONMENT',json.dumps(e),flush=True)
30
+ PY
31
+ while [[ ! -f "$root/EVAL_ASSETS_READY" ]]; do sleep 3; done
32
+ python - "$root" <<'PY'
33
+ import hashlib,sys
34
+ from pathlib import Path
35
+ r=Path(sys.argv[1])
36
+ for n,h in [('opencompass5-data.tar.gz','b49605cc272cee94ddc177d2350e06d70f0f610926a2abf20c8ccd35ad8cd353'),('lmeval-cache-131.tar.gz','e5a319ed00b52181df3d80e47e4939e78fddd393803c29a9bcb63c2dd8a6d468')]:
37
+ assert hashlib.sha256((r/n).read_bytes()).hexdigest()==h,n
38
+ PY
39
+ mkdir -p "$root/eval_data"
40
+ tar -xzf "$root/opencompass5-data.tar.gz" -C "$root/eval_data"
41
+ tar -xzf "$root/lmeval-cache-131.tar.gz" -C "$root"
42
+ HF_HUB_OFFLINE=1 HF_DATASETS_OFFLINE=1 python "$project/scripts/prepare_lmeval9_local_cache.py" "$root/lmeval_cache" --validate-local
43
+ python - <<'PY'
44
+ from datasets import load_dataset
45
+ load_dataset('Salesforce/wikitext','wikitext-2-raw-v1')
46
+ PY
47
+ python "$project/scripts/prepare_offline_ppl_cache.py" "$root"
48
+ touch "$root/EVAL_READY" "$root/HALF_READY"
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/come.py ADDED
@@ -0,0 +1,612 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Native Hugging Face implementation of CoMe structured layer pruning.
2
+
3
+ This module implements the pruning-only portion of CoMe for decoder-only
4
+ models whose blocks use Llama-style attention and gated MLP projections. It
5
+ intentionally does not implement post-pruning distillation.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import math
12
+ from dataclasses import asdict, dataclass
13
+ from pathlib import Path
14
+ from typing import Iterable, Sequence
15
+
16
+ import torch
17
+ from torch import Tensor, nn
18
+ from tqdm.auto import tqdm
19
+
20
+
21
+ @dataclass
22
+ class CalibrationScores:
23
+ """Scores collected from one pass over the calibration sequences."""
24
+
25
+ block_importance: list[float]
26
+ pair_similarity: list[float]
27
+ attention_groups: list[Tensor]
28
+ mlp_neurons: list[Tensor]
29
+
30
+
31
+ @dataclass
32
+ class MergeRecord:
33
+ step: int
34
+ left_index: int
35
+ source_layers: list[list[int]]
36
+ retention_ratios: list[float]
37
+ retained_attention_groups: list[int]
38
+ retained_mlp_neurons: list[int]
39
+ pair_score: float
40
+
41
+
42
+ def allocate_retained_channels(total: int, ratios: Sequence[float]) -> list[int]:
43
+ """Allocate exactly ``total`` channels, putting rounding slack in the max arm."""
44
+
45
+ if total < 1:
46
+ raise ValueError("total must be positive")
47
+ if not ratios or any(value < 0 for value in ratios):
48
+ raise ValueError("ratios must be a non-empty sequence of non-negative values")
49
+ ratio_sum = float(sum(ratios))
50
+ if ratio_sum <= 0:
51
+ normalized = [1.0 / len(ratios)] * len(ratios)
52
+ else:
53
+ normalized = [float(value) / ratio_sum for value in ratios]
54
+
55
+ largest = max(range(len(normalized)), key=normalized.__getitem__)
56
+ counts = [0] * len(normalized)
57
+ for index, ratio in enumerate(normalized):
58
+ if index != largest:
59
+ counts[index] = math.floor(total * ratio)
60
+ counts[largest] = total - sum(counts)
61
+ return counts
62
+
63
+
64
+ def gqa_projection_indices(
65
+ groups: Tensor,
66
+ *,
67
+ num_attention_heads: int,
68
+ num_key_value_heads: int,
69
+ head_dim: int,
70
+ ) -> tuple[Tensor, Tensor]:
71
+ """Return Q and KV row indices for complete GQA groups.
72
+
73
+ Hugging Face stores query heads contiguously by KV group. Expanding a KV
74
+ mask with ``repeat`` mixes these groups for GQA models; this explicit
75
+ mapping keeps all query heads belonging to each selected KV head together.
76
+ """
77
+
78
+ if num_attention_heads % num_key_value_heads:
79
+ raise ValueError("num_attention_heads must be divisible by num_key_value_heads")
80
+ queries_per_kv = num_attention_heads // num_key_value_heads
81
+ q_parts: list[Tensor] = []
82
+ kv_parts: list[Tensor] = []
83
+ for group in groups.to(dtype=torch.long, device="cpu").tolist():
84
+ if group < 0 or group >= num_key_value_heads:
85
+ raise IndexError(f"KV group {group} is outside [0, {num_key_value_heads})")
86
+ q_start = group * queries_per_kv * head_dim
87
+ kv_start = group * head_dim
88
+ q_parts.append(torch.arange(q_start, q_start + queries_per_kv * head_dim))
89
+ kv_parts.append(torch.arange(kv_start, kv_start + head_dim))
90
+ empty = torch.empty(0, dtype=torch.long)
91
+ return (
92
+ torch.cat(q_parts) if q_parts else empty,
93
+ torch.cat(kv_parts) if kv_parts else empty,
94
+ )
95
+
96
+
97
+ def _copy_tensor(target: Tensor, value: Tensor) -> None:
98
+ with torch.no_grad():
99
+ target.copy_(value.to(device=target.device, dtype=target.dtype))
100
+
101
+
102
+ def _selected_indices(scores: Tensor, count: int) -> Tensor:
103
+ if count == 0:
104
+ return torch.empty(0, dtype=torch.long)
105
+ if count > scores.numel():
106
+ raise ValueError(f"cannot select {count} values from {scores.numel()} scores")
107
+ # Sorting the selected indices preserves the original within-layer order.
108
+ return torch.sort(torch.topk(scores.float(), count, largest=True).indices).values.cpu()
109
+
110
+
111
+ def _cat_selected(
112
+ modules: Sequence[nn.Linear],
113
+ indices: Sequence[Tensor],
114
+ *,
115
+ dimension: int,
116
+ ) -> Tensor:
117
+ chunks = []
118
+ for module, selected in zip(modules, indices, strict=True):
119
+ chunks.append(torch.index_select(module.weight.detach(), dimension, selected.to(module.weight.device)))
120
+ return torch.cat(chunks, dim=dimension)
121
+
122
+
123
+ def _weighted_optional_bias(modules: Sequence[nn.Linear], ratios: Sequence[float]) -> Tensor | None:
124
+ biases = [module.bias for module in modules]
125
+ if all(bias is None for bias in biases):
126
+ return None
127
+ if any(bias is None for bias in biases):
128
+ raise ValueError("projection bias presence differs across the layers being merged")
129
+ assert all(bias is not None for bias in biases)
130
+ result = torch.zeros_like(biases[0])
131
+ for bias, ratio in zip(biases, ratios, strict=True):
132
+ result.add_(bias.detach().to(result.device), alpha=float(ratio))
133
+ return result
134
+
135
+
136
+ def merge_attention(
137
+ layers: Sequence[nn.Module],
138
+ ratios: Sequence[float],
139
+ group_scores: Sequence[Tensor],
140
+ ) -> list[int]:
141
+ """Merge attention projections in-place into the first decoder layer."""
142
+
143
+ attentions = [layer.self_attn for layer in layers]
144
+ first = attentions[0]
145
+ q_heads = int(first.config.num_attention_heads)
146
+ kv_heads = int(first.config.num_key_value_heads)
147
+ head_dim = int(getattr(first, "head_dim", first.q_proj.out_features // q_heads))
148
+ counts = allocate_retained_channels(kv_heads, ratios)
149
+ groups = [_selected_indices(score, count) for score, count in zip(group_scores, counts, strict=True)]
150
+ q_indices: list[Tensor] = []
151
+ kv_indices: list[Tensor] = []
152
+ for selected in groups:
153
+ q_index, kv_index = gqa_projection_indices(
154
+ selected,
155
+ num_attention_heads=q_heads,
156
+ num_key_value_heads=kv_heads,
157
+ head_dim=head_dim,
158
+ )
159
+ q_indices.append(q_index)
160
+ kv_indices.append(kv_index)
161
+
162
+ q_modules = [attention.q_proj for attention in attentions]
163
+ k_modules = [attention.k_proj for attention in attentions]
164
+ v_modules = [attention.v_proj for attention in attentions]
165
+ o_modules = [attention.o_proj for attention in attentions]
166
+ q_weight = _cat_selected(q_modules, q_indices, dimension=0)
167
+ k_weight = _cat_selected(k_modules, kv_indices, dimension=0)
168
+ v_weight = _cat_selected(v_modules, kv_indices, dimension=0)
169
+ o_weight = _cat_selected(o_modules, q_indices, dimension=1)
170
+
171
+ _copy_tensor(first.q_proj.weight, q_weight)
172
+ _copy_tensor(first.k_proj.weight, k_weight)
173
+ _copy_tensor(first.v_proj.weight, v_weight)
174
+ _copy_tensor(first.o_proj.weight, o_weight)
175
+ for destination, source_modules, selected in (
176
+ (first.q_proj, q_modules, q_indices),
177
+ (first.k_proj, k_modules, kv_indices),
178
+ (first.v_proj, v_modules, kv_indices),
179
+ ):
180
+ biases = [module.bias for module in source_modules]
181
+ if not all(bias is None for bias in biases):
182
+ if any(bias is None for bias in biases):
183
+ raise ValueError("projection bias presence differs across merged layers")
184
+ bias_chunks = [
185
+ torch.index_select(module.bias.detach(), 0, index.to(module.bias.device))
186
+ for module, index in zip(source_modules, selected, strict=True)
187
+ ]
188
+ assert destination.bias is not None
189
+ _copy_tensor(destination.bias, torch.cat(bias_chunks))
190
+ merged_o_bias = _weighted_optional_bias(o_modules, ratios)
191
+ if merged_o_bias is not None:
192
+ assert first.o_proj.bias is not None
193
+ _copy_tensor(first.o_proj.bias, merged_o_bias)
194
+
195
+ # Qwen3 applies a shared per-head RMSNorm after Q/K projection. It cannot
196
+ # be sliced by group, so use the same convex merge as other shared values.
197
+ for norm_name in ("q_norm", "k_norm"):
198
+ norms = [getattr(attention, norm_name, None) for attention in attentions]
199
+ if all(norm is None for norm in norms):
200
+ continue
201
+ if any(norm is None for norm in norms):
202
+ raise ValueError(f"{norm_name} presence differs across merged layers")
203
+ destination = norms[0]
204
+ merged = torch.zeros_like(destination.weight)
205
+ for norm, ratio in zip(norms, ratios, strict=True):
206
+ merged.add_(norm.weight.detach().to(merged.device), alpha=float(ratio))
207
+ _copy_tensor(destination.weight, merged)
208
+
209
+ return counts
210
+
211
+
212
+ def merge_mlp(
213
+ layers: Sequence[nn.Module],
214
+ ratios: Sequence[float],
215
+ neuron_scores: Sequence[Tensor],
216
+ ) -> list[int]:
217
+ """Merge gated MLP projections in-place into the first decoder layer."""
218
+
219
+ mlps = [layer.mlp for layer in layers]
220
+ intermediate_size = int(mlps[0].gate_proj.out_features)
221
+ counts = allocate_retained_channels(intermediate_size, ratios)
222
+ selected = [_selected_indices(score, count) for score, count in zip(neuron_scores, counts, strict=True)]
223
+
224
+ for name in ("gate_proj", "up_proj"):
225
+ modules = [getattr(mlp, name) for mlp in mlps]
226
+ merged = _cat_selected(modules, selected, dimension=0)
227
+ destination = getattr(mlps[0], name)
228
+ _copy_tensor(destination.weight, merged)
229
+ biases = [module.bias for module in modules]
230
+ if not all(bias is None for bias in biases):
231
+ if any(bias is None for bias in biases):
232
+ raise ValueError(f"{name} bias presence differs across merged layers")
233
+ bias_chunks = [
234
+ torch.index_select(module.bias.detach(), 0, index.to(module.bias.device))
235
+ for module, index in zip(modules, selected, strict=True)
236
+ ]
237
+ assert destination.bias is not None
238
+ _copy_tensor(destination.bias, torch.cat(bias_chunks))
239
+
240
+ down_modules = [mlp.down_proj for mlp in mlps]
241
+ _copy_tensor(mlps[0].down_proj.weight, _cat_selected(down_modules, selected, dimension=1))
242
+ merged_bias = _weighted_optional_bias(down_modules, ratios)
243
+ if merged_bias is not None:
244
+ assert mlps[0].down_proj.bias is not None
245
+ _copy_tensor(mlps[0].down_proj.bias, merged_bias)
246
+ return counts
247
+
248
+
249
+ def merge_norms(layers: Sequence[nn.Module]) -> None:
250
+ """Average the two residual-stream norms into the destination block."""
251
+
252
+ for name in ("input_layernorm", "post_attention_layernorm"):
253
+ norms = [getattr(layer, name) for layer in layers]
254
+ destination = norms[0]
255
+ _copy_tensor(destination.weight, torch.stack([norm.weight.detach().to(destination.weight.device) for norm in norms]).mean(0))
256
+ destination_bias = getattr(destination, "bias", None)
257
+ if destination_bias is not None:
258
+ source_biases = [getattr(norm, "bias", None) for norm in norms]
259
+ if any(bias is None for bias in source_biases):
260
+ raise ValueError(f"{name} bias presence differs across merged layers")
261
+ _copy_tensor(
262
+ destination_bias,
263
+ torch.stack([bias.detach().to(destination_bias.device) for bias in source_biases]).mean(0),
264
+ )
265
+
266
+
267
+ def compute_retention_ratios(
268
+ importance: Sequence[float],
269
+ *,
270
+ power: float,
271
+ minimum: float,
272
+ ) -> list[float]:
273
+ if power < 0:
274
+ raise ValueError("power must be non-negative")
275
+ if not 0 <= minimum <= 1:
276
+ raise ValueError("minimum must be in [0, 1]")
277
+ values = [max(float(value), 0.0) ** power for value in importance]
278
+ total = sum(values)
279
+ ratios = [value / total for value in values] if total > 0 else [1 / len(values)] * len(values)
280
+ largest = max(range(len(ratios)), key=ratios.__getitem__)
281
+ if ratios[largest] < minimum:
282
+ if len(ratios) == 1:
283
+ return [1.0]
284
+ remainder = sum(ratios) - ratios[largest]
285
+ scale = (1.0 - minimum) / remainder if remainder > 0 else 0.0
286
+ ratios = [ratio * scale for ratio in ratios]
287
+ ratios[largest] = minimum
288
+ return ratios
289
+
290
+
291
+ class _ProjectionScoreCollector:
292
+ def __init__(self, modules: Sequence[nn.Linear]):
293
+ self.scores = [torch.zeros(module.in_features, dtype=torch.float64) for module in modules]
294
+ self._handles = []
295
+ for index, module in enumerate(modules):
296
+ self._handles.append(module.register_forward_pre_hook(self._hook(index)))
297
+
298
+ def _hook(self, index: int):
299
+ def collect(module: nn.Linear, inputs: tuple[Tensor, ...]) -> None:
300
+ activation = inputs[0].detach().float().abs()
301
+ reduce_dims = tuple(range(activation.ndim - 1))
302
+ activation_sum = activation.sum(dim=reduce_dims)
303
+ weight_l1 = module.weight.detach().float().abs().sum(dim=0)
304
+ self.scores[index].add_((activation_sum * weight_l1).double().cpu())
305
+
306
+ return collect
307
+
308
+ def close(self) -> None:
309
+ for handle in self._handles:
310
+ handle.remove()
311
+
312
+
313
+ def _angular_distance(left: Tensor, right: Tensor, *, last_token_only: bool) -> Tensor:
314
+ if last_token_only:
315
+ left = left[:, -1:, :]
316
+ right = right[:, -1:, :]
317
+ cosine = torch.nn.functional.cosine_similarity(left.float(), right.float(), dim=-1)
318
+ if last_token_only:
319
+ return torch.acos(cosine.clamp(0, 1)) / math.pi
320
+ return 1 - cosine
321
+
322
+
323
+ @torch.inference_mode()
324
+ def collect_calibration_scores(
325
+ model: nn.Module,
326
+ batches: Iterable[dict[str, Tensor]],
327
+ *,
328
+ sbi_metric: str = "angular_last",
329
+ ) -> CalibrationScores:
330
+ """Collect CoMe block, adjacent-pair, attention, and MLP scores."""
331
+
332
+ if sbi_metric not in {"angular_last", "cosine_all"}:
333
+ raise ValueError("sbi_metric must be 'angular_last' or 'cosine_all'")
334
+ backbone = model.model
335
+ layers = list(backbone.layers)
336
+ attention = _ProjectionScoreCollector([layer.self_attn.o_proj for layer in layers])
337
+ mlp = _ProjectionScoreCollector([layer.mlp.down_proj for layer in layers])
338
+ block_sums = torch.zeros(len(layers), dtype=torch.float64)
339
+ pair_sums = torch.zeros(len(layers) - 1, dtype=torch.float64)
340
+ block_count = 0
341
+ pair_count = 0
342
+ input_device = model.get_input_embeddings().weight.device
343
+ try:
344
+ for batch in tqdm(batches, desc=f"CoMe calibration ({len(layers)} layers)"):
345
+ prepared = {key: value.to(input_device) for key, value in batch.items()}
346
+ outputs = backbone(
347
+ **prepared,
348
+ use_cache=False,
349
+ output_hidden_states=True,
350
+ return_dict=True,
351
+ )
352
+ hidden = outputs.hidden_states
353
+ for index in range(len(layers)):
354
+ distance = _angular_distance(hidden[index], hidden[index + 1], last_token_only=False)
355
+ block_sums[index] += distance.double().sum().cpu()
356
+ batch_token_count = hidden[0].shape[0] * hidden[0].shape[1]
357
+ block_count += batch_token_count
358
+ for index in range(len(layers) - 1):
359
+ distance = _angular_distance(
360
+ hidden[index],
361
+ hidden[index + 2],
362
+ last_token_only=sbi_metric == "angular_last",
363
+ )
364
+ pair_sums[index] += distance.double().sum().cpu()
365
+ pair_count += hidden[0].shape[0] if sbi_metric == "angular_last" else batch_token_count
366
+ finally:
367
+ attention.close()
368
+ mlp.close()
369
+
370
+ if block_count == 0:
371
+ raise ValueError("calibration batches are empty")
372
+ attention_groups: list[Tensor] = []
373
+ for layer, score in zip(layers, attention.scores, strict=True):
374
+ attn = layer.self_attn
375
+ q_heads = int(attn.config.num_attention_heads)
376
+ kv_heads = int(attn.config.num_key_value_heads)
377
+ head_dim = int(getattr(attn, "head_dim", attn.q_proj.out_features // q_heads))
378
+ queries_per_kv = q_heads // kv_heads
379
+ expected = kv_heads * queries_per_kv * head_dim
380
+ if score.numel() != expected:
381
+ raise ValueError(f"unexpected attention input width {score.numel()} (expected {expected})")
382
+ attention_groups.append(score.reshape(kv_heads, queries_per_kv, head_dim).mean((1, 2)))
383
+ return CalibrationScores(
384
+ block_importance=(block_sums / block_count).tolist(),
385
+ pair_similarity=(pair_sums / max(pair_count, 1)).tolist(),
386
+ attention_groups=attention_groups,
387
+ mlp_neurons=mlp.scores,
388
+ )
389
+
390
+
391
+ def _choose_pair(pair_scores: Sequence[float], lineage: Sequence[Sequence[int]], allow_repeat: bool) -> int:
392
+ candidates = []
393
+ for index, score in enumerate(pair_scores):
394
+ repeated = len(lineage[index]) > 1 or len(lineage[index + 1]) > 1
395
+ if allow_repeat or not repeated:
396
+ candidates.append((float(score), index))
397
+ if not candidates:
398
+ raise RuntimeError(
399
+ "no legal adjacent pair remains; use --allow-repeat or choose a target at least ceil(original_layers / 2)"
400
+ )
401
+ return min(candidates)[1]
402
+
403
+
404
+ def _update_config_after_delete(model: nn.Module, deleted_index: int) -> None:
405
+ model.config.num_hidden_layers = len(model.model.layers)
406
+ if hasattr(model.config, "layer_types") and model.config.layer_types is not None:
407
+ layer_types = list(model.config.layer_types)
408
+ if deleted_index < len(layer_types):
409
+ del layer_types[deleted_index]
410
+ model.config.layer_types = layer_types
411
+ for index, layer in enumerate(model.model.layers):
412
+ if hasattr(layer.self_attn, "layer_idx"):
413
+ layer.self_attn.layer_idx = index
414
+
415
+
416
+ @torch.inference_mode()
417
+ def progressive_prune(
418
+ model: nn.Module,
419
+ calibration_batches: Sequence[dict[str, Tensor]],
420
+ *,
421
+ target_layers: int,
422
+ power: float = 1.0,
423
+ minimum_retention: float = 0.0,
424
+ allow_repeat: bool = False,
425
+ sbi_metric: str = "angular_last",
426
+ ) -> list[MergeRecord]:
427
+ """Progressively merge adjacent layer pairs until ``target_layers`` remain."""
428
+
429
+ original_layers = len(model.model.layers)
430
+ if not 1 <= target_layers <= original_layers:
431
+ raise ValueError(f"target_layers must be in [1, {original_layers}]")
432
+ if not allow_repeat and target_layers < math.ceil(original_layers / 2):
433
+ raise ValueError("without repeated merges, target_layers cannot be below ceil(original_layers / 2)")
434
+ lineage: list[list[int]] = [[index] for index in range(original_layers)]
435
+ records: list[MergeRecord] = []
436
+ model.eval()
437
+ model.config.use_cache = False
438
+
439
+ while len(model.model.layers) > target_layers:
440
+ scores = collect_calibration_scores(model, calibration_batches, sbi_metric=sbi_metric)
441
+ left = _choose_pair(scores.pair_similarity, lineage, allow_repeat)
442
+ indices = [left, left + 1]
443
+ leaf_count = sum(len(lineage[index]) for index in indices)
444
+ adjusted_minimum = minimum_retention
445
+ if allow_repeat and minimum_retention > 0 and leaf_count > 2:
446
+ adjusted_minimum = minimum_retention ** (1 / (leaf_count - 1))
447
+ ratios = compute_retention_ratios(
448
+ [scores.block_importance[index] for index in indices],
449
+ power=power,
450
+ minimum=adjusted_minimum,
451
+ )
452
+ print(
453
+ f"CoMe step {len(records) + 1}: merge current layers {left}/{left + 1} "
454
+ f"(sources {lineage[left]} + {lineage[left + 1]}, ratios={ratios})",
455
+ flush=True,
456
+ )
457
+ merge_layers = [model.model.layers[index] for index in indices]
458
+ attention_counts = merge_attention(
459
+ merge_layers,
460
+ ratios,
461
+ [scores.attention_groups[index] for index in indices],
462
+ )
463
+ mlp_counts = merge_mlp(
464
+ merge_layers,
465
+ ratios,
466
+ [scores.mlp_neurons[index] for index in indices],
467
+ )
468
+ merge_norms(merge_layers)
469
+ records.append(
470
+ MergeRecord(
471
+ step=len(records) + 1,
472
+ left_index=left,
473
+ source_layers=[list(lineage[index]) for index in indices],
474
+ retention_ratios=ratios,
475
+ retained_attention_groups=attention_counts,
476
+ retained_mlp_neurons=mlp_counts,
477
+ pair_score=float(scores.pair_similarity[left]),
478
+ )
479
+ )
480
+ del model.model.layers[left + 1]
481
+ lineage[left] = lineage[left] + lineage[left + 1]
482
+ del lineage[left + 1]
483
+ _update_config_after_delete(model, left + 1)
484
+ if torch.cuda.is_available():
485
+ torch.cuda.empty_cache()
486
+ return records
487
+
488
+
489
+ def build_wikitext2_calibration(
490
+ tokenizer,
491
+ *,
492
+ samples: int,
493
+ sequence_length: int,
494
+ seed: int,
495
+ ) -> list[dict[str, Tensor]]:
496
+ """Reproduce CoMe's shuffled WikiText-2 prefix calibration stream.
497
+
498
+ The upstream ``nsamples`` argument counts shuffled dataset rows, not 2,048
499
+ token windows. Full windows are carved from their concatenated token stream
500
+ and the short tail is discarded.
501
+ """
502
+
503
+ from datasets import load_dataset
504
+
505
+ dataset = load_dataset("wikitext", "wikitext-2-raw-v1", split="train").shuffle(seed=seed)
506
+ selected = dataset.select(range(min(samples, len(dataset))))
507
+ text = "\n\n".join(selected["text"])
508
+ token_ids = tokenizer(text, return_tensors="pt").input_ids[0]
509
+ windows = token_ids.numel() // sequence_length
510
+ if windows == 0:
511
+ raise ValueError("selected WikiText-2 rows contain fewer tokens than sequence_length")
512
+ batches = []
513
+ for index in range(windows):
514
+ start = index * sequence_length
515
+ input_ids = token_ids[start : start + sequence_length].unsqueeze(0)
516
+ batches.append({"input_ids": input_ids, "attention_mask": torch.ones_like(input_ids)})
517
+ return batches
518
+
519
+
520
+ def build_slimpajama_calibration(
521
+ tokenizer,
522
+ *,
523
+ rows: int,
524
+ sequence_length: int,
525
+ seed: int,
526
+ shuffle_buffer: int = 10_000,
527
+ ) -> list[dict[str, Tensor]]:
528
+ """Pack full windows after concatenating shuffled SlimPajama rows.
529
+
530
+ This mirrors upstream CoMe's WikiText loader: ``nsamples`` counts dataset
531
+ rows, not model-forward windows.
532
+ """
533
+
534
+ from datasets import load_dataset
535
+
536
+ if rows < 1:
537
+ raise ValueError("rows must be positive")
538
+ dataset = load_dataset(
539
+ "DKYoon/SlimPajama-6B",
540
+ split="train",
541
+ streaming=True,
542
+ ).shuffle(seed=seed, buffer_size=shuffle_buffer)
543
+ token_buffer: list[int] = []
544
+ selected_rows = 0
545
+ for row in dataset:
546
+ text = row.get("text")
547
+ selected_rows += 1
548
+ if isinstance(text, str):
549
+ token_buffer.extend(tokenizer.encode(text, add_special_tokens=False))
550
+ if selected_rows == rows:
551
+ break
552
+ if selected_rows != rows:
553
+ raise RuntimeError(f"could only read {selected_rows}/{rows} SlimPajama rows")
554
+ windows = len(token_buffer) // sequence_length
555
+ if windows == 0:
556
+ raise ValueError("selected SlimPajama rows contain fewer tokens than sequence_length")
557
+ batches: list[dict[str, Tensor]] = []
558
+ for index in range(windows):
559
+ start = index * sequence_length
560
+ input_ids = torch.tensor(token_buffer[start : start + sequence_length], dtype=torch.long).unsqueeze(0)
561
+ batches.append({"input_ids": input_ids, "attention_mask": torch.ones_like(input_ids)})
562
+ return batches
563
+
564
+
565
+ def batch_calibration(
566
+ samples: Sequence[dict[str, Tensor]], batch_size: int
567
+ ) -> list[dict[str, Tensor]]:
568
+ if batch_size < 1:
569
+ raise ValueError("batch_size must be positive")
570
+ batches = []
571
+ for start in range(0, len(samples), batch_size):
572
+ chunk = samples[start : start + batch_size]
573
+ batches.append({key: torch.cat([item[key] for item in chunk], dim=0) for key in chunk[0]})
574
+ return batches
575
+
576
+
577
+ def save_merge_metadata(
578
+ output_dir: str | Path,
579
+ *,
580
+ source_model: str,
581
+ records: Sequence[MergeRecord],
582
+ arguments: dict,
583
+ ) -> None:
584
+ path = Path(output_dir) / "come_pruning.json"
585
+ payload = {
586
+ "method": "CoMe structured pruning (no distillation)",
587
+ "source_model": source_model,
588
+ "arguments": arguments,
589
+ "merges": [asdict(record) for record in records],
590
+ }
591
+ path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
592
+
593
+
594
+ def enable_torch24_dtensor_save_compat() -> None:
595
+ """Expose PyTorch 2.4's private DTensor where Transformers 4.52 expects it."""
596
+
597
+ try:
598
+ import torch.distributed.tensor as public_tensor
599
+ except ImportError:
600
+ return
601
+ if hasattr(public_tensor, "DTensor"):
602
+ return
603
+ try:
604
+ from torch.distributed._tensor import DTensor
605
+ except ImportError:
606
+ return
607
+ public_tensor.DTensor = DTensor
608
+ # Transformers 4.52 imports this name only when it detects torch >= 2.5,
609
+ # but save_pretrained references it unconditionally on torch 2.4.
610
+ import transformers.modeling_utils as modeling_utils
611
+
612
+ modeling_utils.DTensor = DTensor
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/eval_llama31_8b_12bench.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Evaluate the lm-eval portion of the requested Llama benchmark suite.
3
+
4
+ RACE-H/M, C3, CMNLI, and CHID are evaluated with their canonical OpenCompass
5
+ PPL task definitions by the companion launcher. This script handles the
6
+ remaining eight tasks plus full zero-shot MMLU and CMMLU.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import os
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ import torch
18
+ from transformers import AutoModelForCausalLM, AutoTokenizer
19
+
20
+
21
+ TASKS = (
22
+ "piqa",
23
+ "winogrande",
24
+ "hellaswag",
25
+ "arc_challenge",
26
+ "arc_easy",
27
+ "openbookqa",
28
+ "sciq",
29
+ "mmlu",
30
+ "cmmlu",
31
+ )
32
+
33
+ # Use normalized accuracy where the standard harness exposes it. The
34
+ # extraction code falls back to plain accuracy for tasks/versions without it.
35
+ PREFERRED_METRICS = {
36
+ "piqa": "acc_norm,none",
37
+ "hellaswag": "acc_norm,none",
38
+ "arc_challenge": "acc_norm,none",
39
+ "arc_easy": "acc_norm,none",
40
+ "openbookqa": "acc_norm,none",
41
+ "sciq": "acc_norm,none",
42
+ }
43
+
44
+
45
+ def _score(task: str, result: dict[str, Any]) -> tuple[str, float]:
46
+ preferred = PREFERRED_METRICS.get(task, "acc,none")
47
+ candidates = (preferred, "acc_norm,none", "acc,none")
48
+ for metric in candidates:
49
+ value = result.get(metric)
50
+ if value is not None:
51
+ return metric, float(value)
52
+ available = sorted(key for key in result if "," in key and not key.endswith("_stderr,none"))
53
+ raise KeyError(f"No supported accuracy metric for {task}; available={available}")
54
+
55
+
56
+ def _load_model(args: argparse.Namespace):
57
+ if args.compact_stage is None:
58
+ model = AutoModelForCausalLM.from_pretrained(
59
+ args.model,
60
+ revision=args.revision,
61
+ torch_dtype=torch.bfloat16,
62
+ attn_implementation="eager",
63
+ local_files_only=args.local_files_only,
64
+ ).cuda().eval()
65
+ tokenizer = AutoTokenizer.from_pretrained(
66
+ args.model,
67
+ revision=args.revision,
68
+ local_files_only=args.local_files_only,
69
+ )
70
+ return model, tokenizer
71
+
72
+ if args.cycle is None or args.anchor is None:
73
+ raise ValueError("--compact-stage requires --cycle and --anchor")
74
+ from fusegpt.abprune_stagewise_geometry import load_compact_model
75
+
76
+ model = load_compact_model(
77
+ args.model,
78
+ args.compact_stage,
79
+ cycle=args.cycle,
80
+ anchor=args.anchor,
81
+ dtype=torch.bfloat16,
82
+ device=torch.device("cuda"),
83
+ attn="eager",
84
+ revision=args.revision,
85
+ )
86
+ tokenizer = AutoTokenizer.from_pretrained(
87
+ args.model, revision=args.revision, local_files_only=args.local_files_only)
88
+ return model, tokenizer
89
+
90
+
91
+ def main() -> None:
92
+ parser = argparse.ArgumentParser()
93
+ parser.add_argument("--model", required=True)
94
+ parser.add_argument("--revision", default=None)
95
+ parser.add_argument("--local-files-only", action="store_true")
96
+ parser.add_argument("--compact-stage", type=Path, default=None)
97
+ parser.add_argument("--cycle", type=int, default=None)
98
+ parser.add_argument("--anchor", type=int, default=None)
99
+ parser.add_argument("--batch-size", default="auto:4")
100
+ parser.add_argument("--limit", type=float, default=None)
101
+ parser.add_argument("--output", type=Path, required=True)
102
+ parser.add_argument("--dataset-cache", type=Path, default=None)
103
+ parser.add_argument("--tasks", nargs="+", choices=TASKS, default=list(TASKS),
104
+ help="Evaluate a subset without repeating already scored tasks")
105
+ args = parser.parse_args()
106
+ if len(set(args.tasks)) != len(args.tasks):
107
+ parser.error("--tasks must not contain duplicates")
108
+
109
+ # CMMLU is still distributed through a Hugging Face dataset loading
110
+ # script. Opt in explicitly so non-interactive experiment jobs do not
111
+ # stop at the datasets trust prompt.
112
+ os.environ.setdefault("HF_DATASETS_TRUST_REMOTE_CODE", "1")
113
+
114
+ from lm_eval import evaluator
115
+ from lm_eval.models.huggingface import HFLM
116
+
117
+ if args.dataset_cache is not None:
118
+ from prepare_lmeval9_local_cache import install_local_loader
119
+ install_local_loader(args.dataset_cache)
120
+
121
+ model, tokenizer = _load_model(args)
122
+ model.config.use_cache = False
123
+ if getattr(model, "generation_config", None) is not None:
124
+ model.generation_config.use_cache = False
125
+ for layer_idx, layer in enumerate(model.model.layers):
126
+ if hasattr(layer, "self_attn") and hasattr(layer.self_attn, "layer_idx"):
127
+ layer.self_attn.layer_idx = layer_idx
128
+
129
+ lm = HFLM(
130
+ pretrained=model,
131
+ tokenizer=tokenizer,
132
+ backend="causal",
133
+ batch_size=args.batch_size,
134
+ )
135
+ raw = evaluator.simple_evaluate(
136
+ model=lm,
137
+ tasks=args.tasks,
138
+ num_fewshot=0,
139
+ batch_size=args.batch_size,
140
+ random_seed=0,
141
+ numpy_random_seed=1234,
142
+ torch_random_seed=1234,
143
+ fewshot_random_seed=1234,
144
+ bootstrap_iters=0,
145
+ limit=args.limit,
146
+ )
147
+
148
+ scores: dict[str, float] = {}
149
+ metrics: dict[str, str] = {}
150
+ for task in args.tasks:
151
+ source = raw.get("groups", {}) if task in {"mmlu", "cmmlu"} else raw["results"]
152
+ if task not in source:
153
+ raise KeyError(
154
+ f"Requested task {task!r} missing from lm-eval results: "
155
+ f"results={sorted(raw['results'])}, groups={sorted(raw.get('groups', {}))}"
156
+ )
157
+ metric, value = _score(task, source[task])
158
+ metrics[task] = metric
159
+ scores[task] = value
160
+
161
+ report = {
162
+ "model": args.model,
163
+ "revision": args.revision,
164
+ "compact_stage": str(args.compact_stage) if args.compact_stage else None,
165
+ "cycle": args.cycle,
166
+ "anchor": args.anchor,
167
+ "tasks": args.tasks,
168
+ "num_fewshot": 0,
169
+ "batch_size": args.batch_size,
170
+ "limit": args.limit,
171
+ "dataset_cache": str(args.dataset_cache) if args.dataset_cache else None,
172
+ "preferred_metrics": metrics,
173
+ "task_scores": scores,
174
+ "macro_mean_all_rows": sum(scores.values()) / len(scores),
175
+ "lm_eval_results": raw["results"],
176
+ "lm_eval_groups": raw.get("groups"),
177
+ "lm_eval_versions": raw.get("versions"),
178
+ "lm_eval_config": raw.get("config"),
179
+ }
180
+ args.output.parent.mkdir(parents=True, exist_ok=True)
181
+ args.output.write_text(
182
+ json.dumps(report, indent=2, ensure_ascii=False, default=str) + "\n",
183
+ encoding="utf-8",
184
+ )
185
+ print(
186
+ json.dumps(
187
+ {"task_scores": scores, "macro_mean_all_rows": report["macro_mean_all_rows"]},
188
+ indent=2,
189
+ )
190
+ )
191
+
192
+
193
+ if __name__ == "__main__":
194
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/eval_opencompass_ppl_fast.py ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Fast, equivalent evaluator for selected OpenCompass zero-shot PPL tasks.
3
+
4
+ The prompts, labels, split choices, full-prompt mean-CE scoring, and lowest-PPL
5
+ decision rule mirror OpenCompass 0.5.4's canonical configs for RACE, C3,
6
+ CMNLI, and CHID. Unlike the stock runner, this evaluator disables KV cache
7
+ and length-batches all choices, which matters substantially on 40 GB GPUs.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import json
14
+ from pathlib import Path
15
+ from typing import Iterable
16
+
17
+ import torch
18
+ import torch.nn.functional as F
19
+ from transformers import AutoModelForCausalLM, AutoTokenizer
20
+
21
+
22
+ def read_jsonl(path: Path) -> Iterable[dict]:
23
+ with path.open("r", encoding="utf-8") as stream:
24
+ for line in stream:
25
+ yield json.loads(line)
26
+
27
+
28
+ def race(path: Path) -> tuple[list[list[str]], list[int]]:
29
+ prompts, golds = [], []
30
+ for row in read_jsonl(path):
31
+ human = (
32
+ "Read the article, and answer the question by replying A, B, C or D.\n\n"
33
+ f"Article:\n{row['article']}\n\nQ: {row['question']}\n\n"
34
+ f"A. {row['options'][0]}\nB. {row['options'][1]}\n"
35
+ f"C. {row['options'][2]}\nD. {row['options'][3]}"
36
+ )
37
+ prompts.append([human + "\n" + f"A: {answer}" for answer in "ABCD"])
38
+ golds.append("ABCD".index(row["answer"]))
39
+ return prompts, golds
40
+
41
+
42
+ def c3(path: Path) -> tuple[list[list[str]], list[int]]:
43
+ prompts, golds = [], []
44
+ rows = json.loads(path.read_text(encoding="utf-8"))
45
+ for row in rows:
46
+ content = " ".join("".join(paragraph) for paragraph in row[0])
47
+ for question in row[1]:
48
+ choices = list(question["choice"])
49
+ golds.append(choices.index(question["answer"]))
50
+ while len(choices) < 4:
51
+ choices.append(choices[0])
52
+ human = f"文章:{content}\n问题:{question['question']}"
53
+ prompts.append([human + "\n" + f"答案:{choice}" for choice in choices[:4]])
54
+ return prompts, golds
55
+
56
+
57
+ def cmnli(path: Path) -> tuple[list[list[str]], list[int]]:
58
+ labels = ("contradiction", "entailment", "neutral")
59
+ verbalizers = ("矛盾", "蕴含", "无关")
60
+ prompts, golds = [], []
61
+ for row in read_jsonl(path):
62
+ if row["label"] == "-":
63
+ continue
64
+ human = (
65
+ f"语句一:“{row['sentence1']}”\n语句二:“{row['sentence2']}”\n"
66
+ "请问这两句话是什么关系?"
67
+ )
68
+ prompts.append([human + "\n" + word for word in verbalizers])
69
+ golds.append(labels.index(row["label"]))
70
+ return prompts, golds
71
+
72
+
73
+ def chid(path: Path) -> tuple[list[list[str]], list[int]]:
74
+ prompts, golds = [], []
75
+ for row in read_jsonl(path):
76
+ candidates = [row["content"].replace("#idiom#", candidate) for candidate in row["candidates"]]
77
+ prompts.append([
78
+ f"以下句子是否通顺?\n{content}\n这个句子是通顺的。" for content in candidates
79
+ ])
80
+ golds.append(int(row["answer"]))
81
+ return prompts, golds
82
+
83
+
84
+ def score_task(model, tokenizer, choices: list[list[str]], golds: list[int], max_batch: int,
85
+ token_budget: int) -> dict:
86
+ flat = [(sample_idx, choice_idx, prompt)
87
+ for sample_idx, row in enumerate(choices)
88
+ for choice_idx, prompt in enumerate(row)]
89
+ encoded = tokenizer(
90
+ [item[2] for item in flat],
91
+ add_special_tokens=True,
92
+ padding=False,
93
+ truncation=True,
94
+ max_length=model.config.max_position_embeddings,
95
+ )["input_ids"]
96
+ order = sorted(range(len(flat)), key=lambda idx: len(encoded[idx]), reverse=True)
97
+ losses = [0.0] * len(flat)
98
+ cursor = 0
99
+ while cursor < len(order):
100
+ longest = len(encoded[order[cursor]])
101
+ batch_size = min(max_batch, max(1, token_budget // longest), len(order) - cursor)
102
+ while True:
103
+ batch_indices = order[cursor:cursor + batch_size]
104
+ max_len = max(len(encoded[idx]) for idx in batch_indices)
105
+ input_ids = torch.full(
106
+ (batch_size, max_len), tokenizer.pad_token_id, dtype=torch.long, device="cuda"
107
+ )
108
+ attention = torch.zeros((batch_size, max_len), dtype=torch.long, device="cuda")
109
+ for row_idx, flat_idx in enumerate(batch_indices):
110
+ values = torch.tensor(encoded[flat_idx], dtype=torch.long, device="cuda")
111
+ input_ids[row_idx, : len(values)] = values
112
+ attention[row_idx, : len(values)] = 1
113
+ try:
114
+ with torch.inference_mode():
115
+ logits = model(input_ids=input_ids, attention_mask=attention, use_cache=False).logits
116
+ token_loss = F.cross_entropy(
117
+ logits[:, :-1].float().reshape(-1, logits.shape[-1]),
118
+ input_ids[:, 1:].reshape(-1),
119
+ reduction="none",
120
+ ).view(batch_size, -1)
121
+ # OpenCompass divides by the number of non-padding input
122
+ # tokens (including BOS), while scoring shifted labels.
123
+ sequence_loss = (
124
+ token_loss * attention[:, 1:]
125
+ ).sum(dim=1) / attention.sum(dim=1)
126
+ break
127
+ except torch.OutOfMemoryError:
128
+ del input_ids, attention
129
+ torch.cuda.empty_cache()
130
+ if batch_size == 1:
131
+ raise
132
+ batch_size = max(1, batch_size // 2)
133
+ for flat_idx, value in zip(batch_indices, sequence_loss.tolist()):
134
+ losses[flat_idx] = value
135
+ cursor += batch_size
136
+ if cursor % 1000 < batch_size or cursor == len(order):
137
+ print(f"choices={cursor}/{len(order)}", flush=True)
138
+
139
+ score_rows = [[0.0] * len(row) for row in choices]
140
+ for flat_idx, (sample_idx, choice_idx, _) in enumerate(flat):
141
+ score_rows[sample_idx][choice_idx] = losses[flat_idx]
142
+ predictions = [min(range(len(row)), key=row.__getitem__) for row in score_rows]
143
+ correct = sum(prediction == gold for prediction, gold in zip(predictions, golds))
144
+ return {
145
+ "accuracy": correct / len(golds),
146
+ "correct": correct,
147
+ "samples": len(golds),
148
+ "choices": len(flat),
149
+ }
150
+
151
+
152
+ def main() -> None:
153
+ parser = argparse.ArgumentParser()
154
+ parser.add_argument("--model", required=True)
155
+ parser.add_argument("--revision", default=None)
156
+ parser.add_argument("--tokenizer", required=True)
157
+ parser.add_argument("--compact-stage", type=Path, default=None)
158
+ parser.add_argument("--cycle", type=int, default=None)
159
+ parser.add_argument("--anchor", type=int, default=None)
160
+ parser.add_argument("--data-root", type=Path, required=True)
161
+ parser.add_argument("--output", type=Path, required=True)
162
+ parser.add_argument("--max-batch", type=int, default=32)
163
+ parser.add_argument("--token-budget", type=int, default=8192)
164
+ parser.add_argument("--limit", type=int, default=None)
165
+ args = parser.parse_args()
166
+
167
+ tokenizer = AutoTokenizer.from_pretrained(args.tokenizer, local_files_only=True)
168
+ if tokenizer.pad_token_id is None:
169
+ tokenizer.pad_token_id = tokenizer.eos_token_id
170
+ tokenizer.padding_side = "right"
171
+ if args.compact_stage is None:
172
+ model = AutoModelForCausalLM.from_pretrained(
173
+ args.model,
174
+ revision=args.revision,
175
+ torch_dtype=torch.bfloat16,
176
+ attn_implementation="sdpa",
177
+ local_files_only=True,
178
+ ).cuda().eval()
179
+ else:
180
+ if args.cycle is None or args.anchor is None:
181
+ raise ValueError("--compact-stage requires --cycle and --anchor")
182
+ from fusegpt.abprune_stagewise_geometry import load_compact_model
183
+
184
+ model = load_compact_model(
185
+ args.model,
186
+ args.compact_stage,
187
+ cycle=args.cycle,
188
+ anchor=args.anchor,
189
+ dtype=torch.bfloat16,
190
+ device=torch.device("cuda"),
191
+ attn="sdpa",
192
+ revision=args.revision,
193
+ )
194
+ model.config.use_cache = False
195
+
196
+ datasets = {
197
+ "race-middle": race(args.data_root / "race/test/middle.jsonl"),
198
+ "race-high": race(args.data_root / "race/test/high.jsonl"),
199
+ "C3": c3(args.data_root / "CLUE/C3/dev_0.json"),
200
+ "cmnli": cmnli(args.data_root / "CLUE/cmnli/cmnli_public/dev.json"),
201
+ "chid-dev": chid(args.data_root / "FewCLUE/chid/dev_few_all.json"),
202
+ }
203
+ results = {}
204
+ for name, (choices, golds) in datasets.items():
205
+ if args.limit is not None:
206
+ choices, golds = choices[: args.limit], golds[: args.limit]
207
+ print(f"task={name} samples={len(golds)}", flush=True)
208
+ results[name] = score_task(
209
+ model, tokenizer, choices, golds, args.max_batch, args.token_budget
210
+ )
211
+ print(json.dumps({name: results[name]}, ensure_ascii=False), flush=True)
212
+
213
+ report = {
214
+ "model": args.model,
215
+ "revision": args.revision,
216
+ "compact_stage": str(args.compact_stage) if args.compact_stage else None,
217
+ "cycle": args.cycle,
218
+ "anchor": args.anchor,
219
+ "tokenizer": args.tokenizer,
220
+ "protocol": "OpenCompass 0.5.4 canonical PPL prompts; full-prompt mean CE; lowest PPL",
221
+ "max_batch": args.max_batch,
222
+ "token_budget": args.token_budget,
223
+ "limit": args.limit,
224
+ "results": results,
225
+ }
226
+ args.output.parent.mkdir(parents=True, exist_ok=True)
227
+ args.output.write_text(json.dumps(report, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
228
+
229
+
230
+ if __name__ == "__main__":
231
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/evaluate_hchc_wikitext2_ppl.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Evaluate a saved causal LM with the HCHC WikiText-2 PPL protocol."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ import math
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ import torch
13
+ from datasets import load_dataset, load_from_disk
14
+
15
+
16
+ def primary(output: Any) -> torch.Tensor:
17
+ if torch.is_tensor(output):
18
+ return output
19
+ if isinstance(output, (tuple, list)) and output and torch.is_tensor(output[0]):
20
+ return output[0]
21
+ raise TypeError(f"Unsupported decoder-layer output type: {type(output)!r}")
22
+
23
+
24
+ def replace_primary(output: Any, hidden: torch.Tensor) -> Any:
25
+ if torch.is_tensor(output):
26
+ return hidden
27
+ if isinstance(output, tuple):
28
+ return (hidden, *output[1:])
29
+ if isinstance(output, list):
30
+ return [hidden, *output[1:]]
31
+ raise TypeError(f"Unsupported decoder-layer output type: {type(output)!r}")
32
+
33
+
34
+ def register_residual_scale_hook(layer, gamma: float):
35
+ """Install h_out = h_in + gamma * (block(h_in) - h_in)."""
36
+ scale = torch.tensor(gamma, device=next(layer.parameters()).device)
37
+
38
+ def hook(_module, inputs, output):
39
+ if not inputs or not torch.is_tensor(inputs[0]):
40
+ raise RuntimeError("Could not capture decoder-layer residual input")
41
+ layer_input = inputs[0]
42
+ corrected = layer_input + scale * (primary(output) - layer_input)
43
+ return replace_primary(output, corrected)
44
+
45
+ return layer.register_forward_hook(hook)
46
+
47
+
48
+ def packed_wikitext_tokens(tokenizer, split: str, *, dataset_cache: Path | None = None) -> torch.Tensor:
49
+ """Reproduce the canonical HCHC WikiText-2 packing protocol."""
50
+ if dataset_cache is not None:
51
+ dataset = load_from_disk(str(dataset_cache))[split]
52
+ else:
53
+ dataset = load_dataset(
54
+ "Salesforce/wikitext", "wikitext-2-raw-v1", split=split
55
+ )
56
+ text = "\n\n".join(row for row in dataset["text"] if row.strip())
57
+ return tokenizer(
58
+ text, add_special_tokens=False, return_tensors="pt"
59
+ ).input_ids[0]
60
+
61
+
62
+ @torch.no_grad()
63
+ def evaluate_perplexity(
64
+ model,
65
+ tokens: torch.Tensor,
66
+ sequence_length: int,
67
+ batch_size: int,
68
+ ) -> dict[str, float | int]:
69
+ num_sequences = tokens.numel() // sequence_length
70
+ ids = tokens[: num_sequences * sequence_length].view(num_sequences, sequence_length)
71
+ total_nll = 0.0
72
+ total_predicted_tokens = 0
73
+ model.eval()
74
+ for start in range(0, num_sequences, batch_size):
75
+ batch = ids[start : start + batch_size].to("cuda")
76
+ output = model(input_ids=batch, labels=batch, use_cache=False)
77
+ predicted = batch.shape[0] * (batch.shape[1] - 1)
78
+ total_nll += output.loss.float().item() * predicted
79
+ total_predicted_tokens += predicted
80
+ mean_nll = total_nll / total_predicted_tokens
81
+ return {
82
+ "nll": mean_nll,
83
+ "perplexity": math.exp(mean_nll),
84
+ "tokens": total_predicted_tokens,
85
+ "sequences": num_sequences,
86
+ "source_tokens": int(tokens.numel()),
87
+ }
88
+
89
+
90
+ def main() -> None:
91
+ parser = argparse.ArgumentParser()
92
+ parser.add_argument("--model", type=Path, required=True)
93
+ parser.add_argument("--output", type=Path, required=True)
94
+ parser.add_argument("--sequence-length", type=int, default=2048)
95
+ parser.add_argument("--batch-size", type=int, default=8)
96
+ parser.add_argument("--residual-anchor", type=int)
97
+ parser.add_argument("--residual-gamma", type=float)
98
+ args = parser.parse_args()
99
+
100
+ if (args.residual_anchor is None) != (args.residual_gamma is None):
101
+ parser.error("--residual-anchor and --residual-gamma must be supplied together")
102
+
103
+ from transformers import AutoModelForCausalLM, AutoTokenizer
104
+
105
+ tokenizer = AutoTokenizer.from_pretrained(args.model, local_files_only=True)
106
+ model = AutoModelForCausalLM.from_pretrained(
107
+ args.model,
108
+ torch_dtype=torch.bfloat16,
109
+ local_files_only=True,
110
+ low_cpu_mem_usage=True,
111
+ attn_implementation="sdpa",
112
+ ).to("cuda")
113
+ model.config.use_cache = False
114
+
115
+ handle = None
116
+ if args.residual_gamma is not None:
117
+ if args.residual_anchor >= len(model.model.layers):
118
+ raise ValueError(
119
+ f"Residual anchor {args.residual_anchor} is outside decoder depth "
120
+ f"{len(model.model.layers)}"
121
+ )
122
+ handle = register_residual_scale_hook(
123
+ model.model.layers[args.residual_anchor], args.residual_gamma
124
+ )
125
+
126
+ tokens = packed_wikitext_tokens(tokenizer, "test")
127
+ try:
128
+ metrics = evaluate_perplexity(
129
+ model, tokens, args.sequence_length, args.batch_size
130
+ )
131
+ finally:
132
+ if handle is not None:
133
+ handle.remove()
134
+
135
+ report = {
136
+ "model": str(args.model),
137
+ "dataset": "Salesforce/wikitext:wikitext-2-raw-v1:test",
138
+ "protocol": "HCHC experiment.py: non-empty rows joined with double newline before one-shot tokenization",
139
+ "sequence_length": args.sequence_length,
140
+ "batch_size": args.batch_size,
141
+ "dtype": "bfloat16",
142
+ "residual_anchor": args.residual_anchor,
143
+ "residual_gamma": args.residual_gamma,
144
+ "metrics": metrics,
145
+ }
146
+ args.output.parent.mkdir(parents=True, exist_ok=True)
147
+ args.output.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
148
+ print(json.dumps(report, indent=2), flush=True)
149
+
150
+
151
+ if __name__ == "__main__":
152
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/mka.py ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Corrected MKA variant: adjacent NPIB selection, upstream lambda, real fusion.
2
+
3
+ Not an exact reproduction of the paper: use sequence-level pooled activations,
4
+ recompute geometry after every merge, and resolve NPIB ties back-to-front.
5
+ The seven projection weights are fused; residual and Q/K norms stay at anchor.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import math
12
+ import random
13
+ import time
14
+ from collections.abc import Callable, Iterable, Sequence
15
+ from dataclasses import asdict, dataclass
16
+
17
+ import numpy as np
18
+ import torch
19
+ from scipy.linalg import eigh
20
+ from scipy.spatial.distance import pdist, squareform
21
+ from sklearn.feature_selection import mutual_info_regression
22
+ from sklearn.neighbors import NearestNeighbors
23
+ from torch import Tensor, nn
24
+
25
+ PROJECTION_WEIGHTS = (
26
+ "mlp.down_proj.weight",
27
+ "mlp.up_proj.weight",
28
+ "mlp.gate_proj.weight",
29
+ "self_attn.k_proj.weight",
30
+ "self_attn.o_proj.weight",
31
+ "self_attn.q_proj.weight",
32
+ "self_attn.v_proj.weight",
33
+ )
34
+ UPSTREAM = "https://github.com/SempraETY/Pruning-via-Merging"
35
+ UPSTREAM_COMMIT = "3b60b002a0963266e2f4ca78f133b4e091bc607a"
36
+
37
+
38
+ @dataclass(frozen=True)
39
+ class GeometryConfig:
40
+ sigma: float = 8.0
41
+ alpha: float = 0.5
42
+ dimensions: int = 2
43
+ mi_neighbors: int = 5
44
+ entropy_neighbors: int = 50
45
+ beta: float = 1.0
46
+ seed: int = 0
47
+ pooling: str = "mean"
48
+
49
+ def validate(self) -> None:
50
+ if not math.isfinite(self.sigma) or self.sigma <= 0:
51
+ raise ValueError("sigma must be positive and finite")
52
+ if not math.isfinite(self.alpha) or not 0 <= self.alpha <= 1:
53
+ raise ValueError("alpha must be finite and in [0, 1]")
54
+ if self.dimensions < 1 or min(self.mi_neighbors, self.entropy_neighbors) < 1:
55
+ raise ValueError("dimensions and neighbor counts must be positive")
56
+ if not math.isfinite(self.beta) or self.beta < 0:
57
+ raise ValueError("beta must be non-negative and finite")
58
+ if self.pooling not in {"mean", "last"}:
59
+ raise ValueError("pooling must be 'mean' or 'last'")
60
+
61
+
62
+ def sample_slimpajama(
63
+ tokenizer,
64
+ *,
65
+ samples: int = 100,
66
+ sequence_length: int = 512,
67
+ seed: int = 0,
68
+ revision: str = "b5f90f419b7489cdba26fdbc8c022fcb5562f968",
69
+ shuffle_buffer: int = 10000,
70
+ max_documents: int = 100000,
71
+ documents: Iterable[dict] | None = None,
72
+ ) -> tuple[list[dict[str, Tensor]], dict]:
73
+ """Exactly one random fixed-length, no-BOS window from each distinct document.
74
+
75
+ Unlike CoMe's row-packing loader, ``samples`` is the number of sequences.
76
+ Persist returned IDs and provenance; do not sample again between stages.
77
+ """
78
+ if min(samples, sequence_length, shuffle_buffer, max_documents) < 1:
79
+ raise ValueError("sampling counts, length and buffer must be positive")
80
+ if documents is None:
81
+ from datasets import load_dataset
82
+
83
+ documents = load_dataset(
84
+ "DKYoon/SlimPajama-6B", revision=revision, split="train", streaming=True
85
+ ).shuffle(seed=seed, buffer_size=shuffle_buffer)
86
+ rng = random.Random(seed)
87
+ batches, records, seen = [], [], set()
88
+ iterator = iter(documents)
89
+ try:
90
+ for row_index, row in enumerate(iterator):
91
+ if row_index >= max_documents:
92
+ break
93
+ text = row.get("text")
94
+ if not isinstance(text, str) or not text.strip():
95
+ continue
96
+ digest = hashlib.sha256(text.encode("utf-8")).hexdigest()
97
+ if digest in seen:
98
+ continue
99
+ seen.add(digest)
100
+ ids = tokenizer.encode(text, add_special_tokens=False)
101
+ if len(ids) < sequence_length:
102
+ continue
103
+ start = rng.randrange(len(ids) - sequence_length + 1)
104
+ tensor = torch.tensor(
105
+ ids[start : start + sequence_length], dtype=torch.long
106
+ )[None, :]
107
+ batches.append(
108
+ {"input_ids": tensor, "attention_mask": torch.ones_like(tensor)}
109
+ )
110
+ records.append(
111
+ {
112
+ "stream_row": row_index,
113
+ "document_sha256": digest,
114
+ "document_tokens": len(ids),
115
+ "window_start": start,
116
+ }
117
+ )
118
+ if len(batches) == samples:
119
+ break
120
+ finally:
121
+ close = getattr(iterator, "close", None)
122
+ if close is not None:
123
+ close()
124
+ if len(batches) != samples:
125
+ raise RuntimeError(
126
+ f"Only found {len(batches)}/{samples} distinct sufficiently long documents"
127
+ )
128
+ checksum = hashlib.sha256()
129
+ for batch in batches:
130
+ checksum.update(batch["input_ids"].numpy().astype("<i8").tobytes())
131
+ metadata = {
132
+ "dataset": "DKYoon/SlimPajama-6B",
133
+ "revision": revision,
134
+ "split": "train",
135
+ "samples": samples,
136
+ "sequence_length": sequence_length,
137
+ "seed": seed,
138
+ "shuffle_buffer": shuffle_buffer,
139
+ "add_special_tokens": False,
140
+ "sampling": "one random window per distinct document",
141
+ "input_ids_sha256": checksum.hexdigest(),
142
+ "records": records,
143
+ }
144
+ return batches, metadata
145
+
146
+
147
+ @torch.inference_mode()
148
+ def collect_features(
149
+ model: nn.Module, batches: Sequence[dict[str, Tensor]], *, pooling: str = "mean"
150
+ ) -> list[np.ndarray]:
151
+ """One backbone forward per batch; block hooks avoid hidden-state off-by-one.
152
+
153
+ Collect outputs *before* the final backbone norm, including the final block.
154
+ Pool only valid tokens; activations are CPU float32 after pooling.
155
+ """
156
+ if pooling not in {"mean", "last"} or not batches:
157
+ raise ValueError("valid pooling and nonempty calibration batches are required")
158
+ layers = model.model.layers
159
+ features: list[list[Tensor]] = [[] for _ in layers]
160
+ current_mask: Tensor | None = None
161
+
162
+ def hook(index):
163
+ def capture(module, inputs, output):
164
+ hidden = output[0] if isinstance(output, (tuple, list)) else output
165
+ mask = current_mask.to(hidden.device, dtype=torch.bool)
166
+ if hidden.shape[:2] != mask.shape or (mask.sum(-1) == 0).any():
167
+ raise ValueError("block output and valid-token mask do not match")
168
+ if pooling == "mean":
169
+ value = (hidden.float() * mask[:, :, None]).sum(1) / mask.sum(1)[
170
+ :, None
171
+ ]
172
+ else:
173
+ positions = torch.arange(mask.shape[1], device=mask.device)[None, :]
174
+ last = positions.expand_as(mask).masked_fill(~mask, -1).max(1).values
175
+ value = hidden[
176
+ torch.arange(hidden.shape[0], device=hidden.device), last
177
+ ].float()
178
+ if not torch.isfinite(value).all():
179
+ raise FloatingPointError(f"nonfinite activation in block {index}")
180
+ features[index].append(value.cpu())
181
+
182
+ return capture
183
+
184
+ handles = [layer.register_forward_hook(hook(i)) for i, layer in enumerate(layers)]
185
+ was_training = model.training
186
+ model.eval()
187
+ try:
188
+ device = model.get_input_embeddings().weight.device
189
+ for batch in batches:
190
+ prepared = {key: value.to(device) for key, value in batch.items()}
191
+ current_mask = prepared.get(
192
+ "attention_mask", torch.ones_like(prepared["input_ids"])
193
+ )
194
+ model.model(**prepared, use_cache=False, return_dict=True)
195
+ finally:
196
+ for handle in handles:
197
+ handle.remove()
198
+ model.train(was_training)
199
+ expected = sum(batch["input_ids"].shape[0] for batch in batches)
200
+ arrays = [torch.cat(parts, dim=0).numpy() for parts in features]
201
+ if any(array.shape[0] != expected for array in arrays):
202
+ raise RuntimeError("not all calibration examples reached each decoder block")
203
+ return arrays
204
+
205
+
206
+ def diffusion_embedding(
207
+ features: np.ndarray, config: GeometryConfig
208
+ ) -> tuple[np.ndarray, dict]:
209
+ """Correctly shaped sample-by-sample diffusion kernel, following upstream SVD geometry."""
210
+ config.validate()
211
+ x = np.asarray(features, dtype=np.float64)
212
+ if x.ndim != 2 or not np.isfinite(x).all() or len(x) <= config.dimensions + 1:
213
+ raise ValueError(
214
+ "features must be finite [samples, features], samples > dimensions + 1"
215
+ )
216
+ distance = squareform(pdist(x, metric="euclidean"))
217
+ if distance.max() <= np.finfo(float).eps:
218
+ raise ValueError(
219
+ "constant calibration features: cannot estimate manifold geometry"
220
+ )
221
+ kernel = np.exp(-np.sqrt(distance / config.sigma))
222
+ p = kernel.sum(0)
223
+ normalized = kernel / np.outer(p, p) ** config.alpha
224
+ v = np.sqrt(normalized.sum(0))
225
+ operator = normalized / np.outer(v, v)
226
+ condition = float(np.linalg.cond(operator))
227
+ regularization = 1e-6 if not math.isfinite(condition) or condition > 1e12 else 0.0
228
+ if regularization:
229
+ operator += regularization * np.eye(len(x))
230
+ values, vectors = eigh(
231
+ operator, subset_by_index=(len(x) - config.dimensions - 1, len(x) - 1)
232
+ )
233
+ values, vectors = values[::-1], vectors[:, ::-1]
234
+ # Fix arbitrary eigenvector signs; the leading vector of this positive kernel is positive.
235
+ for dim in range(vectors.shape[1]):
236
+ if vectors[np.argmax(np.abs(vectors[:, dim])), dim] < 0:
237
+ vectors[:, dim] *= -1
238
+ if np.any(np.abs(vectors[:, 0]) < 1e-12):
239
+ raise FloatingPointError(
240
+ "diffusion normalization has a near-zero leading eigenvector"
241
+ )
242
+ embedding = vectors[:, 1:] / vectors[:, :1]
243
+ if not np.isfinite(embedding).all():
244
+ raise FloatingPointError("nonfinite diffusion embedding")
245
+ # Upstream uses per-axis rank normalization before its KNN estimators.
246
+ embedding = np.argsort(
247
+ np.argsort(embedding, axis=0, kind="stable"), axis=0, kind="stable"
248
+ ) / len(x)
249
+ return embedding, {
250
+ "samples": len(x),
251
+ "condition_number": condition if math.isfinite(condition) else None,
252
+ "regularization": regularization,
253
+ "eigenvalues": values.tolist(),
254
+ }
255
+
256
+
257
+ def entropy_knn(x: np.ndarray, neighbors: int) -> float:
258
+ """Upstream differential-entropy estimator, evaluated in log space."""
259
+ n, dimensions = x.shape
260
+ k = min(neighbors, n - 1)
261
+ distances = NearestNeighbors(n_neighbors=k + 1).fit(x).kneighbors(x)[0][:, -1]
262
+ if np.any(distances <= 0) or not np.isfinite(distances).all():
263
+ raise FloatingPointError(
264
+ "duplicate/degenerate manifold points in entropy estimator"
265
+ )
266
+ return float(math.log(n / k) + dimensions * np.log(distances).mean())
267
+
268
+
269
+ def npib_matrix(
270
+ embeddings: Sequence[np.ndarray], config: GeometryConfig
271
+ ) -> tuple[np.ndarray, list[float]]:
272
+ """Match upstream axis-wise MI average and symmetric sqrt(H_i*H_j) normalization.
273
+
274
+ Differential entropies can be negative. Preserve upstream's formula when
275
+ their product is positive; fail clearly for zero/negative products or NaNs.
276
+ This estimator is a heuristic, not a guaranteed [0, 1] similarity.
277
+ """
278
+ config.validate()
279
+ if not embeddings or len({x.shape for x in embeddings}) != 1:
280
+ raise ValueError("embeddings must have identical sample/coordinate shapes")
281
+ n = len(embeddings[0])
282
+ if n < 3 or any(not np.isfinite(x).all() for x in embeddings):
283
+ raise ValueError("need at least three finite manifold points")
284
+ entropies = [entropy_knn(x, config.entropy_neighbors) for x in embeddings]
285
+ scores = np.empty((len(embeddings), len(embeddings)), dtype=np.float64)
286
+ for i, left in enumerate(embeddings):
287
+ for j in range(i, len(embeddings)):
288
+ right = embeddings[j]
289
+ product = entropies[i] * entropies[j]
290
+ if not math.isfinite(product) or product <= 1e-12:
291
+ raise FloatingPointError(
292
+ f"invalid entropy product at ({i}, {j}): {entropies[i]}, {entropies[j]}"
293
+ )
294
+ mi = np.mean(
295
+ [
296
+ np.mean(
297
+ mutual_info_regression(
298
+ left,
299
+ right[:, dim],
300
+ n_neighbors=min(config.mi_neighbors, n - 1),
301
+ random_state=config.seed,
302
+ )
303
+ )
304
+ for dim in range(right.shape[1])
305
+ ]
306
+ )
307
+ scores[i, j] = scores[j, i] = mi / math.sqrt(product)
308
+ if not np.isfinite(scores).all():
309
+ raise FloatingPointError("NPIB contains nonfinite scores")
310
+ return scores, entropies
311
+
312
+
313
+ def upstream_lambda(
314
+ scores: np.ndarray, left: int, right: int, beta: float = 1.0
315
+ ) -> float:
316
+ """Exactly upstream's sigmoid(beta * row_mean_i / (row_mean_i + row_mean_j))."""
317
+ means = np.mean(scores[[left, right]], axis=1)
318
+ total = float(means.sum())
319
+ if not np.isfinite(means).all() or (means < 0).any() or total <= 1e-12:
320
+ raise FloatingPointError(
321
+ "cannot compute upstream lambda from nonpositive/nonfinite row means"
322
+ )
323
+ if not math.isfinite(beta) or beta < 0:
324
+ raise ValueError("beta must be non-negative and finite")
325
+ value = beta * float(means[0]) / total
326
+ return 1.0 / (1.0 + math.exp(-value))
327
+
328
+
329
+ def select_pair(
330
+ scores: np.ndarray,
331
+ *,
332
+ selection: str = "npib",
333
+ protected_first: int = 0,
334
+ protected_last: int = 0,
335
+ ) -> int:
336
+ """Adjacent pairs only; NPIB descending, and deeper pair wins exact ties."""
337
+ n = len(scores)
338
+ if scores.shape != (n, n) or not np.isfinite(scores).all():
339
+ raise ValueError("scores must be a finite square matrix")
340
+ if min(protected_first, protected_last) < 0:
341
+ raise ValueError("protected layer counts must be non-negative")
342
+ candidates = range(protected_first, n - protected_last - 1)
343
+ if not candidates:
344
+ raise ValueError("no eligible adjacent pair remains")
345
+ if selection == "back-to-front":
346
+ return candidates[-1]
347
+ if selection != "npib":
348
+ raise ValueError("selection must be 'npib' or 'back-to-front'")
349
+ return max(candidates, key=lambda i: (float(scores[i, i + 1]), i))
350
+
351
+
352
+ @torch.inference_mode()
353
+ def merge_pair(model: nn.Module, left: int, ratio: float) -> int:
354
+ """FP32 weighted sum copied into real parameters, then delete the right block."""
355
+ layers = model.model.layers
356
+ if (
357
+ not 0 <= left < len(layers) - 1
358
+ or not math.isfinite(ratio)
359
+ or not 0 <= ratio <= 1
360
+ ):
361
+ raise ValueError("invalid adjacent pair or merge ratio")
362
+ destination, source = layers[left], layers[left + 1]
363
+ pairs = []
364
+ for name in PROJECTION_WEIGHTS:
365
+ pairs.append((destination.get_parameter(name), source.get_parameter(name)))
366
+ # Qwen2.5 has Q/K/V biases. Fuse them with the same coefficient;
367
+ # Llama and Qwen3 (bias-free projections) retain their existing behavior.
368
+ module_name = name.rsplit('.', 1)[0]
369
+ a_bias = getattr(destination.get_submodule(module_name), 'bias', None)
370
+ b_bias = getattr(source.get_submodule(module_name), 'bias', None)
371
+ if (a_bias is None) != (b_bias is None):
372
+ raise ValueError('projection bias presence differs between merge layers')
373
+ if a_bias is not None:
374
+ pairs.append((a_bias, b_bias))
375
+ # Validate all shapes/values/config before any model mutation.
376
+ if any(a.shape != b.shape for a, b in pairs):
377
+ raise ValueError("projection shapes differ between merge layers")
378
+ if any(not torch.isfinite(p).all() for pair in pairs for p in pair):
379
+ raise FloatingPointError("nonfinite source weight")
380
+ configs = [model.config, model.model.config]
381
+ for config in configs:
382
+ types = getattr(config, "layer_types", None)
383
+ if types is not None and len(types) != len(layers):
384
+ raise ValueError("config.layer_types length does not match decoder depth")
385
+ changed = 0
386
+ for target, other in pairs:
387
+ merged = torch.lerp(
388
+ other.detach().to(target.device, dtype=torch.float32), target.float(), ratio
389
+ )
390
+ merged = merged.to(target.dtype)
391
+ if not torch.isfinite(merged).all():
392
+ raise FloatingPointError("merge overflow after conversion to model dtype")
393
+ changed += int(not torch.equal(target, merged))
394
+ target.copy_(merged)
395
+ del layers[left + 1]
396
+ handled = set()
397
+ for config in configs:
398
+ if id(config) in handled:
399
+ continue
400
+ handled.add(id(config))
401
+ config.num_hidden_layers = len(layers)
402
+ if getattr(config, "layer_types", None) is not None:
403
+ config.layer_types = list(config.layer_types[: left + 1]) + list(
404
+ config.layer_types[left + 2 :]
405
+ )
406
+ for index, layer in enumerate(layers):
407
+ if hasattr(layer.self_attn, "layer_idx"):
408
+ layer.self_attn.layer_idx = index
409
+ return changed
410
+
411
+
412
+ def progressive_prune(
413
+ model: nn.Module,
414
+ batches: Sequence[dict[str, Tensor]],
415
+ *,
416
+ target_layers: int,
417
+ geometry: GeometryConfig | None = None,
418
+ selection: str = "npib",
419
+ protected_first: int = 0,
420
+ protected_last: int = 0,
421
+ on_stage: Callable[[nn.Module, dict], None] | None = None,
422
+ transport: bool = False,
423
+ transport_ridge: float = 1e-3,
424
+ transport_fit_fraction: float = 0.8,
425
+ initial_lineage: Sequence[Sequence[int]] | None = None,
426
+ ) -> list[dict]:
427
+ """Recompute activations/manifolds/NPIB on fixed data after every accepted merge.
428
+
429
+ No threshold or forced fallbacks; stop at the requested exact depth. Repeated
430
+ merging of a previously merged block is allowed and recorded in its lineage.
431
+ """
432
+ geometry = geometry or GeometryConfig()
433
+ geometry.validate()
434
+ depth = len(model.model.layers)
435
+ if min(protected_first, protected_last) < 0 or not 1 <= target_layers <= depth:
436
+ raise ValueError("invalid target depth or protected counts")
437
+ if target_layers < protected_first + protected_last + 1:
438
+ raise ValueError("target depth would remove protected layers")
439
+ if selection not in {"npib", "back-to-front"}:
440
+ raise ValueError("invalid selection mode")
441
+ lineage = ([list(group) for group in initial_lineage] if initial_lineage is not None
442
+ else [[i] for i in range(depth)])
443
+ flattened = [index for group in lineage for index in group]
444
+ if (len(lineage) != depth or any(not group for group in lineage)
445
+ or any(type(index) is not int for index in flattened)
446
+ or flattened != list(range(len(flattened)))):
447
+ raise ValueError("initial lineage must partition original layers in order")
448
+ stage_offset = len(flattened) - depth
449
+ records = []
450
+ model.eval()
451
+ while len(model.model.layers) > target_layers:
452
+ started = time.monotonic()
453
+ step = stage_offset + len(records) + 1
454
+ print(
455
+ f"MKA stage {step}: collecting features for {len(lineage)} layers",
456
+ flush=True,
457
+ )
458
+ features = collect_features(model, batches, pooling=geometry.pooling)
459
+ results = [diffusion_embedding(x, geometry) for x in features]
460
+ del features
461
+ scores, entropies = npib_matrix([x[0] for x in results], geometry)
462
+ left = select_pair(
463
+ scores,
464
+ selection=selection,
465
+ protected_first=protected_first,
466
+ protected_last=protected_last,
467
+ )
468
+ ratio = upstream_lambda(scores, left, left + 1, geometry.beta)
469
+ record = {
470
+ "step": step,
471
+ "selection": selection,
472
+ "left_index": left,
473
+ "source_layers": [lineage[left][:], lineage[left + 1][:]],
474
+ "pair_npib": float(scores[left, left + 1]),
475
+ "lambda_left": ratio,
476
+ "lambda_right": 1 - ratio,
477
+ "row_means": scores.mean(1).tolist(),
478
+ "npib_matrix": scores.tolist(),
479
+ "entropies": entropies,
480
+ "geometry": asdict(geometry),
481
+ "manifolds": [x[1] for x in results],
482
+ }
483
+ if transport:
484
+ from .mka_transport import transport_merge_pair
485
+ changed, diagnostic = transport_merge_pair(
486
+ model, batches, left, ratio, ridge_relative=transport_ridge,
487
+ fit_fraction=transport_fit_fraction,
488
+ )
489
+ record["changed_parameter_tensors"] = changed
490
+ record["transport"] = diagnostic
491
+ else:
492
+ record["changed_parameter_tensors"] = merge_pair(model, left, ratio)
493
+ lineage[left] += lineage.pop(left + 1)
494
+ record["lineage_after"] = [x[:] for x in lineage]
495
+ record["remaining_layers"] = len(lineage)
496
+ record["elapsed_seconds"] = time.monotonic() - started
497
+ records.append(record)
498
+ print(
499
+ f"MKA stage {step}: merge {left}/{left + 1}, NPIB={record['pair_npib']:.6g}, "
500
+ f"lambda={ratio:.6g}, remaining={len(lineage)}",
501
+ flush=True,
502
+ )
503
+ if on_stage is not None:
504
+ on_stage(model, record)
505
+ return records
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/mka_transport.py ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Token-level ridge input transport before MKA's original scalar merge.
2
+
3
+ Attention Q/K/V and MLP gate/up use separate maps. MLP deployment inputs are
4
+ measured with the provisional merged attention; source targets come from the
5
+ unmodified current model. Output projections and anchor norms are not mapped.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import math
10
+ from contextlib import contextmanager
11
+
12
+ import torch
13
+
14
+ ATTENTION = tuple(f"self_attn.{name}_proj.weight" for name in ("q", "k", "v", "o"))
15
+ INPUTS = ATTENTION[:3] + ("mlp.gate_proj.weight", "mlp.up_proj.weight")
16
+
17
+
18
+ class _Captured(RuntimeError):
19
+ pass
20
+
21
+
22
+ @contextmanager
23
+ def capture_inputs(model, modules, stop):
24
+ captured = {}
25
+ handles = []
26
+
27
+ def hook(name):
28
+ def capture(_module, args, kwargs):
29
+ value = args[0] if args else kwargs["hidden_states"]
30
+ captured[name] = value.detach()
31
+ if name == stop:
32
+ raise _Captured()
33
+ return capture
34
+
35
+ try:
36
+ for name, module in modules.items():
37
+ handles.append(module.register_forward_pre_hook(hook(name), with_kwargs=True))
38
+ yield captured
39
+ finally:
40
+ for handle in handles:
41
+ handle.remove()
42
+
43
+
44
+ def forward_until_capture(model, batch):
45
+ device = model.get_input_embeddings().weight.device
46
+ try:
47
+ model.model(**{k: v.to(device) for k, v in batch.items()}, use_cache=False,
48
+ return_dict=True)
49
+ except _Captured:
50
+ pass
51
+
52
+
53
+ def valid_tokens(value, batch):
54
+ mask = batch.get("attention_mask", torch.ones_like(batch["input_ids"]))
55
+ if value.shape[:2] != mask.shape:
56
+ raise ValueError("transport activation/mask shape mismatch")
57
+ result = value[mask.to(value.device, dtype=torch.bool)]
58
+ if not len(result) or not torch.isfinite(result).all():
59
+ raise FloatingPointError("empty/nonfinite transport inputs")
60
+ return result
61
+
62
+
63
+ class Statistics:
64
+ def __init__(self):
65
+ self.gram = self.cross = None
66
+ self.target_sq = 0.0
67
+ self.tokens = 0
68
+
69
+ def add(self, x, y):
70
+ x, y = x.float(), y.to(x.device).float()
71
+ if x.shape != y.shape or x.ndim != 2:
72
+ raise ValueError("transport requires paired equal-width token inputs")
73
+ if self.gram is None:
74
+ self.gram = torch.zeros((x.shape[1], x.shape[1]), device=x.device)
75
+ self.cross = torch.zeros_like(self.gram)
76
+ self.gram.addmm_(x.T, x)
77
+ self.cross.addmm_(x.T, y)
78
+ self.target_sq += float(y.double().square().sum())
79
+ self.tokens += len(x)
80
+
81
+ def score(self, mapping):
82
+ # CPU FP64 avoids TF32 and cancellation in the diagnostic quadratic.
83
+ gram = self.gram.double().cpu() / self.tokens
84
+ cross = self.cross.double().cpu() / self.tokens
85
+ t = mapping.double().cpu()
86
+ target = self.target_sq / self.tokens
87
+ dot = float((t * cross).sum())
88
+ prediction = float((t * (gram @ t)).sum())
89
+ error = max(0.0, prediction + target - 2 * dot)
90
+ return {"tokens": self.tokens, "nmse": error / target,
91
+ "cosine": dot / math.sqrt(max(prediction * target, 1e-30)),
92
+ "norm_ratio": math.sqrt(max(prediction / target, 0.0))}
93
+
94
+ def solve(self, ridge_relative):
95
+ gram = self.gram.double().cpu() / self.tokens
96
+ cross = self.cross.double().cpu() / self.tokens
97
+ ridge = float(gram.diagonal().mean()) * ridge_relative
98
+ gram.diagonal().add_(ridge)
99
+ chol, info = torch.linalg.cholesky_ex(gram)
100
+ if int(info.max()) != 0:
101
+ raise FloatingPointError("transport regularized Gram is not positive definite")
102
+ mapping = torch.cholesky_solve(cross, chol).float().to(self.gram.device)
103
+ if not torch.isfinite(mapping).all():
104
+ raise FloatingPointError("nonfinite transport mapping")
105
+ return mapping, {"ridge_relative": ridge_relative, "ridge_absolute": ridge,
106
+ "relative_identity_distance": float(
107
+ (mapping - torch.eye(len(mapping), device=mapping.device)).norm()
108
+ / math.sqrt(len(mapping))), "fit": self.score(mapping)}
109
+
110
+
111
+ def transport_weight(weight, mapping, chunk=256):
112
+ result = torch.empty_like(weight)
113
+ for start in range(0, len(weight), chunk):
114
+ result[start:start + chunk] = (
115
+ weight[start:start + chunk].float() @ mapping.T
116
+ ).to(weight.dtype)
117
+ if not torch.isfinite(result).all():
118
+ raise FloatingPointError("nonfinite transported weight")
119
+ return result
120
+
121
+
122
+ @torch.inference_mode()
123
+ def transport_merge_pair(model, batches, left, ratio, *, ridge_relative=1e-3,
124
+ fit_fraction=0.8, observer=None):
125
+ """Fit on whole examples, validate on disjoint examples, then merge once.
126
+
127
+ Temporary attention changes are restored even if fitting raises. Final source
128
+ rewrites are restored if merging fails before layer deletion. No optimizer,
129
+ Fisher estimate, output-target regression, or benchmark selection is involved.
130
+ """
131
+ from .mka import PROJECTION_WEIGHTS, merge_pair
132
+
133
+ if not math.isfinite(ridge_relative) or ridge_relative <= 0:
134
+ raise ValueError("transport ridge must be positive and finite")
135
+ if not 0 < fit_fraction < 1 or not batches:
136
+ raise ValueError("transport requires calibration and a proper fit split")
137
+ if not 0 <= left < len(model.model.layers) - 1 or not 0 <= ratio <= 1:
138
+ raise ValueError("invalid merge pair/ratio")
139
+ anchor, source = model.model.layers[left:left + 2]
140
+ pairs = [(anchor.get_parameter(n), source.get_parameter(n)) for n in PROJECTION_WEIGHTS]
141
+ if any(a.shape != b.shape for a, b in pairs):
142
+ raise ValueError("projection shapes differ")
143
+ if any(not torch.isfinite(p).all() for pair in pairs for p in pair):
144
+ raise FloatingPointError("nonfinite source projection")
145
+ # The experiment runner uses batch=1; generic batches must not straddle
146
+ # the document split, so split by batches and record exact example counts.
147
+ split = int(len(batches) * fit_fraction)
148
+ if not 0 < split < len(batches):
149
+ raise ValueError("transport split needs at least two calibration batches")
150
+ attn_stats = [Statistics(), Statistics()]
151
+ mlp_targets = []
152
+ native = {"anchor_attn": anchor.self_attn, "source_attn": source.self_attn,
153
+ "source_mlp": source.mlp}
154
+ was_training = model.training
155
+ old_tf32 = torch.backends.cuda.matmul.allow_tf32
156
+ model.eval()
157
+ torch.backends.cuda.matmul.allow_tf32 = False
158
+ anchor_backup = {}
159
+ source_backup = {}
160
+ try:
161
+ for index, batch in enumerate(batches):
162
+ with capture_inputs(model, native, "source_mlp") as captured:
163
+ forward_until_capture(model, batch)
164
+ if set(captured) != set(native):
165
+ raise RuntimeError("incomplete native input capture")
166
+ attn_stats[int(index >= split)].add(
167
+ valid_tokens(captured["anchor_attn"], batch),
168
+ valid_tokens(captured["source_attn"], batch))
169
+ mlp_targets.append(valid_tokens(captured["source_mlp"], batch).cpu())
170
+ t_attn, attn_diagnostic = attn_stats[0].solve(ridge_relative)
171
+ attn_diagnostic["heldout"] = attn_stats[1].score(t_attn)
172
+ del attn_stats
173
+ # Provisional attention equals the actual attention deployed at the
174
+ # anchor after this merge, including raw o_proj and projection biases.
175
+ for name in ATTENTION:
176
+ target = anchor.get_parameter(name)
177
+ original_source = source.get_parameter(name)
178
+ anchor_backup[name] = target.detach().cpu().clone()
179
+ candidate = (transport_weight(original_source, t_attn)
180
+ if name in INPUTS else original_source)
181
+ target.copy_(torch.lerp(candidate.float(), target.float(), ratio).to(target.dtype))
182
+ bias_name = name.replace(".weight", ".bias")
183
+ a_bias = getattr(anchor.get_submodule(name.rsplit(".", 1)[0]), "bias", None)
184
+ b_bias = getattr(source.get_submodule(name.rsplit(".", 1)[0]), "bias", None)
185
+ if (a_bias is None) != (b_bias is None):
186
+ raise ValueError("projection bias presence differs")
187
+ if a_bias is not None:
188
+ anchor_backup[bias_name] = a_bias.detach().cpu().clone()
189
+ a_bias.copy_(torch.lerp(b_bias.float(), a_bias.float(), ratio).to(a_bias.dtype))
190
+ mlp_stats = [Statistics(), Statistics()]
191
+ for index, (batch, target) in enumerate(zip(batches, mlp_targets)):
192
+ with capture_inputs(model, {"deployed_mlp": anchor.mlp}, "deployed_mlp") as captured:
193
+ forward_until_capture(model, batch)
194
+ if "deployed_mlp" not in captured:
195
+ raise RuntimeError("incomplete deployed MLP capture")
196
+ mlp_stats[int(index >= split)].add(
197
+ valid_tokens(captured["deployed_mlp"], batch), target)
198
+ t_mlp, mlp_diagnostic = mlp_stats[0].solve(ridge_relative)
199
+ mlp_diagnostic["heldout"] = mlp_stats[1].score(t_mlp)
200
+ del mlp_stats, mlp_targets
201
+ for name, value in anchor_backup.items():
202
+ anchor.get_parameter(name).copy_(value)
203
+ anchor_backup.clear()
204
+ # Optional diagnostic observes native weights and the fitted maps before
205
+ # any source rewrite. It must not mutate model parameters or the maps.
206
+ if observer is not None:
207
+ observer(anchor, source, {"attention": t_attn, "mlp": t_mlp})
208
+ # Rewrite only source input projections. Then reuse original MKA's
209
+ # seven-projection merge, norms policy, layer deletion and reindexing.
210
+ for name in INPUTS:
211
+ parameter = source.get_parameter(name)
212
+ source_backup[name] = parameter.detach().cpu().clone()
213
+ parameter.copy_(transport_weight(parameter, t_attn if name.startswith("self_attn") else t_mlp))
214
+ changed = merge_pair(model, left, ratio)
215
+ source_backup.clear()
216
+ return changed, {"enabled": True, "projections": list(INPUTS),
217
+ "fit_batches": split, "heldout_batches": len(batches) - split,
218
+ "fit_examples": sum(b["input_ids"].shape[0] for b in batches[:split]),
219
+ "heldout_examples": sum(b["input_ids"].shape[0] for b in batches[split:]),
220
+ "attention": attn_diagnostic, "mlp": mlp_diagnostic,
221
+ "mlp_input_policy": "provisional merged attention with retained anchor norms",
222
+ "source_target_policy": "native current-model inputs before any stage mutation",
223
+ "coordinate_fit": "X_deployed @ T ~= X_native_source",
224
+ "weight_rewrite": "W_source <- W_source @ T.T",
225
+ "output_projections_transported": False}
226
+ finally:
227
+ for name, value in anchor_backup.items():
228
+ anchor.get_parameter(name).copy_(value)
229
+ for name, value in source_backup.items():
230
+ source.get_parameter(name).copy_(value)
231
+ torch.backends.cuda.matmul.allow_tf32 = old_tf32
232
+ model.train(was_training)
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/replaceme_llama_instruction_mask_bf16.patch ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compare_model/ReplaceMe/ReplaceMe/lstsq.py b/compare_model/ReplaceMe/ReplaceMe/lstsq.py
2
+ --- a/compare_model/ReplaceMe/ReplaceMe/lstsq.py
3
+ +++ b/compare_model/ReplaceMe/ReplaceMe/lstsq.py
4
+ @@ -92,6 +92,7 @@ def lstsq(
5
+ quantization_config=quantization_config,
6
+ output_hidden_states=True,
7
+ token=token,
8
+ + dtype=torch.bfloat16,
9
+ )
10
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
11
+ hidden_size = model.config.hidden_size
12
+ @@ -173,19 +174,22 @@ def lstsq(
13
+ with torch.no_grad():
14
+ outputs = model(**inputs)
15
+
16
+ + valid_tokens = inputs["attention_mask"].reshape(-1).to(dtype=torch.bool)
17
+ hidden_states = outputs.hidden_states[1:]
18
+
19
+ # Get relevant hidden states
20
+ hidden_states_mlp = [
21
+ - mlp_activations[f'layer_{i}_mlp'].view(-1, hidden_size).to(torch.float64)
22
+ + mlp_activations[f'layer_{i}_mlp']
23
+ + .view(-1, hidden_size)[valid_tokens]
24
+ + .to(torch.float64)
25
+ for i in range(model.config.num_hidden_layers) if i+1 in start_ids
26
+ ]
27
+ hidden_states_i = [
28
+ - hidden_states[i].view(-1, hidden_size).to(torch.float64)
29
+ + hidden_states[i].view(-1, hidden_size)[valid_tokens].to(torch.float64)
30
+ for i in range(model.config.num_hidden_layers) if i+1 in start_ids
31
+ ]
32
+ hidden_states_n = [
33
+ - hidden_states[i].view(-1, hidden_size).to(torch.float64)
34
+ + hidden_states[i].view(-1, hidden_size)[valid_tokens].to(torch.float64)
35
+ for i in range(model.config.num_hidden_layers) if i+1 in end_ids
36
+ ]
37
+
38
+ @@ -231,7 +234,7 @@ def lstsq(
39
+ model = AutoModelForCausalLM.from_pretrained(
40
+ model_path,
41
+ device_map='cpu',
42
+ - torch_dtype=torch.bfloat16,
43
+ + dtype=torch.bfloat16,
44
+ )
45
+
46
+ # Apply transformations
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/replaceme_qwen_layer_types.patch ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compare_model/ReplaceMe/ReplaceMe/utils.py b/compare_model/ReplaceMe/ReplaceMe/utils.py
2
+ --- a/compare_model/ReplaceMe/ReplaceMe/utils.py
3
+ +++ b/compare_model/ReplaceMe/ReplaceMe/utils.py
4
+ @@ -80,11 +80,16 @@ def angular_distance(x_l: torch.Tensor, x_l_plus_n: torch.Tensor) -> torch.Tens
5
+
6
+ def truncate_model(model: nn.Module, start_layer: int, end_layer: int) -> nn.Module:
7
+ """Truncate model by removing specified layers."""
8
+ - model.config.num_hidden_layers -= (end_layer - start_layer)
9
+ - model.model.layers = nn.ModuleList([
10
+ - layer for idx, layer in enumerate(model.model.layers)
11
+ - if idx < start_layer or idx >= end_layer
12
+ - ])
13
+ + layers = model.model.layers
14
+ + kept_indices = [
15
+ + idx for idx in range(len(layers))
16
+ + if idx < start_layer or idx >= end_layer
17
+ + ]
18
+ + model.config.num_hidden_layers = len(kept_indices)
19
+ + model.model.layers = nn.ModuleList([layers[idx] for idx in kept_indices])
20
+ + layer_types = getattr(model.config, "layer_types", None)
21
+ + if isinstance(layer_types, (list, tuple)) and len(layer_types) == len(layers):
22
+ + model.config.layer_types = [layer_types[idx] for idx in kept_indices]
23
+ return model
24
+
25
+
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_come_pruning.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Prune a native Hugging Face Qwen3 or Llama 3 model with CoMe."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ from pathlib import Path
8
+
9
+ import torch
10
+ from transformers import AutoModelForCausalLM, AutoTokenizer
11
+
12
+ from fusegpt.come import (
13
+ batch_calibration,
14
+ build_slimpajama_calibration,
15
+ build_wikitext2_calibration,
16
+ enable_torch24_dtensor_save_compat,
17
+ progressive_prune,
18
+ save_merge_metadata,
19
+ )
20
+
21
+
22
+ DTYPES = {
23
+ "float16": torch.float16,
24
+ "bfloat16": torch.bfloat16,
25
+ "float32": torch.float32,
26
+ }
27
+
28
+
29
+ def parse_args() -> argparse.Namespace:
30
+ parser = argparse.ArgumentParser(description=__doc__)
31
+ parser.add_argument("--model", required=True, help="Hugging Face model id or local directory")
32
+ parser.add_argument("--output-dir", required=True)
33
+ parser.add_argument("--target-layers", required=True, type=int)
34
+ parser.add_argument("--calibration-dataset", choices=("slimpajama", "wikitext2"), default="slimpajama")
35
+ parser.add_argument("--calibration-rows", type=int, default=256)
36
+ parser.add_argument("--sequence-length", type=int, default=2048)
37
+ parser.add_argument("--batch-size", type=int, default=1)
38
+ parser.add_argument("--seed", type=int, default=10)
39
+ parser.add_argument("--power", type=float, default=1.0, help="Block-importance exponent")
40
+ parser.add_argument("--minimum-retention", type=float, default=0.0)
41
+ parser.add_argument("--allow-repeat", action="store_true", help="Allow a merged block to be merged again")
42
+ parser.add_argument("--sbi-metric", choices=("angular_last", "cosine_all"), default="angular_last")
43
+ parser.add_argument("--dtype", choices=tuple(DTYPES), default="bfloat16")
44
+ parser.add_argument("--device-map", default="auto")
45
+ parser.add_argument("--attn-implementation", choices=("eager", "sdpa", "flash_attention_2"), default="sdpa")
46
+ parser.add_argument("--trust-remote-code", action="store_true")
47
+ return parser.parse_args()
48
+
49
+
50
+ def main() -> None:
51
+ args = parse_args()
52
+ output_dir = Path(args.output_dir)
53
+ if (output_dir / "config.json").exists():
54
+ raise FileExistsError(f"Refusing to overwrite an existing checkpoint: {output_dir}")
55
+ output_dir.mkdir(parents=True, exist_ok=True)
56
+ tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=args.trust_remote_code)
57
+ model = AutoModelForCausalLM.from_pretrained(
58
+ args.model,
59
+ torch_dtype=DTYPES[args.dtype],
60
+ device_map=args.device_map,
61
+ low_cpu_mem_usage=True,
62
+ trust_remote_code=args.trust_remote_code,
63
+ attn_implementation=args.attn_implementation,
64
+ )
65
+ architecture = model.config.model_type
66
+ if architecture not in {"llama", "qwen3"}:
67
+ raise ValueError(f"unsupported model_type={architecture!r}; expected 'llama' or 'qwen3'")
68
+
69
+ if args.calibration_dataset == "slimpajama":
70
+ samples = build_slimpajama_calibration(
71
+ tokenizer,
72
+ rows=args.calibration_rows,
73
+ sequence_length=args.sequence_length,
74
+ seed=args.seed,
75
+ )
76
+ else:
77
+ samples = build_wikitext2_calibration(
78
+ tokenizer,
79
+ samples=args.calibration_rows,
80
+ sequence_length=args.sequence_length,
81
+ seed=args.seed,
82
+ )
83
+ print(
84
+ f"Calibration: {args.calibration_rows} {args.calibration_dataset} rows -> "
85
+ f"{len(samples)} windows x {args.sequence_length} tokens",
86
+ flush=True,
87
+ )
88
+ batches = batch_calibration(samples, args.batch_size)
89
+ records = progressive_prune(
90
+ model,
91
+ batches,
92
+ target_layers=args.target_layers,
93
+ power=args.power,
94
+ minimum_retention=args.minimum_retention,
95
+ allow_repeat=args.allow_repeat,
96
+ sbi_metric=args.sbi_metric,
97
+ )
98
+ model.config.use_cache = True
99
+ enable_torch24_dtensor_save_compat()
100
+ model.save_pretrained(output_dir, safe_serialization=True)
101
+ tokenizer.save_pretrained(output_dir)
102
+ metadata_arguments = dict(vars(args))
103
+ metadata_arguments["packed_calibration_windows"] = len(samples)
104
+ metadata_arguments["packed_calibration_tokens"] = len(samples) * args.sequence_length
105
+ save_merge_metadata(
106
+ output_dir,
107
+ source_model=args.model,
108
+ records=records,
109
+ arguments=metadata_arguments,
110
+ )
111
+ print(f"Saved {len(model.model.layers)}-layer model to {output_dir}")
112
+
113
+
114
+ if __name__ == "__main__":
115
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_mka_pruning.py ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Run corrected, training-free MKA on native Hugging Face Llama/Qwen models."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import gc
8
+ import hashlib
9
+ import json
10
+ import platform
11
+ import shutil
12
+ import subprocess
13
+ import sys
14
+ from dataclasses import asdict
15
+ from pathlib import Path
16
+
17
+ sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
18
+
19
+
20
+ def parse_args(argv=None):
21
+ parser = argparse.ArgumentParser(description=__doc__)
22
+ parser.add_argument("--model", required=True)
23
+ parser.add_argument(
24
+ "--revision", help="Source model/tokenizer revision (pin for real experiments)"
25
+ )
26
+ parser.add_argument("--output-dir", required=True)
27
+ parser.add_argument("--resume-checkpoint", help="Continue a completed native MKA checkpoint, retaining original lineage")
28
+ depth = parser.add_mutually_exclusive_group(required=True)
29
+ depth.add_argument("--remove-blocks", type=int)
30
+ depth.add_argument("--target-layers", type=int)
31
+ parser.add_argument(
32
+ "--selection",
33
+ choices=("npib", "back-to-front"),
34
+ default="npib",
35
+ help="NPIB maximum adjacent pair; exact ties prefer deeper pair",
36
+ )
37
+ parser.add_argument("--calibration-samples", type=int, default=100)
38
+ parser.add_argument("--sequence-length", type=int, default=512)
39
+ parser.add_argument(
40
+ "--calibration-ids",
41
+ help="Replay this runner's calibration_ids.pt instead of resampling",
42
+ )
43
+ parser.add_argument(
44
+ "--calibration-revision", default="b5f90f419b7489cdba26fdbc8c022fcb5562f968"
45
+ )
46
+ parser.add_argument("--seed", type=int, default=0)
47
+ parser.add_argument("--batch-size", type=int, default=1)
48
+ parser.add_argument("--pooling", choices=("mean", "last"), default="mean")
49
+ parser.add_argument("--sigma", type=float, default=8.0)
50
+ parser.add_argument("--alpha", type=float, default=0.5)
51
+ parser.add_argument("--manifold-dimensions", type=int, default=2)
52
+ parser.add_argument("--mi-neighbors", type=int, default=5)
53
+ parser.add_argument("--entropy-neighbors", type=int, default=50)
54
+ parser.add_argument("--beta", type=float, default=1.0)
55
+ parser.add_argument("--protected-first", type=int, default=0)
56
+ parser.add_argument("--protected-last", type=int, default=0)
57
+ parser.add_argument("--save-at-removals", type=int, nargs="*", default=[])
58
+ parser.add_argument(
59
+ "--dtype", choices=("bfloat16", "float16", "float32"), default="bfloat16"
60
+ )
61
+ parser.add_argument("--device-map", default="auto")
62
+ parser.add_argument(
63
+ "--attn-implementation",
64
+ choices=("eager", "sdpa", "flash_attention_2"),
65
+ default="sdpa",
66
+ )
67
+ parser.add_argument("--trust-remote-code", action="store_true")
68
+ parser.add_argument(
69
+ "--verify-reload", action=argparse.BooleanOptionalAction, default=True
70
+ )
71
+ parser.add_argument("--cpu-threads", type=int, default=4)
72
+ parser.add_argument("--transport", action="store_true",
73
+ help="Ridge input transport of source Q/K/V and gate/up before MKA merge")
74
+ parser.add_argument("--transport-ridge", type=float, default=1e-3)
75
+ parser.add_argument("--transport-fit-fraction", type=float, default=0.8)
76
+ return parser.parse_args(argv)
77
+
78
+
79
+ def write_json(path: Path, value):
80
+ path.parent.mkdir(parents=True, exist_ok=True)
81
+ path.write_text(
82
+ json.dumps(value, indent=2, ensure_ascii=False, allow_nan=False) + "\n",
83
+ encoding="utf-8",
84
+ )
85
+
86
+
87
+ def replay_calibration(path: str, tokenizer, args):
88
+ import torch
89
+
90
+ bundle = torch.load(path, map_location="cpu", weights_only=True)
91
+ spec = bundle["metadata"]
92
+ chunks = bundle["input_ids"]
93
+ if (
94
+ spec["tokenizer"] != args.model
95
+ or spec["tokenizer_revision"] != args.revision
96
+ or spec["tokenizer_vocab_sha256"] != vocabulary_checksum(tokenizer)
97
+ ):
98
+ raise ValueError(
99
+ "calibration cache tokenizer identity/revision/vocabulary differs"
100
+ )
101
+ if len(chunks) != args.calibration_samples or any(
102
+ x.dtype != torch.long or tuple(x.shape) != (args.sequence_length,)
103
+ for x in chunks
104
+ ):
105
+ raise ValueError(
106
+ "calibration cache sample count, dtype or sequence length differs"
107
+ )
108
+ checksum = hashlib.sha256()
109
+ for chunk in chunks:
110
+ checksum.update(chunk.numpy().astype("<i8").tobytes())
111
+ if checksum.hexdigest() != spec["input_ids_sha256"]:
112
+ raise ValueError("calibration cache token checksum mismatch")
113
+ if any((x < 0).any() or (x >= len(tokenizer)).any() for x in chunks):
114
+ raise ValueError("calibration cache contains invalid token IDs")
115
+ return [
116
+ {"input_ids": chunk[None, :], "attention_mask": torch.ones_like(chunk[None, :])}
117
+ for chunk in chunks
118
+ ], spec
119
+
120
+
121
+ def vocabulary_checksum(tokenizer):
122
+ serialized = json.dumps(tokenizer.get_vocab(), sort_keys=True, ensure_ascii=False)
123
+ return hashlib.sha256(serialized.encode("utf-8")).hexdigest()
124
+
125
+
126
+ def read_resume_protocol(checkpoint, args, geometry, calibration):
127
+ path = Path(checkpoint) / "mka_pruning.json"
128
+ protocol = json.loads(path.read_text(encoding="utf-8"))
129
+ if (protocol.get("status") not in {"complete", "checkpoint_complete"}
130
+ or protocol["source_model"] != args.model
131
+ or protocol["resolved_model_revision"] != args.revision
132
+ or protocol["geometry"] != asdict(geometry)
133
+ or protocol["calibration"] != calibration):
134
+ raise ValueError("resume checkpoint source, geometry or calibration mismatch")
135
+ expected_transport = {"enabled": args.transport, "ridge_relative": args.transport_ridge,
136
+ "fit_fraction": args.transport_fit_fraction,
137
+ "scope": "attention q/k/v and MLP gate/up; separate maps"}
138
+ if protocol.get("transport") != expected_transport:
139
+ raise ValueError("resume checkpoint transport settings mismatch")
140
+ for key in ("selection", "protected_first", "protected_last"):
141
+ if protocol["arguments"][key] != getattr(args, key):
142
+ raise ValueError(f"resume checkpoint {key} mismatch")
143
+ merges = protocol["merges"]
144
+ if (not merges or [row["step"] for row in merges] != list(range(1, len(merges) + 1))
145
+ or protocol["original_depth"] - protocol["actual_depth"] != len(merges)
146
+ or merges[-1]["remaining_layers"] != protocol["actual_depth"]
147
+ or len(merges[-1]["lineage_after"]) != protocol["actual_depth"]
148
+ or [i for group in merges[-1]["lineage_after"] for i in group] != list(range(protocol["original_depth"]))):
149
+ raise ValueError("resume checkpoint merge history/depth mismatch")
150
+ return protocol, hashlib.sha256(path.read_bytes()).hexdigest()
151
+
152
+
153
+ def main(argv=None):
154
+ args = parse_args(argv)
155
+ import numpy as np
156
+ import scipy
157
+ import sklearn
158
+ import torch
159
+ import transformers
160
+ from threadpoolctl import threadpool_limits
161
+ from transformers import AutoModelForCausalLM, AutoTokenizer
162
+
163
+ from fusegpt.come import batch_calibration, enable_torch24_dtensor_save_compat
164
+ from fusegpt.mka import (
165
+ UPSTREAM,
166
+ UPSTREAM_COMMIT,
167
+ GeometryConfig,
168
+ progressive_prune,
169
+ sample_slimpajama,
170
+ )
171
+
172
+ geometry = GeometryConfig(
173
+ sigma=args.sigma,
174
+ alpha=args.alpha,
175
+ dimensions=args.manifold_dimensions,
176
+ mi_neighbors=args.mi_neighbors,
177
+ entropy_neighbors=args.entropy_neighbors,
178
+ beta=args.beta,
179
+ seed=args.seed,
180
+ pooling=args.pooling,
181
+ )
182
+ geometry.validate()
183
+ if min(args.batch_size, args.cpu_threads, args.sequence_length) < 1:
184
+ raise ValueError("batch size, CPU threads and sequence length must be positive")
185
+ if args.calibration_samples <= args.manifold_dimensions + 1:
186
+ raise ValueError("calibration sample count must exceed manifold dimensions + 1")
187
+ torch.set_num_threads(args.cpu_threads)
188
+ torch.manual_seed(args.seed)
189
+ output = Path(args.output_dir)
190
+ output.mkdir(parents=True, exist_ok=True)
191
+ if any(output.iterdir()):
192
+ raise FileExistsError(
193
+ "output directory must be empty; refusing to overwrite an earlier run"
194
+ )
195
+ tokenizer = AutoTokenizer.from_pretrained(
196
+ args.model, revision=args.revision, trust_remote_code=args.trust_remote_code
197
+ )
198
+ if args.calibration_ids:
199
+ samples, spec = replay_calibration(args.calibration_ids, tokenizer, args)
200
+ else:
201
+ samples, spec = sample_slimpajama(
202
+ tokenizer,
203
+ samples=args.calibration_samples,
204
+ sequence_length=args.sequence_length,
205
+ seed=args.seed,
206
+ revision=args.calibration_revision,
207
+ )
208
+ spec.update(
209
+ {
210
+ "tokenizer": args.model,
211
+ "tokenizer_revision": args.revision,
212
+ "tokenizer_vocab_sha256": vocabulary_checksum(tokenizer),
213
+ }
214
+ )
215
+ torch.save(
216
+ {"input_ids": [x["input_ids"][0] for x in samples], "metadata": spec},
217
+ output / "calibration_ids.pt",
218
+ )
219
+ write_json(output / "calibration.json", spec)
220
+ batches = batch_calibration(samples, args.batch_size)
221
+ previous, parent_hash = (read_resume_protocol(args.resume_checkpoint, args, geometry, spec)
222
+ if args.resume_checkpoint else (None, None))
223
+ model = AutoModelForCausalLM.from_pretrained(
224
+ args.resume_checkpoint or args.model,
225
+ revision=None if previous else args.revision,
226
+ torch_dtype=getattr(torch, args.dtype),
227
+ device_map=args.device_map,
228
+ low_cpu_mem_usage=True,
229
+ attn_implementation=args.attn_implementation,
230
+ trust_remote_code=args.trust_remote_code,
231
+ )
232
+ if model.config.model_type not in {"llama", "qwen3", "qwen2"}:
233
+ raise ValueError(
234
+ "only native Llama, Qwen3 and Qwen2 decoder architectures are supported"
235
+ )
236
+ current_depth = len(model.model.layers)
237
+ original_depth = previous["original_depth"] if previous else current_depth
238
+ if previous and current_depth != previous["actual_depth"]:
239
+ raise ValueError("resume checkpoint config depth differs from merge history")
240
+ if args.remove_blocks is not None and not 1 <= args.remove_blocks < original_depth:
241
+ raise ValueError("remove-blocks must be positive and less than original depth")
242
+ target = (
243
+ args.target_layers
244
+ if args.target_layers is not None
245
+ else original_depth - args.remove_blocks
246
+ )
247
+ if not 1 <= target < current_depth:
248
+ raise ValueError(
249
+ "target must remove at least one block and retain at least one"
250
+ )
251
+ if any(not original_depth - current_depth < x <= original_depth - target for x in args.save_at_removals):
252
+ raise ValueError(
253
+ "save-at-removals must fall within the requested pruning trajectory"
254
+ )
255
+ if (
256
+ spec["samples"] != args.calibration_samples
257
+ or args.sequence_length != spec["sequence_length"]
258
+ ):
259
+ raise ValueError("calibration provenance does not match requested counts")
260
+ resolved_revision = previous["resolved_model_revision"] if previous else getattr(model.config, "_commit_hash", None)
261
+ git = subprocess.run(
262
+ ["git", "rev-parse", "HEAD"],
263
+ cwd=Path(__file__).resolve().parents[1],
264
+ capture_output=True,
265
+ text=True,
266
+ check=False,
267
+ )
268
+ metadata = {
269
+ "method": ("MKA corrected + input transport (no gradient training)" if args.transport
270
+ else "MKA corrected variant (training-free)"),
271
+ "upstream": UPSTREAM,
272
+ "upstream_commit": UPSTREAM_COMMIT,
273
+ "source_model": args.model,
274
+ "resolved_model_revision": resolved_revision,
275
+ "git_commit": git.stdout.strip(),
276
+ "arguments": vars(args),
277
+ "geometry": asdict(geometry),
278
+ "calibration": spec,
279
+ "original_depth": original_depth,
280
+ "target_depth": target,
281
+ "allow_repeat": True,
282
+ "transport": {"enabled": args.transport, "ridge_relative": args.transport_ridge,
283
+ "fit_fraction": args.transport_fit_fraction,
284
+ "scope": "attention q/k/v and MLP gate/up; separate maps"},
285
+ "norm_policy": "retain left residual norms and Q/K norms; seven projection weights and their existing biases",
286
+ "implementation_differences": [
287
+ "sequence-level masked pooling",
288
+ (
289
+ "adjacent maximum NPIB selection with deeper exact-tie priority"
290
+ if args.selection == "npib"
291
+ else "fixed back-to-front adjacent merge order"
292
+ ),
293
+ "recompute current-model geometry every stage",
294
+ "actual parameter copy_",
295
+ "independent SlimPajama train calibration; no MMLU test inputs",
296
+ ],
297
+ "environment": {
298
+ "python": platform.python_version(),
299
+ "torch": torch.__version__,
300
+ "transformers": transformers.__version__,
301
+ "numpy": np.__version__,
302
+ "scipy": scipy.__version__,
303
+ "sklearn": sklearn.__version__,
304
+ },
305
+ "status": "running",
306
+ "merges": previous["merges"][:] if previous else [],
307
+ }
308
+ if previous:
309
+ metadata["resume_provenance"] = {"checkpoint": str(Path(args.resume_checkpoint).resolve()),
310
+ "parent_protocol_sha256": parent_hash,
311
+ "parent_git_commit": previous["git_commit"],
312
+ "previous_merges": len(previous["merges"]),
313
+ "starting_depth": current_depth}
314
+ for record in previous["merges"]:
315
+ write_json(output / "stages" / f"stage_{record['step']:04d}.json", record)
316
+ write_json(output / "mka_pruning.json", metadata)
317
+ enable_torch24_dtensor_save_compat()
318
+
319
+ def save_checkpoint(current, directory):
320
+ current.save_pretrained(directory, safe_serialization=True)
321
+ tokenizer.save_pretrained(directory)
322
+
323
+ def journal(current, record):
324
+ metadata["merges"].append(record)
325
+ write_json(output / "stages" / f"stage_{record['step']:04d}.json", record)
326
+ write_json(output / "mka_pruning.json", metadata)
327
+ removed = original_depth - record["remaining_layers"]
328
+ if removed in args.save_at_removals:
329
+ directory = output / f"removed_{removed:02d}"
330
+ save_checkpoint(current, directory)
331
+ for name in ("calibration.json", "calibration_ids.pt"):
332
+ shutil.copy2(output / name, directory / name)
333
+ write_json(
334
+ directory / "mka_pruning.json",
335
+ {
336
+ **metadata,
337
+ "status": "checkpoint_complete",
338
+ "actual_depth": record["remaining_layers"],
339
+ "requested_final_depth": target,
340
+ "target_depth": record["remaining_layers"],
341
+ },
342
+ )
343
+
344
+ use_cache = model.config.use_cache
345
+ try:
346
+ with threadpool_limits(limits=args.cpu_threads):
347
+ progressive_prune(
348
+ model,
349
+ batches,
350
+ target_layers=target,
351
+ geometry=geometry,
352
+ selection=args.selection,
353
+ protected_first=args.protected_first,
354
+ protected_last=args.protected_last,
355
+ on_stage=journal,
356
+ transport=args.transport,
357
+ transport_ridge=args.transport_ridge,
358
+ transport_fit_fraction=args.transport_fit_fraction,
359
+ initial_lineage=previous["merges"][-1]["lineage_after"] if previous else None,
360
+ )
361
+ model.config.use_cache = use_cache
362
+ save_checkpoint(model, output)
363
+ metadata["actual_depth"] = len(model.model.layers)
364
+ if args.verify_reload:
365
+ probe = {
366
+ key: value[:, : min(args.sequence_length, 16)]
367
+ for key, value in samples[0].items()
368
+ }
369
+
370
+ def probe_logits(current):
371
+ current.eval()
372
+ device = current.get_input_embeddings().weight.device
373
+ with torch.inference_mode():
374
+ logits = (
375
+ current(
376
+ **{k: v.to(device) for k, v in probe.items()},
377
+ use_cache=False,
378
+ )
379
+ .logits[:, -1]
380
+ .float()
381
+ .cpu()
382
+ )
383
+ if not torch.isfinite(logits).all():
384
+ raise FloatingPointError("nonfinite reload probe logits")
385
+ return logits
386
+
387
+ expected = probe_logits(model)
388
+ del model
389
+ gc.collect()
390
+ if torch.cuda.is_available():
391
+ torch.cuda.empty_cache()
392
+ restored = AutoModelForCausalLM.from_pretrained(
393
+ output,
394
+ torch_dtype=getattr(torch, args.dtype),
395
+ device_map=args.device_map,
396
+ attn_implementation=args.attn_implementation,
397
+ trust_remote_code=args.trust_remote_code,
398
+ )
399
+ actual = probe_logits(restored)
400
+ error = float((expected - actual).abs().max())
401
+ tolerance = 0.05 if args.dtype == "bfloat16" else 0.005
402
+ if len(restored.model.layers) != target or not torch.allclose(
403
+ expected, actual, atol=tolerance, rtol=tolerance
404
+ ):
405
+ raise AssertionError(
406
+ f"save/reload probe mismatch: max_abs_error={error}"
407
+ )
408
+ metadata["reload_verification"] = {
409
+ "passed": True,
410
+ "max_abs_logit_error": error,
411
+ "atol": tolerance,
412
+ "rtol": tolerance,
413
+ "probe_tokens": probe["input_ids"].shape[1],
414
+ }
415
+ else:
416
+ metadata["reload_verification"] = {
417
+ "passed": None,
418
+ "reason": "disabled by CLI",
419
+ }
420
+ metadata["status"] = "complete"
421
+ except Exception as error:
422
+ metadata["status"] = "failed"
423
+ metadata["failure"] = {"type": type(error).__name__, "message": str(error)}
424
+ write_json(output / "mka_pruning.json", metadata)
425
+ raise
426
+ write_json(output / "mka_pruning.json", metadata)
427
+ print(f"Saved {target}-layer MKA model to {output}", flush=True)
428
+
429
+
430
+ if __name__ == "__main__":
431
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_8b_base_replaceme_depth.sh ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -ne 7 ]]; then
5
+ echo "Usage: $0 <replaceme-repo> <project-root> <output-root> <model-path> <blocks> <removed-start> <gpu>" >&2
6
+ exit 2
7
+ fi
8
+
9
+ repo="$(cd "$1" && pwd)"
10
+ project="$(cd "$2" && pwd)"
11
+ root="$(mkdir -p "$3" && cd "$3" && pwd)"
12
+ model="$(cd "$4" && pwd)"
13
+ blocks="$5"
14
+ removed_start="$6"
15
+ gpu="$7"
16
+ python_bin="${PYTHON_BIN:-python}"
17
+ bf16_patch="$project/patches/replaceme_llama_instruction_mask_bf16.patch"
18
+ qwen_patch="$project/patches/replaceme_qwen_layer_types.patch"
19
+ workdir="$repo/compare_model/ReplaceMe"
20
+ staged_model="$root/model_staged_ReplaceMe_lstsq_1"
21
+ final_model="$root/model"
22
+
23
+ [[ "$blocks" =~ ^(5|9|14|18)$ ]]
24
+ [[ "$removed_start" =~ ^[0-9]+$ ]]
25
+ removed_end=$((removed_start + blocks))
26
+ (( removed_start >= 1 && removed_end <= 36 ))
27
+
28
+ export CUDA_VISIBLE_DEVICES="$gpu"
29
+ export HF_HOME=/workspace/.hf_home
30
+ export TOKENIZERS_PARALLELISM=false
31
+ export PYTHONUNBUFFERED=1
32
+ mkdir -p "$root"/{logs,metadata,eval}
33
+
34
+ test -f "$model/.model_download_complete"
35
+ test -f "$model/config.json"
36
+
37
+ (
38
+ flock 9
39
+ for patch in "$bf16_patch" "$qwen_patch"; do
40
+ if git -C "$repo" apply --check "$patch"; then
41
+ git -C "$repo" apply "$patch"
42
+ elif git -C "$repo" apply --reverse --check "$patch"; then
43
+ :
44
+ else
45
+ echo "RePlaceMe patch does not apply cleanly: $patch" >&2
46
+ exit 1
47
+ fi
48
+ done
49
+ ) 9>"$repo/.replaceme_patch.lock"
50
+
51
+ "$python_bin" -m py_compile \
52
+ "$repo/compare_model/ReplaceMe/ReplaceMe/lstsq.py" \
53
+ "$repo/compare_model/ReplaceMe/ReplaceMe/utils.py" \
54
+ "$repo/compare_model/ReplaceMe/ReplaceMe/ReplaceMe_pipeline.py"
55
+ git -C "$repo" diff --binary > "$root/metadata/replaceme_source_patch.diff"
56
+ git -C "$repo" rev-parse HEAD > "$root/metadata/replaceme_source_commit.txt"
57
+
58
+ "$python_bin" - "$root" "$model" "$blocks" "$removed_start" "$removed_end" <<'PY'
59
+ import json
60
+ import sys
61
+ from pathlib import Path
62
+
63
+ root = Path(sys.argv[1])
64
+ model = sys.argv[2]
65
+ blocks = int(sys.argv[3])
66
+ removed_start = int(sys.argv[4])
67
+ removed_end = int(sys.argv[5])
68
+ (root / "selected_blocks.json").write_text(
69
+ json.dumps({"replaceme_blocks": [[removed_start, removed_end]]}, indent=2) + "\n"
70
+ )
71
+ config = {
72
+ "method": "lstsq",
73
+ "model_path": model,
74
+ "dataset": "DKYoon/SlimPajama-6B",
75
+ "dataset_column": "text",
76
+ "batch_size": 8,
77
+ "max_length": 1024,
78
+ "dataset_size": 10000,
79
+ "dataset_subset": "train",
80
+ "use_4bit": False,
81
+ "save_path": str(root / "model_staged"),
82
+ "save_transform_only": True,
83
+ "diag": False,
84
+ "alpha": 0.0,
85
+ "distances_path": None,
86
+ "num_A": 1,
87
+ "layers_to_skip": blocks,
88
+ "merge_consecutive": True,
89
+ "selected_blocks_path": str(root / "selected_blocks.json"),
90
+ "seed": 42,
91
+ "tasks": None,
92
+ }
93
+ (root / "config.json").write_text(json.dumps(config, indent=2) + "\n")
94
+ protocol = {
95
+ "method": "ReplaceMe streaming closed-form LSTSQ",
96
+ "model": "Qwen/Qwen3-8B-Base",
97
+ "model_revision": "49e3418fbbbca6ecbdf9608b4d22e5a407081db4",
98
+ "selected_span_source": "SlimPajama-500 original RePlaceMe angular-distance selector",
99
+ "removed_interval": [removed_start, removed_end],
100
+ "removed_original_layers": list(range(removed_start, removed_end)),
101
+ "left_boundary_layer": removed_start - 1,
102
+ "calibration": {
103
+ "dataset": "DKYoon/SlimPajama-6B",
104
+ "records": 10000,
105
+ "sequence_length": 1024,
106
+ "batch_size": 8,
107
+ "valid_tokens_only": True,
108
+ "dtype": "bfloat16",
109
+ "seed": 42,
110
+ },
111
+ "fit": {"solver": "closed_form_lstsq", "ridge_alpha": 0.0},
112
+ }
113
+ (root / "protocol.json").write_text(json.dumps(protocol, indent=2) + "\n")
114
+ PY
115
+
116
+ if [[ ! -f "$root/TRAIN_COMPLETE" ]]; then
117
+ if [[ -e "$final_model" ]]; then
118
+ echo "Refusing to overwrite existing final model: $final_model" >&2
119
+ exit 2
120
+ fi
121
+ (
122
+ cd "$workdir"
123
+ PYTHONPATH="$workdir:$repo:$project/src${PYTHONPATH:+:$PYTHONPATH}" \
124
+ "$python_bin" -u run_replaceme.py --config "$root/config.json"
125
+ ) > "$root/logs/train.log" 2>&1
126
+ test -f "$staged_model/config.json"
127
+ mv -- "$staged_model" "$final_model"
128
+ touch "$root/TRAIN_COMPLETE"
129
+ fi
130
+
131
+ touch "$root/MODEL_READY_NO_EVAL"
132
+ echo "qwen3_8b_base_replaceme_${blocks}block=model_ready_evaluation_deferred"
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_8b_native_span_transport_additive_u.sh ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -ne 7 ]]; then
5
+ echo "Usage: $0 <abprune-repo> <project-root> <output-root> <model-path> <anchor> <cycles> <gpu>" >&2
6
+ exit 2
7
+ fi
8
+
9
+ repo="$(cd "$1" && pwd)"
10
+ project="$(cd "$2" && pwd)"
11
+ root="$(mkdir -p "$3" && cd "$3" && pwd)"
12
+ model="$(cd "$4" && pwd)"
13
+ anchor="$5"
14
+ cycles="$6"
15
+ gpu="$7"
16
+ fit_tokens="${ABPRUNE_FIT_TARGET_TOKENS:-524288}"
17
+ calib_sequences="${ABPRUNE_CALIB_SEQUENCES:-64}"
18
+
19
+ model_id=Qwen/Qwen3-8B-Base
20
+ revision=49e3418fbbbca6ecbdf9608b4d22e5a407081db4
21
+ num_layers=36
22
+ removed_start=$((anchor + 1))
23
+ removed_end=$((removed_start + cycles))
24
+ layer_order=()
25
+ for _ in $(seq 1 "$cycles"); do layer_order+=("$anchor"); done
26
+
27
+ export HF_HOME=/workspace/.hf_home
28
+ export HF_TOKEN_PATH=/root/.cache/huggingface/token
29
+ export HF_XET_HIGH_PERFORMANCE=1
30
+ export TOKENIZERS_PARALLELISM=false
31
+ export PYTHONUNBUFFERED=1
32
+ export PYTHONPATH="$repo/src:$project/src${PYTHONPATH:+:$PYTHONPATH}"
33
+ mkdir -p "$root/logs" "$root/run" "$root/compact" "$root/eval" "$root/metadata"
34
+
35
+ python - "$root/protocol.json" "$anchor" "$cycles" "$removed_start" "$removed_end" "$fit_tokens" "$calib_sequences" <<'PY'
36
+ import json
37
+ import sys
38
+ from pathlib import Path
39
+
40
+ output, anchor, cycles, removed_start, removed_end, fit_tokens, calib_sequences = sys.argv[1:]
41
+ anchor = int(anchor)
42
+ cycles = int(cycles)
43
+ removed_start = int(removed_start)
44
+ removed_end = int(removed_end)
45
+ Path(output).write_text(json.dumps({
46
+ "experiment": f"qwen3_8b_native_cosine_transport_additive_u_{cycles}block_v1",
47
+ "model": "Qwen/Qwen3-8B-Base",
48
+ "revision": "49e3418fbbbca6ecbdf9608b4d22e5a407081db4",
49
+ "selection": {
50
+ "method": "native block-output-aligned contiguous cosine",
51
+ "dataset": "DKYoon/SlimPajama-6B",
52
+ "sequences": 500,
53
+ "sequence_length": 1024,
54
+ "seed": 20260910,
55
+ "anchor": anchor,
56
+ "removed_interval": [removed_start, removed_end],
57
+ },
58
+ "anchor": anchor,
59
+ "removed_original_layers": list(range(removed_start, removed_end)),
60
+ "cycles": cycles,
61
+ "merge": {
62
+ "fisher": "same-anchor post-pruning contextual diagonal parameter Fisher",
63
+ "fisher_eps": 0.0,
64
+ "source_feature_transport": "X_anchor @ T ~= X_source; gate/up W_source <- W_source @ T.T",
65
+ "transport_ridge_relative": 1e-3,
66
+ "fit_parameterization": "W = W_F + U_add; U_add initialized at zero; Fisher gates frozen",
67
+ "rho_scaling": False,
68
+ },
69
+ "training": {
70
+ "dataset": "DKYoon/SlimPajama-6B",
71
+ "sequence_length": 1024,
72
+ "target_tokens_per_stage": int(fit_tokens),
73
+ "calibration_sequences": int(calib_sequences),
74
+ "distill_epochs_per_stage": 1.0,
75
+ "distill_kl_weight": 0.02,
76
+ "hidden_mse_weight": 1.0,
77
+ "mlp_mse_weight": 1.0,
78
+ "parameter_subset": "mlp",
79
+ },
80
+ }, indent=2) + "\n", encoding="utf-8")
81
+ PY
82
+
83
+ python -m py_compile \
84
+ "$repo/src/fuse_layers.py" \
85
+ "$repo/src/fuse_layers_distill.py" \
86
+ "$repo/src/source_feature_transport.py"
87
+ PYTHONPATH="$repo/src" python "$project/scripts/test_abprune_additive_u.py"
88
+
89
+ if [[ ! -f "$root/TRAIN_COMPLETE" ]]; then
90
+ (
91
+ export CUDA_VISIBLE_DEVICES="$gpu"
92
+ export DATASET=slimpajama DATASET_CONFIG=none
93
+ export NUM_PROGRESSIVE="$cycles" SEQ_LEN=1024 DISTILL_SEQ_LEN=1024
94
+ export TARGET_TOKENS="$fit_tokens" CALIB_SEQUENCES="$calib_sequences"
95
+ export BATCH_SIZE=2 DISTILL_BATCH_SIZE=1 DISTILL_EPOCHS=1.0
96
+ export DISTILL_KL_WEIGHT=0.02 LORA_EPOCHS=0 EVAL_NUM_SAMPLES=0
97
+ export SKIP_FINAL_MODEL_SAVE=1 COMM_ENABLED=0 HEAD_PERMUTE=0
98
+ export REPARAM_PARAM_SUBSET=mlp REPARAM_FISHER_INIT_SUBSET=same
99
+ export REPARAM_TRAIN_SUBSET=same REPARAM_RHO_OBJECTIVE=none
100
+ export DISTILL_HIDDEN_MSE_WEIGHT=1.0 DISTILL_ATTN_MSE_WEIGHT=0.0
101
+ export DISTILL_MLP_MSE_WEIGHT=1.0
102
+ export DTYPE=bfloat16 EVAL_DTYPE=bfloat16 DISABLE_TQDM=1
103
+ unset SAVE_FULL_MODEL_CYCLES
104
+
105
+ bash "$repo/script/run_fuse_layers_order.sh" "$model" "$root/run" \
106
+ --layer_order "${layer_order[@]}" \
107
+ --eps 0 --skip_eval --distill_log_steps 100 --seed 42 \
108
+ --distill_lr 1e-4 --distill_weight_decay 0 --distill_max_grad_norm 1 --distill_grad_accum_steps 1 \
109
+ --source_feature_transport \
110
+ --source_feature_transport_ridge_relative 1e-3 \
111
+ --reparam_additive_u
112
+ ) >> "$root/logs/train.log" 2>&1
113
+ touch "$root/TRAIN_COMPLETE"
114
+ fi
115
+
116
+ if [[ ! -f "$root/COMPACT_COMPLETE" ]]; then
117
+ python -m fusegpt.abprune_compact \
118
+ --run-root "$root/run" --output-root "$root/compact" \
119
+ --model "$model_id" --base-revision "$revision" \
120
+ --run-id "qwen3_8b_native_cosine_transport_additive_u_${cycles}block_v1" \
121
+ --cycles "$cycles" --layer-order "${layer_order[*]}"
122
+ for stage in $(seq 1 "$cycles"); do
123
+ padded="$(printf '%02d' "$stage")"
124
+ cp "$root/run/cycle_${stage}/cycle_metadata.json" \
125
+ "$root/metadata/cycle_${padded}.json"
126
+ done
127
+ touch "$root/COMPACT_COMPLETE"
128
+ fi
129
+
130
+ if [[ -f "$root/DEFER_EVAL" || "${DEFER_EVAL:-0}" == "1" ]]; then
131
+ touch "$root/MODEL_READY_NO_EVAL"
132
+ echo "qwen3_8b_native_transport_${cycles}block=model_ready_evaluation_deferred"
133
+ exit 0
134
+ fi
135
+
136
+ for stage in $(seq 1 "$cycles"); do
137
+ padded="$(printf '%02d' "$stage")"
138
+ if [[ ! -f "$root/eval/stage_${padded}_ppl.json" ]]; then
139
+ CUDA_VISIBLE_DEVICES="$gpu" python "$project/scripts/evaluate_abprune_compact_ppl.py" \
140
+ --model "$model" --revision "$revision" \
141
+ --compact-stage "$root/compact/stage_${padded}" \
142
+ --anchor "$anchor" --cycles "$stage" --original-layers "$num_layers" \
143
+ --seq-len 2048 --batch-size 4 \
144
+ --output "$root/eval/stage_${padded}_ppl.json" \
145
+ >> "$root/logs/eval.log" 2>&1
146
+ fi
147
+ done
148
+
149
+ final_padded="$(printf '%02d' "$cycles")"
150
+ if [[ ! -f "$root/eval/stage_${final_padded}_zs6.json" ]]; then
151
+ CUDA_VISIBLE_DEVICES="$gpu" python "$project/scripts/eval_abprune_compact_zeroshot.py" \
152
+ --model "$model" --revision "$revision" \
153
+ --compact-stage "$root/compact/stage_${final_padded}" \
154
+ --cycle "$cycles" --anchor "$anchor" --batch-size auto:4 \
155
+ --output "$root/eval/stage_${final_padded}_zs6.json" \
156
+ >> "$root/logs/eval.log" 2>&1
157
+ fi
158
+
159
+ python "$project/scripts/summarize_qwen3_8b_native_span_transport.py" "$root"
160
+ touch "$root/COMPLETE"
161
+ echo "qwen3_8b_native_transport_${cycles}block=complete"
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/code/run_qwen3_base_half2.py ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Two GPU lanes: native CoMe/MKA/ReplaceMe and Fisher+Transport+FiT ABPrune."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ from concurrent.futures import ThreadPoolExecutor
6
+ import datetime
7
+ import json
8
+ import os
9
+ from pathlib import Path
10
+ import shutil
11
+ import subprocess
12
+ import sys
13
+ import time
14
+ import traceback
15
+
16
+ REV='49e3418fbbbca6ecbdf9608b4d22e5a407081db4'
17
+ METHODS=('come','mka','replaceme','abprune')
18
+
19
+
20
+ def read(path):
21
+ return json.loads(Path(path).read_text())
22
+
23
+
24
+ def write(path, value):
25
+ path=Path(path); path.parent.mkdir(parents=True,exist_ok=True)
26
+ tmp=path.with_suffix(path.suffix+'.tmp')
27
+ tmp.write_text(json.dumps(value,indent=2)+'\n'); tmp.replace(path)
28
+
29
+
30
+ def main():
31
+ p=argparse.ArgumentParser()
32
+ for name in ('project','external','root','model','session'):
33
+ p.add_argument('--'+name,required=True)
34
+ p.add_argument('--lane',choices=('all','baselines','abprune'),default='all')
35
+ a=p.parse_args()
36
+ project,external,root,model=map(Path,(a.project,a.external,a.root,a.model))
37
+ assert root.resolve().is_relative_to(Path('/workspace/artifacts'))
38
+ assert subprocess.check_output(['git','-C',str(project),'branch','--show-current'],text=True).strip()=='codex/'+a.session
39
+ root.mkdir(parents=True,exist_ok=True)
40
+ while not (root/'HALF_READY').exists():
41
+ if (root/'BOOTSTRAP_FAILED').exists():
42
+ raise RuntimeError('Bootstrap failed; inspect bootstrap.log')
43
+ time.sleep(3)
44
+ assert read(model/'config.json')['num_hidden_layers']==36
45
+ env=os.environ.copy()
46
+ env.update(HF_HOME='/workspace/.hf_home',HF_TOKEN_PATH='/root/.cache/huggingface/token',
47
+ HF_DATASETS_CACHE='/workspace/.hf_datasets36',HF_DATASETS_TRUST_REMOTE_CODE='1',
48
+ PYTHONUNBUFFERED='1',TOKENIZERS_PARALLELISM='false',OMP_NUM_THREADS='4',
49
+ PYTHONPATH=f'{project}/src:{external}/src:{project}',ABPRUNE_DATASET_REVISION='b5f90f419b7489cdba26fdbc8c022fcb5562f968')
50
+ commit=subprocess.check_output(['git','-C',str(project),'rev-parse','HEAD'],text=True).strip()
51
+ previous_execution=read(root/'execution.json') if (root/'execution.json').exists() else None
52
+ write(root/'execution.json',dict(commit=commit,session=a.session,started=datetime.datetime.now(datetime.timezone.utc).isoformat(),
53
+ gpu0=['come','mka','replaceme'],gpu1=['abprune'],removed_blocks=18,original_layers=36,auto_return=False,
54
+ lane=a.lane,previous_execution=previous_execution))
55
+
56
+ def run(cmd,log,gpu=None,offline=False,extra=None):
57
+ local=env.copy()
58
+ if gpu is not None: local['CUDA_VISIBLE_DEVICES']=str(gpu)
59
+ if offline:
60
+ local.update(HF_HUB_OFFLINE='1',HF_DATASETS_OFFLINE='1',TRANSFORMERS_OFFLINE='1')
61
+ if extra: local.update({k:str(v) for k,v in extra.items()})
62
+ log=Path(log); log.parent.mkdir(parents=True,exist_ok=True)
63
+ with log.open('a') as stream:
64
+ stream.write(json.dumps({'utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'command':list(map(str,cmd))})+'\n'); stream.flush()
65
+ subprocess.run(list(map(str,cmd)),env=local,cwd=project,stdout=stream,stderr=subprocess.STDOUT,check=True)
66
+
67
+ def phase(method,text):
68
+ write(root/'full'/method/'status.json',dict(phase=text,updated=datetime.datetime.now(datetime.timezone.utc).isoformat()))
69
+
70
+ def select():
71
+ s=root/'selection'; s.mkdir(exist_ok=True)
72
+ if not (s/'selection.json').exists():
73
+ run(['bash',str(external)+'-legacy/run_compare_layer_selection_metrics.sh'],s/'selection.log',1,
74
+ extra=dict(MODEL=model,PRUNE_LAYERS=18,DATASET='slimpajama',NUM_SEQUENCES=500,SEQ_LEN=1024,
75
+ BATCH_SIZE=2,DTYPE='bfloat16',DEVICE='cuda',SEED=42,
76
+ CHUNK_CACHE_PATH=s/'slimpajama500_seed42.pt',OUTPUT_JSON=s/'selection.json'))
77
+ rows=read(s/'selection.json')['selections']
78
+ chosen={x['method']:x for x in rows if x['method'] in ('fuse_region_cosine','replaceme')}
79
+ assert set(chosen)=={'fuse_region_cosine','replaceme'}
80
+ for x in chosen.values():
81
+ lo=int(x['removed_start'])
82
+ # The unmodified 39e selector emits an inclusive removed_end.
83
+ hi=int(x['removed_end'])+1 if 'removed_interval_half_open' not in x else x['removed_interval_half_open'][1]
84
+ assert hi-lo==18 and 1<=lo<hi<=36
85
+ assert x['inferred_pruned_layers_zero_based']==list(range(lo,hi))
86
+ x['removed_interval_half_open']=[lo,hi]
87
+ write(s/'summary.json',dict(model='Qwen/Qwen3-8B-Base',revision=REV,sequences=500,sequence_length=1024,seed=42,selections=chosen))
88
+ (s/'COMPLETE').touch()
89
+ return chosen
90
+
91
+ def evaluate(method,gpu,anchor=None):
92
+ r=root/'full'/method; phase(method,'evaluation')
93
+ shutil.copy2(root/'full/base/offline_eval.json',r/'offline_eval.json')
94
+ (r/'eval').mkdir(exist_ok=True)
95
+ compact=method=='abprune'
96
+ target=model if compact else r/'model'
97
+ args=['--compact-stage',r/'compact/stage_18','--cycle','18','--anchor',str(anchor)] if compact else []
98
+ if not (r/'eval/final_ppl.json').exists():
99
+ if compact:
100
+ cmd=[sys.executable,project/'scripts/evaluate_abprune_compact_ppl.py','--model',model,'--revision',REV,
101
+ '--compact-stage',r/'compact/stage_18','--anchor',anchor,'--cycles',18,'--original-layers',36,
102
+ '--seq-len',2048,'--batch-size',4,'--output',r/'eval/final_ppl.json']
103
+ else:
104
+ cmd=[sys.executable,project/'scripts/evaluate_hchc_wikitext2_ppl.py','--model',target,
105
+ '--batch-size',4,'--output',r/'eval/final_ppl.json']
106
+ run(cmd,r/'logs/ppl.log',gpu,True)
107
+ if not (r/'eval/final_opencompass5.json').exists():
108
+ run([sys.executable,project/'scripts/eval_opencompass_ppl_fast.py','--model',target,'--tokenizer',model,*args,
109
+ '--data-root',root/'eval_data/data','--max-batch',32,'--token-budget',8192,
110
+ '--output',r/'eval/final_opencompass5.json'],r/'logs/opencompass.log',gpu,True)
111
+ if not (r/'eval/final_lmeval9.json').exists():
112
+ run([sys.executable,project/'scripts/eval_llama31_8b_12bench.py','--model',target,*args,'--local-files-only',
113
+ '--dataset-cache',root/'lmeval_cache','--batch-size','auto:4',
114
+ '--output',r/'eval/final_lmeval9.json'],r/'logs/lmeval.log',gpu,True)
115
+ run([sys.executable,project/'scripts/aggregate_transport_rho_fit_14bench.py',r],r/'logs/aggregate.log')
116
+ assert read(r/'eval/final_ppl.json')['metrics']['tokens']==296815
117
+ (r/'EVAL_COMPLETE').touch()
118
+
119
+ def archive(method):
120
+ r=root/'full'/method; phase(method,'verified_backup')
121
+ b=root/'backup'/method
122
+ if not b.exists():
123
+ b.mkdir(parents=True)
124
+ if method=='abprune':
125
+ shutil.copytree(r/'compact/stage_18',b/'compact/stage_18')
126
+ shutil.copytree(r/'metadata',b/'stage_metadata')
127
+ else:
128
+ shutil.copytree(r/'model',b/'model')
129
+ for name in ('eval','logs'):
130
+ shutil.copytree(r/name,b/name)
131
+ for name in ('protocol.json','offline_eval.json'):
132
+ shutil.copy2(r/name,b/name)
133
+ shutil.copytree(root/'selection',b/'selection')
134
+ for name in ('environment.json','execution.json'):
135
+ shutil.copy2(root/name,b/name)
136
+ code=b/'code'; code.mkdir()
137
+ for name in ('run_qwen3_base_half2.py','bootstrap_qwen3_base_half2.sh','run_mka_pruning.py','run_come_pruning.py',
138
+ 'run_qwen3_8b_base_replaceme_depth.sh','run_qwen3_8b_native_span_transport_additive_u.sh',
139
+ 'eval_opencompass_ppl_fast.py','eval_llama31_8b_12bench.py','evaluate_hchc_wikitext2_ppl.py'):
140
+ shutil.copy2(project/'scripts'/name,code/name)
141
+ for name in ('come.py','mka.py','mka_transport.py','abprune_compact.py'):
142
+ shutil.copy2(project/'src/fusegpt'/name,code/name)
143
+ if method=='abprune':
144
+ for name in ('fuse_layers.py','fuse_layers_distill.py','source_feature_transport.py'):
145
+ shutil.copy2(external/'src'/name,code/name)
146
+ else:
147
+ shutil.copy2(project/'patches/replaceme_llama_instruction_mask_bf16.patch',code/'replaceme_llama_instruction_mask_bf16.patch')
148
+ shutil.copy2(project/'patches/replaceme_qwen_layer_types.patch',code/'replaceme_qwen_layer_types.patch')
149
+ shutil.copy2(project/'exp_md/2026-10-12_qwen3-base-half2.md',b/'protocol.md')
150
+ run([sys.executable,project/'scripts/write_tree_manifest.py',b],r/'logs/manifest.log')
151
+ receipt=root/f'{method}_backup.json'
152
+ if not receipt.exists():
153
+ local=env.copy(); local.update(HF_HUB_OFFLINE='0',HF_DATASETS_OFFLINE='0',TRANSFORMERS_OFFLINE='0')
154
+ with receipt.open('w') as out, (r/'logs/upload.log').open('a') as log:
155
+ subprocess.run([sys.executable,str(project/'scripts/upload_verified_hf_tree.py'),str(b),
156
+ '--repo-id','LJYAI/paper_revision','--path-in-repo',f'runs/{a.session}/20261012-qwen3-base-half18/{method}',
157
+ '--verify-all-files','--commit-message',f'Qwen3-8B Base 50pct {method} PPL Bench14'],
158
+ env=local,stdout=out,stderr=log,check=True)
159
+ receipt_data=read(receipt); assert receipt_data['verified'] and receipt_data['all_payload_hashes_match']
160
+ (r/'BACKUP_COMPLETE').touch(); phase(method,'complete')
161
+ records=project/'results/qwen3_base_half18_20261012'/method
162
+ records.mkdir(parents=True,exist_ok=True)
163
+ for f in (r/'eval').glob('*.json'): shutil.copy2(f,records/f.name)
164
+ for name in ('protocol.json',): shutil.copy2(r/name,records/name)
165
+ shutil.copy2(receipt,records/'backup.json')
166
+
167
+ def baselines():
168
+ for method in ('come','mka','replaceme'):
169
+ r=root/'full'/method; (r/'logs').mkdir(parents=True,exist_ok=True)
170
+ if not (r/'TRAIN_COMPLETE').exists():
171
+ phase(method,'pruning')
172
+ protocol=dict(model='Qwen/Qwen3-8B-Base',revision=REV,method=method,removed_blocks=18,
173
+ original_layers=36,target_layers=18,transport=False,fit=False,execution_commit=commit)
174
+ if method=='come':
175
+ protocol.update(calibration=dict(dataset='slimpajama',rows=256,seq_len=2048,seed=10),allow_repeat=True)
176
+ run([sys.executable,project/'scripts/run_come_pruning.py','--model',model,'--output-dir',r/'model',
177
+ '--target-layers',18,'--calibration-dataset','slimpajama','--calibration-rows',256,
178
+ '--sequence-length',2048,'--batch-size',1,'--seed',10,'--power',1,'--minimum-retention',0,
179
+ '--allow-repeat','--sbi-metric','angular_last','--dtype','bfloat16','--device-map','cuda'],r/'logs/pruning.log',0)
180
+ elif method=='mka':
181
+ protocol.update(calibration=dict(dataset='slimpajama',samples=100,seq_len=512,seed=0),
182
+ implementation='corrected local MKA; not exact paper reproduction',merge_scope='attention_and_mlp',selection='current-model NPIB')
183
+ run([sys.executable,project/'scripts/run_mka_pruning.py','--model',model,'--output-dir',r/'model',
184
+ '--remove-blocks',18,'--calibration-samples',100,'--sequence-length',512,'--seed',0,
185
+ '--batch-size',1,'--pooling','mean','--dtype','bfloat16','--device-map','cuda'],r/'logs/pruning.log',0)
186
+ else:
187
+ while not (root/'selection/COMPLETE').exists():
188
+ if (root/'abprune_FAILED').exists(): raise RuntimeError('Selection lane failed')
189
+ time.sleep(3)
190
+ selection=read(root/'selection/summary.json')['selections']['replaceme']
191
+ run(['bash',project/'scripts/run_qwen3_8b_base_replaceme_depth.sh',str(external)+'-legacy',project,r,
192
+ model,18,selection['removed_start'],0],r/'logs/pruning.log',0)
193
+ protocol=read(r/'protocol.json'); protocol['selection']=selection
194
+ assert read(r/'model/config.json')['num_hidden_layers']==18
195
+ write(r/'protocol.json',protocol); (r/'TRAIN_COMPLETE').touch()
196
+ evaluate(method,0); archive(method)
197
+
198
+ def abprune():
199
+ method='abprune'; r=root/'full'/method; (r/'logs').mkdir(parents=True,exist_ok=True)
200
+ phase(method,'span_selection')
201
+ selections=select(); s=selections['fuse_region_cosine']; anchor=s['removed_start']-1
202
+ smoke=root/'smoke/abprune'
203
+ if not (smoke/'SMOKE_VERIFIED').exists():
204
+ phase(method,'two_stage_smoke')
205
+ run(['bash',project/'scripts/run_qwen3_8b_native_span_transport_additive_u.sh',external,project,smoke,model,anchor,2,1],
206
+ smoke/'logs/pipeline.log',1,True,extra=dict(DEFER_EVAL=1,ABPRUNE_FIT_TARGET_TOKENS=20480,ABPRUNE_CALIB_SEQUENCES=4))
207
+ sm=read(smoke/'compact/stage_02/metadata.json')
208
+ assert sm['removed_count']==2 and sm['anchor_index']==anchor
209
+ (smoke/'SMOKE_VERIFIED').touch()
210
+ if not (r/'TRAIN_COMPLETE').exists():
211
+ phase(method,'pruning_and_fit')
212
+ run(['bash',project/'scripts/run_qwen3_8b_native_span_transport_additive_u.sh',external,project,r,model,anchor,18,1],
213
+ r/'logs/pipeline_train.log',1,True,extra=dict(DEFER_EVAL=1))
214
+ protocol=read(r/'protocol.json'); protocol['selection'].update(seed=42,selected=s)
215
+ protocol['execution_commit']=commit; protocol['training'].update(learning_rate=1e-4,weight_decay=0,
216
+ fit_records=512,fit_parameter_scope='mlp',epochs_per_stage=1)
217
+ write(r/'protocol.json',protocol)
218
+ m=read(r/'compact/stage_18/metadata.json')
219
+ assert m['removed_count']==18 and m['removed_original_layers']==list(range(anchor+1,anchor+19))
220
+ evaluate(method,1,anchor); archive(method)
221
+
222
+ def guarded(fn,method):
223
+ try: fn()
224
+ except Exception:
225
+ traceback.print_exc()
226
+ (root/f'{method}_FAILED').touch(); raise
227
+
228
+ with ThreadPoolExecutor(max_workers=2) as pool:
229
+ jobs=[]
230
+ if a.lane in ('all','baselines'): jobs.append(pool.submit(guarded,baselines,'baselines'))
231
+ if a.lane in ('all','abprune'): jobs.append(pool.submit(guarded,abprune,'abprune'))
232
+ for job in jobs: job.result()
233
+ while not all((root/'full'/m/'BACKUP_COMPLETE').exists() for m in METHODS):
234
+ if list(root.glob('*FAILED')): raise RuntimeError('Other lane failed; inspect its log')
235
+ time.sleep(3)
236
+ records=project/'results/qwen3_base_half18_20261012'
237
+ shutil.copytree(root/'selection',records/'selection',ignore=shutil.ignore_patterns('*.pt','*.log'),dirs_exist_ok=True)
238
+ rows=[]
239
+ for method in METHODS:
240
+ r=root/'full'/method; scores=read(r/'eval/final_14bench.json')['task_scores']
241
+ rows.append(dict(model='Qwen/Qwen3-8B-Base',method=method,removed_blocks=18,pruning_fraction=.5,
242
+ ppl=read(r/'eval/final_ppl.json')['metrics']['perplexity'],zs12=sum(v for k,v in scores.items() if k not in ('mmlu','cmmlu'))/12,
243
+ mmlu=scores['mmlu'],cmmlu=scores['cmmlu'],bench14=sum(scores.values())/14,task_scores=scores,
244
+ protocol=read(r/'protocol.json'),backup=read(root/f'{method}_backup.json')))
245
+ write(records/'summary.json',dict(rows=rows,environment=read(root/'environment.json'),execution=read(root/'execution.json')))
246
+ (root/'COMPLETE').touch()
247
+ subprocess.run(['git','-C',str(project),'add','results/qwen3_base_half18_20261012'],check=True)
248
+ subprocess.run(['git','-C',str(project),'commit','-m','Record Qwen3 Base 50pct four-method PPL Bench14 and verified weights'],check=True)
249
+ (root/'RECORDS_COMMITTED').touch()
250
+ print('ALL_FOUR_COMPLETE_BACKED_UP_INSTANCE_RETAINED',flush=True)
251
+
252
+
253
+ if __name__=='__main__':
254
+ main()
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/environment.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "python": "3.11.14",
3
+ "torch": "2.9.1+cu128",
4
+ "cuda": "12.8",
5
+ "packages": {
6
+ "transformers": "5.15.1",
7
+ "datasets": "3.6.0",
8
+ "huggingface_hub": "1.33.0",
9
+ "lm_eval": "0.4.12",
10
+ "accelerate": "1.15.0",
11
+ "scipy": "1.17.1",
12
+ "scikit-learn": "1.9.1",
13
+ "peft": "0.21.2"
14
+ }
15
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_14bench.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "task_scores": {
3
+ "race_high": 0.22898799313893653,
4
+ "race_middle": 0.21030640668523676,
5
+ "c3": 0.2580821917808219,
6
+ "cmnli": 0.3508700269585818,
7
+ "chid": 0.12871287128712872,
8
+ "piqa": 0.5772578890097932,
9
+ "winogrande": 0.5169692186266772,
10
+ "hellaswag": 0.3126867157936666,
11
+ "arc_challenge": 0.25426621160409557,
12
+ "arc_easy": 0.3223905723905724,
13
+ "openbookqa": 0.278,
14
+ "sciq": 0.269,
15
+ "mmlu": 0.22945449366187154,
16
+ "cmmlu": 0.2528060783975134
17
+ },
18
+ "macro_mean_14": 0.2992707620953497,
19
+ "tasks": [
20
+ "race_high",
21
+ "race_middle",
22
+ "c3",
23
+ "cmnli",
24
+ "chid",
25
+ "piqa",
26
+ "winogrande",
27
+ "hellaswag",
28
+ "arc_challenge",
29
+ "arc_easy",
30
+ "openbookqa",
31
+ "sciq",
32
+ "mmlu",
33
+ "cmmlu"
34
+ ],
35
+ "opencompass_protocol": "OpenCompass 0.5.4 canonical PPL prompts; full-prompt mean CE; lowest PPL",
36
+ "lm_eval_num_fewshot": 0
37
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_lmeval9.json ADDED
@@ -0,0 +1,1401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model",
3
+ "revision": null,
4
+ "compact_stage": null,
5
+ "cycle": null,
6
+ "anchor": null,
7
+ "tasks": [
8
+ "piqa",
9
+ "winogrande",
10
+ "hellaswag",
11
+ "arc_challenge",
12
+ "arc_easy",
13
+ "openbookqa",
14
+ "sciq",
15
+ "mmlu",
16
+ "cmmlu"
17
+ ],
18
+ "num_fewshot": 0,
19
+ "batch_size": "auto:4",
20
+ "limit": null,
21
+ "dataset_cache": "/workspace/artifacts/qwen3-base-half2-20261012/lmeval_cache",
22
+ "preferred_metrics": {
23
+ "piqa": "acc_norm,none",
24
+ "winogrande": "acc,none",
25
+ "hellaswag": "acc_norm,none",
26
+ "arc_challenge": "acc_norm,none",
27
+ "arc_easy": "acc_norm,none",
28
+ "openbookqa": "acc_norm,none",
29
+ "sciq": "acc_norm,none",
30
+ "mmlu": "acc,none",
31
+ "cmmlu": "acc,none"
32
+ },
33
+ "task_scores": {
34
+ "piqa": 0.5772578890097932,
35
+ "winogrande": 0.5169692186266772,
36
+ "hellaswag": 0.3126867157936666,
37
+ "arc_challenge": 0.25426621160409557,
38
+ "arc_easy": 0.3223905723905724,
39
+ "openbookqa": 0.278,
40
+ "sciq": 0.269,
41
+ "mmlu": 0.22945449366187154,
42
+ "cmmlu": 0.2528060783975134
43
+ },
44
+ "macro_mean_all_rows": 0.3347590199426878,
45
+ "lm_eval_results": {
46
+ "piqa": {
47
+ "name": "piqa",
48
+ "alias": "piqa",
49
+ "sample_len": 1838,
50
+ "acc,none": 0.5865070729053319,
51
+ "acc_stderr,none": "N/A",
52
+ "acc_norm,none": 0.5772578890097932,
53
+ "acc_norm_stderr,none": "N/A"
54
+ },
55
+ "winogrande": {
56
+ "name": "winogrande",
57
+ "alias": "winogrande",
58
+ "sample_len": 1267,
59
+ "acc,none": 0.5169692186266772,
60
+ "acc_stderr,none": "N/A"
61
+ },
62
+ "hellaswag": {
63
+ "name": "hellaswag",
64
+ "alias": "hellaswag",
65
+ "sample_len": 10042,
66
+ "acc,none": 0.2849034056960765,
67
+ "acc_stderr,none": "N/A",
68
+ "acc_norm,none": 0.3126867157936666,
69
+ "acc_norm_stderr,none": "N/A"
70
+ },
71
+ "arc_challenge": {
72
+ "name": "arc_challenge",
73
+ "alias": "arc_challenge",
74
+ "sample_len": 1172,
75
+ "acc,none": 0.20819112627986347,
76
+ "acc_stderr,none": "N/A",
77
+ "acc_norm,none": 0.25426621160409557,
78
+ "acc_norm_stderr,none": "N/A"
79
+ },
80
+ "arc_easy": {
81
+ "name": "arc_easy",
82
+ "alias": "arc_easy",
83
+ "sample_len": 2376,
84
+ "acc,none": 0.3413299663299663,
85
+ "acc_stderr,none": "N/A",
86
+ "acc_norm,none": 0.3223905723905724,
87
+ "acc_norm_stderr,none": "N/A"
88
+ },
89
+ "openbookqa": {
90
+ "name": "openbookqa",
91
+ "alias": "openbookqa",
92
+ "sample_len": 500,
93
+ "acc,none": 0.152,
94
+ "acc_stderr,none": "N/A",
95
+ "acc_norm,none": 0.278,
96
+ "acc_norm_stderr,none": "N/A"
97
+ },
98
+ "sciq": {
99
+ "name": "sciq",
100
+ "alias": "sciq",
101
+ "sample_len": 1000,
102
+ "acc,none": 0.307,
103
+ "acc_stderr,none": "N/A",
104
+ "acc_norm,none": 0.269,
105
+ "acc_norm_stderr,none": "N/A"
106
+ },
107
+ "mmlu_abstract_algebra": {
108
+ "name": "mmlu_abstract_algebra",
109
+ "alias": "abstract_algebra",
110
+ "sample_len": 100,
111
+ "acc,none": 0.22,
112
+ "acc_stderr,none": "N/A"
113
+ },
114
+ "mmlu_anatomy": {
115
+ "name": "mmlu_anatomy",
116
+ "alias": "anatomy",
117
+ "sample_len": 135,
118
+ "acc,none": 0.18518518518518517,
119
+ "acc_stderr,none": "N/A"
120
+ },
121
+ "mmlu_astronomy": {
122
+ "name": "mmlu_astronomy",
123
+ "alias": "astronomy",
124
+ "sample_len": 152,
125
+ "acc,none": 0.17763157894736842,
126
+ "acc_stderr,none": "N/A"
127
+ },
128
+ "mmlu_college_biology": {
129
+ "name": "mmlu_college_biology",
130
+ "alias": "college_biology",
131
+ "sample_len": 144,
132
+ "acc,none": 0.2569444444444444,
133
+ "acc_stderr,none": "N/A"
134
+ },
135
+ "mmlu_college_chemistry": {
136
+ "name": "mmlu_college_chemistry",
137
+ "alias": "college_chemistry",
138
+ "sample_len": 100,
139
+ "acc,none": 0.2,
140
+ "acc_stderr,none": "N/A"
141
+ },
142
+ "mmlu_college_computer_science": {
143
+ "name": "mmlu_college_computer_science",
144
+ "alias": "college_computer_science",
145
+ "sample_len": 100,
146
+ "acc,none": 0.26,
147
+ "acc_stderr,none": "N/A"
148
+ },
149
+ "mmlu_college_mathematics": {
150
+ "name": "mmlu_college_mathematics",
151
+ "alias": "college_mathematics",
152
+ "sample_len": 100,
153
+ "acc,none": 0.21,
154
+ "acc_stderr,none": "N/A"
155
+ },
156
+ "mmlu_college_physics": {
157
+ "name": "mmlu_college_physics",
158
+ "alias": "college_physics",
159
+ "sample_len": 102,
160
+ "acc,none": 0.21568627450980393,
161
+ "acc_stderr,none": "N/A"
162
+ },
163
+ "mmlu_computer_security": {
164
+ "name": "mmlu_computer_security",
165
+ "alias": "computer_security",
166
+ "sample_len": 100,
167
+ "acc,none": 0.28,
168
+ "acc_stderr,none": "N/A"
169
+ },
170
+ "mmlu_conceptual_physics": {
171
+ "name": "mmlu_conceptual_physics",
172
+ "alias": "conceptual_physics",
173
+ "sample_len": 235,
174
+ "acc,none": 0.26382978723404255,
175
+ "acc_stderr,none": "N/A"
176
+ },
177
+ "mmlu_electrical_engineering": {
178
+ "name": "mmlu_electrical_engineering",
179
+ "alias": "electrical_engineering",
180
+ "sample_len": 145,
181
+ "acc,none": 0.2413793103448276,
182
+ "acc_stderr,none": "N/A"
183
+ },
184
+ "mmlu_elementary_mathematics": {
185
+ "name": "mmlu_elementary_mathematics",
186
+ "alias": "elementary_mathematics",
187
+ "sample_len": 378,
188
+ "acc,none": 0.20899470899470898,
189
+ "acc_stderr,none": "N/A"
190
+ },
191
+ "mmlu_high_school_biology": {
192
+ "name": "mmlu_high_school_biology",
193
+ "alias": "high_school_biology",
194
+ "sample_len": 310,
195
+ "acc,none": 0.1774193548387097,
196
+ "acc_stderr,none": "N/A"
197
+ },
198
+ "mmlu_high_school_chemistry": {
199
+ "name": "mmlu_high_school_chemistry",
200
+ "alias": "high_school_chemistry",
201
+ "sample_len": 203,
202
+ "acc,none": 0.15270935960591134,
203
+ "acc_stderr,none": "N/A"
204
+ },
205
+ "mmlu_high_school_computer_science": {
206
+ "name": "mmlu_high_school_computer_science",
207
+ "alias": "high_school_computer_science",
208
+ "sample_len": 100,
209
+ "acc,none": 0.25,
210
+ "acc_stderr,none": "N/A"
211
+ },
212
+ "mmlu_high_school_mathematics": {
213
+ "name": "mmlu_high_school_mathematics",
214
+ "alias": "high_school_mathematics",
215
+ "sample_len": 270,
216
+ "acc,none": 0.2111111111111111,
217
+ "acc_stderr,none": "N/A"
218
+ },
219
+ "mmlu_high_school_physics": {
220
+ "name": "mmlu_high_school_physics",
221
+ "alias": "high_school_physics",
222
+ "sample_len": 151,
223
+ "acc,none": 0.1986754966887417,
224
+ "acc_stderr,none": "N/A"
225
+ },
226
+ "mmlu_high_school_statistics": {
227
+ "name": "mmlu_high_school_statistics",
228
+ "alias": "high_school_statistics",
229
+ "sample_len": 216,
230
+ "acc,none": 0.1527777777777778,
231
+ "acc_stderr,none": "N/A"
232
+ },
233
+ "mmlu_machine_learning": {
234
+ "name": "mmlu_machine_learning",
235
+ "alias": "machine_learning",
236
+ "sample_len": 112,
237
+ "acc,none": 0.3125,
238
+ "acc_stderr,none": "N/A"
239
+ },
240
+ "mmlu_business_ethics": {
241
+ "name": "mmlu_business_ethics",
242
+ "alias": "business_ethics",
243
+ "sample_len": 100,
244
+ "acc,none": 0.3,
245
+ "acc_stderr,none": "N/A"
246
+ },
247
+ "mmlu_clinical_knowledge": {
248
+ "name": "mmlu_clinical_knowledge",
249
+ "alias": "clinical_knowledge",
250
+ "sample_len": 265,
251
+ "acc,none": 0.21509433962264152,
252
+ "acc_stderr,none": "N/A"
253
+ },
254
+ "mmlu_college_medicine": {
255
+ "name": "mmlu_college_medicine",
256
+ "alias": "college_medicine",
257
+ "sample_len": 173,
258
+ "acc,none": 0.20809248554913296,
259
+ "acc_stderr,none": "N/A"
260
+ },
261
+ "mmlu_global_facts": {
262
+ "name": "mmlu_global_facts",
263
+ "alias": "global_facts",
264
+ "sample_len": 100,
265
+ "acc,none": 0.18,
266
+ "acc_stderr,none": "N/A"
267
+ },
268
+ "mmlu_human_aging": {
269
+ "name": "mmlu_human_aging",
270
+ "alias": "human_aging",
271
+ "sample_len": 223,
272
+ "acc,none": 0.31390134529147984,
273
+ "acc_stderr,none": "N/A"
274
+ },
275
+ "mmlu_management": {
276
+ "name": "mmlu_management",
277
+ "alias": "management",
278
+ "sample_len": 103,
279
+ "acc,none": 0.17475728155339806,
280
+ "acc_stderr,none": "N/A"
281
+ },
282
+ "mmlu_marketing": {
283
+ "name": "mmlu_marketing",
284
+ "alias": "marketing",
285
+ "sample_len": 234,
286
+ "acc,none": 0.2905982905982906,
287
+ "acc_stderr,none": "N/A"
288
+ },
289
+ "mmlu_medical_genetics": {
290
+ "name": "mmlu_medical_genetics",
291
+ "alias": "medical_genetics",
292
+ "sample_len": 100,
293
+ "acc,none": 0.3,
294
+ "acc_stderr,none": "N/A"
295
+ },
296
+ "mmlu_miscellaneous": {
297
+ "name": "mmlu_miscellaneous",
298
+ "alias": "miscellaneous",
299
+ "sample_len": 783,
300
+ "acc,none": 0.23754789272030652,
301
+ "acc_stderr,none": "N/A"
302
+ },
303
+ "mmlu_nutrition": {
304
+ "name": "mmlu_nutrition",
305
+ "alias": "nutrition",
306
+ "sample_len": 306,
307
+ "acc,none": 0.22549019607843138,
308
+ "acc_stderr,none": "N/A"
309
+ },
310
+ "mmlu_professional_accounting": {
311
+ "name": "mmlu_professional_accounting",
312
+ "alias": "professional_accounting",
313
+ "sample_len": 282,
314
+ "acc,none": 0.23404255319148937,
315
+ "acc_stderr,none": "N/A"
316
+ },
317
+ "mmlu_professional_medicine": {
318
+ "name": "mmlu_professional_medicine",
319
+ "alias": "professional_medicine",
320
+ "sample_len": 272,
321
+ "acc,none": 0.18382352941176472,
322
+ "acc_stderr,none": "N/A"
323
+ },
324
+ "mmlu_virology": {
325
+ "name": "mmlu_virology",
326
+ "alias": "virology",
327
+ "sample_len": 166,
328
+ "acc,none": 0.28313253012048195,
329
+ "acc_stderr,none": "N/A"
330
+ },
331
+ "mmlu_econometrics": {
332
+ "name": "mmlu_econometrics",
333
+ "alias": "econometrics",
334
+ "sample_len": 114,
335
+ "acc,none": 0.23684210526315788,
336
+ "acc_stderr,none": "N/A"
337
+ },
338
+ "mmlu_high_school_geography": {
339
+ "name": "mmlu_high_school_geography",
340
+ "alias": "high_school_geography",
341
+ "sample_len": 198,
342
+ "acc,none": 0.17676767676767677,
343
+ "acc_stderr,none": "N/A"
344
+ },
345
+ "mmlu_high_school_government_and_politics": {
346
+ "name": "mmlu_high_school_government_and_politics",
347
+ "alias": "high_school_government_and_politics",
348
+ "sample_len": 193,
349
+ "acc,none": 0.19689119170984457,
350
+ "acc_stderr,none": "N/A"
351
+ },
352
+ "mmlu_high_school_macroeconomics": {
353
+ "name": "mmlu_high_school_macroeconomics",
354
+ "alias": "high_school_macroeconomics",
355
+ "sample_len": 390,
356
+ "acc,none": 0.20256410256410257,
357
+ "acc_stderr,none": "N/A"
358
+ },
359
+ "mmlu_high_school_microeconomics": {
360
+ "name": "mmlu_high_school_microeconomics",
361
+ "alias": "high_school_microeconomics",
362
+ "sample_len": 238,
363
+ "acc,none": 0.21008403361344538,
364
+ "acc_stderr,none": "N/A"
365
+ },
366
+ "mmlu_high_school_psychology": {
367
+ "name": "mmlu_high_school_psychology",
368
+ "alias": "high_school_psychology",
369
+ "sample_len": 545,
370
+ "acc,none": 0.1926605504587156,
371
+ "acc_stderr,none": "N/A"
372
+ },
373
+ "mmlu_human_sexuality": {
374
+ "name": "mmlu_human_sexuality",
375
+ "alias": "human_sexuality",
376
+ "sample_len": 131,
377
+ "acc,none": 0.2595419847328244,
378
+ "acc_stderr,none": "N/A"
379
+ },
380
+ "mmlu_professional_psychology": {
381
+ "name": "mmlu_professional_psychology",
382
+ "alias": "professional_psychology",
383
+ "sample_len": 612,
384
+ "acc,none": 0.25,
385
+ "acc_stderr,none": "N/A"
386
+ },
387
+ "mmlu_public_relations": {
388
+ "name": "mmlu_public_relations",
389
+ "alias": "public_relations",
390
+ "sample_len": 110,
391
+ "acc,none": 0.21818181818181817,
392
+ "acc_stderr,none": "N/A"
393
+ },
394
+ "mmlu_security_studies": {
395
+ "name": "mmlu_security_studies",
396
+ "alias": "security_studies",
397
+ "sample_len": 245,
398
+ "acc,none": 0.18775510204081633,
399
+ "acc_stderr,none": "N/A"
400
+ },
401
+ "mmlu_sociology": {
402
+ "name": "mmlu_sociology",
403
+ "alias": "sociology",
404
+ "sample_len": 201,
405
+ "acc,none": 0.24378109452736318,
406
+ "acc_stderr,none": "N/A"
407
+ },
408
+ "mmlu_us_foreign_policy": {
409
+ "name": "mmlu_us_foreign_policy",
410
+ "alias": "us_foreign_policy",
411
+ "sample_len": 100,
412
+ "acc,none": 0.28,
413
+ "acc_stderr,none": "N/A"
414
+ },
415
+ "mmlu_formal_logic": {
416
+ "name": "mmlu_formal_logic",
417
+ "alias": "formal_logic",
418
+ "sample_len": 126,
419
+ "acc,none": 0.2857142857142857,
420
+ "acc_stderr,none": "N/A"
421
+ },
422
+ "mmlu_high_school_european_history": {
423
+ "name": "mmlu_high_school_european_history",
424
+ "alias": "high_school_european_history",
425
+ "sample_len": 165,
426
+ "acc,none": 0.21818181818181817,
427
+ "acc_stderr,none": "N/A"
428
+ },
429
+ "mmlu_high_school_us_history": {
430
+ "name": "mmlu_high_school_us_history",
431
+ "alias": "high_school_us_history",
432
+ "sample_len": 204,
433
+ "acc,none": 0.25,
434
+ "acc_stderr,none": "N/A"
435
+ },
436
+ "mmlu_high_school_world_history": {
437
+ "name": "mmlu_high_school_world_history",
438
+ "alias": "high_school_world_history",
439
+ "sample_len": 237,
440
+ "acc,none": 0.270042194092827,
441
+ "acc_stderr,none": "N/A"
442
+ },
443
+ "mmlu_international_law": {
444
+ "name": "mmlu_international_law",
445
+ "alias": "international_law",
446
+ "sample_len": 121,
447
+ "acc,none": 0.2396694214876033,
448
+ "acc_stderr,none": "N/A"
449
+ },
450
+ "mmlu_jurisprudence": {
451
+ "name": "mmlu_jurisprudence",
452
+ "alias": "jurisprudence",
453
+ "sample_len": 108,
454
+ "acc,none": 0.25925925925925924,
455
+ "acc_stderr,none": "N/A"
456
+ },
457
+ "mmlu_logical_fallacies": {
458
+ "name": "mmlu_logical_fallacies",
459
+ "alias": "logical_fallacies",
460
+ "sample_len": 163,
461
+ "acc,none": 0.22085889570552147,
462
+ "acc_stderr,none": "N/A"
463
+ },
464
+ "mmlu_moral_disputes": {
465
+ "name": "mmlu_moral_disputes",
466
+ "alias": "moral_disputes",
467
+ "sample_len": 346,
468
+ "acc,none": 0.24855491329479767,
469
+ "acc_stderr,none": "N/A"
470
+ },
471
+ "mmlu_moral_scenarios": {
472
+ "name": "mmlu_moral_scenarios",
473
+ "alias": "moral_scenarios",
474
+ "sample_len": 895,
475
+ "acc,none": 0.23798882681564246,
476
+ "acc_stderr,none": "N/A"
477
+ },
478
+ "mmlu_philosophy": {
479
+ "name": "mmlu_philosophy",
480
+ "alias": "philosophy",
481
+ "sample_len": 311,
482
+ "acc,none": 0.1864951768488746,
483
+ "acc_stderr,none": "N/A"
484
+ },
485
+ "mmlu_prehistory": {
486
+ "name": "mmlu_prehistory",
487
+ "alias": "prehistory",
488
+ "sample_len": 324,
489
+ "acc,none": 0.21604938271604937,
490
+ "acc_stderr,none": "N/A"
491
+ },
492
+ "mmlu_professional_law": {
493
+ "name": "mmlu_professional_law",
494
+ "alias": "professional_law",
495
+ "sample_len": 1534,
496
+ "acc,none": 0.2457627118644068,
497
+ "acc_stderr,none": "N/A"
498
+ },
499
+ "mmlu_world_religions": {
500
+ "name": "mmlu_world_religions",
501
+ "alias": "world_religions",
502
+ "sample_len": 171,
503
+ "acc,none": 0.3216374269005848,
504
+ "acc_stderr,none": "N/A"
505
+ },
506
+ "cmmlu_agronomy": {
507
+ "name": "cmmlu_agronomy",
508
+ "alias": "cmmlu_agronomy",
509
+ "sample_len": 169,
510
+ "acc,none": 0.24260355029585798,
511
+ "acc_stderr,none": "N/A",
512
+ "acc_norm,none": 0.24260355029585798,
513
+ "acc_norm_stderr,none": "N/A"
514
+ },
515
+ "cmmlu_anatomy": {
516
+ "name": "cmmlu_anatomy",
517
+ "alias": "cmmlu_anatomy",
518
+ "sample_len": 148,
519
+ "acc,none": 0.25675675675675674,
520
+ "acc_stderr,none": "N/A",
521
+ "acc_norm,none": 0.25675675675675674,
522
+ "acc_norm_stderr,none": "N/A"
523
+ },
524
+ "cmmlu_ancient_chinese": {
525
+ "name": "cmmlu_ancient_chinese",
526
+ "alias": "cmmlu_ancient_chinese",
527
+ "sample_len": 164,
528
+ "acc,none": 0.25609756097560976,
529
+ "acc_stderr,none": "N/A",
530
+ "acc_norm,none": 0.25609756097560976,
531
+ "acc_norm_stderr,none": "N/A"
532
+ },
533
+ "cmmlu_arts": {
534
+ "name": "cmmlu_arts",
535
+ "alias": "cmmlu_arts",
536
+ "sample_len": 160,
537
+ "acc,none": 0.25625,
538
+ "acc_stderr,none": "N/A",
539
+ "acc_norm,none": 0.25625,
540
+ "acc_norm_stderr,none": "N/A"
541
+ },
542
+ "cmmlu_astronomy": {
543
+ "name": "cmmlu_astronomy",
544
+ "alias": "cmmlu_astronomy",
545
+ "sample_len": 165,
546
+ "acc,none": 0.23636363636363636,
547
+ "acc_stderr,none": "N/A",
548
+ "acc_norm,none": 0.23636363636363636,
549
+ "acc_norm_stderr,none": "N/A"
550
+ },
551
+ "cmmlu_business_ethics": {
552
+ "name": "cmmlu_business_ethics",
553
+ "alias": "cmmlu_business_ethics",
554
+ "sample_len": 209,
555
+ "acc,none": 0.24880382775119617,
556
+ "acc_stderr,none": "N/A",
557
+ "acc_norm,none": 0.24880382775119617,
558
+ "acc_norm_stderr,none": "N/A"
559
+ },
560
+ "cmmlu_chinese_civil_service_exam": {
561
+ "name": "cmmlu_chinese_civil_service_exam",
562
+ "alias": "cmmlu_chinese_civil_service_exam",
563
+ "sample_len": 160,
564
+ "acc,none": 0.2625,
565
+ "acc_stderr,none": "N/A",
566
+ "acc_norm,none": 0.2625,
567
+ "acc_norm_stderr,none": "N/A"
568
+ },
569
+ "cmmlu_chinese_driving_rule": {
570
+ "name": "cmmlu_chinese_driving_rule",
571
+ "alias": "cmmlu_chinese_driving_rule",
572
+ "sample_len": 131,
573
+ "acc,none": 0.25190839694656486,
574
+ "acc_stderr,none": "N/A",
575
+ "acc_norm,none": 0.25190839694656486,
576
+ "acc_norm_stderr,none": "N/A"
577
+ },
578
+ "cmmlu_chinese_food_culture": {
579
+ "name": "cmmlu_chinese_food_culture",
580
+ "alias": "cmmlu_chinese_food_culture",
581
+ "sample_len": 136,
582
+ "acc,none": 0.25,
583
+ "acc_stderr,none": "N/A",
584
+ "acc_norm,none": 0.25,
585
+ "acc_norm_stderr,none": "N/A"
586
+ },
587
+ "cmmlu_chinese_foreign_policy": {
588
+ "name": "cmmlu_chinese_foreign_policy",
589
+ "alias": "cmmlu_chinese_foreign_policy",
590
+ "sample_len": 107,
591
+ "acc,none": 0.2616822429906542,
592
+ "acc_stderr,none": "N/A",
593
+ "acc_norm,none": 0.2616822429906542,
594
+ "acc_norm_stderr,none": "N/A"
595
+ },
596
+ "cmmlu_chinese_history": {
597
+ "name": "cmmlu_chinese_history",
598
+ "alias": "cmmlu_chinese_history",
599
+ "sample_len": 323,
600
+ "acc,none": 0.25077399380804954,
601
+ "acc_stderr,none": "N/A",
602
+ "acc_norm,none": 0.25077399380804954,
603
+ "acc_norm_stderr,none": "N/A"
604
+ },
605
+ "cmmlu_chinese_literature": {
606
+ "name": "cmmlu_chinese_literature",
607
+ "alias": "cmmlu_chinese_literature",
608
+ "sample_len": 204,
609
+ "acc,none": 0.2549019607843137,
610
+ "acc_stderr,none": "N/A",
611
+ "acc_norm,none": 0.2549019607843137,
612
+ "acc_norm_stderr,none": "N/A"
613
+ },
614
+ "cmmlu_chinese_teacher_qualification": {
615
+ "name": "cmmlu_chinese_teacher_qualification",
616
+ "alias": "cmmlu_chinese_teacher_qualification",
617
+ "sample_len": 179,
618
+ "acc,none": 0.25139664804469275,
619
+ "acc_stderr,none": "N/A",
620
+ "acc_norm,none": 0.25139664804469275,
621
+ "acc_norm_stderr,none": "N/A"
622
+ },
623
+ "cmmlu_clinical_knowledge": {
624
+ "name": "cmmlu_clinical_knowledge",
625
+ "alias": "cmmlu_clinical_knowledge",
626
+ "sample_len": 237,
627
+ "acc,none": 0.25316455696202533,
628
+ "acc_stderr,none": "N/A",
629
+ "acc_norm,none": 0.25316455696202533,
630
+ "acc_norm_stderr,none": "N/A"
631
+ },
632
+ "cmmlu_college_actuarial_science": {
633
+ "name": "cmmlu_college_actuarial_science",
634
+ "alias": "cmmlu_college_actuarial_science",
635
+ "sample_len": 106,
636
+ "acc,none": 0.24528301886792453,
637
+ "acc_stderr,none": "N/A",
638
+ "acc_norm,none": 0.24528301886792453,
639
+ "acc_norm_stderr,none": "N/A"
640
+ },
641
+ "cmmlu_college_education": {
642
+ "name": "cmmlu_college_education",
643
+ "alias": "cmmlu_college_education",
644
+ "sample_len": 107,
645
+ "acc,none": 0.3177570093457944,
646
+ "acc_stderr,none": "N/A",
647
+ "acc_norm,none": 0.3177570093457944,
648
+ "acc_norm_stderr,none": "N/A"
649
+ },
650
+ "cmmlu_college_engineering_hydrology": {
651
+ "name": "cmmlu_college_engineering_hydrology",
652
+ "alias": "cmmlu_college_engineering_hydrology",
653
+ "sample_len": 106,
654
+ "acc,none": 0.3018867924528302,
655
+ "acc_stderr,none": "N/A",
656
+ "acc_norm,none": 0.3018867924528302,
657
+ "acc_norm_stderr,none": "N/A"
658
+ },
659
+ "cmmlu_college_law": {
660
+ "name": "cmmlu_college_law",
661
+ "alias": "cmmlu_college_law",
662
+ "sample_len": 108,
663
+ "acc,none": 0.21296296296296297,
664
+ "acc_stderr,none": "N/A",
665
+ "acc_norm,none": 0.21296296296296297,
666
+ "acc_norm_stderr,none": "N/A"
667
+ },
668
+ "cmmlu_college_mathematics": {
669
+ "name": "cmmlu_college_mathematics",
670
+ "alias": "cmmlu_college_mathematics",
671
+ "sample_len": 105,
672
+ "acc,none": 0.2571428571428571,
673
+ "acc_stderr,none": "N/A",
674
+ "acc_norm,none": 0.2571428571428571,
675
+ "acc_norm_stderr,none": "N/A"
676
+ },
677
+ "cmmlu_college_medical_statistics": {
678
+ "name": "cmmlu_college_medical_statistics",
679
+ "alias": "cmmlu_college_medical_statistics",
680
+ "sample_len": 106,
681
+ "acc,none": 0.24528301886792453,
682
+ "acc_stderr,none": "N/A",
683
+ "acc_norm,none": 0.24528301886792453,
684
+ "acc_norm_stderr,none": "N/A"
685
+ },
686
+ "cmmlu_college_medicine": {
687
+ "name": "cmmlu_college_medicine",
688
+ "alias": "cmmlu_college_medicine",
689
+ "sample_len": 273,
690
+ "acc,none": 0.24175824175824176,
691
+ "acc_stderr,none": "N/A",
692
+ "acc_norm,none": 0.24175824175824176,
693
+ "acc_norm_stderr,none": "N/A"
694
+ },
695
+ "cmmlu_computer_science": {
696
+ "name": "cmmlu_computer_science",
697
+ "alias": "cmmlu_computer_science",
698
+ "sample_len": 204,
699
+ "acc,none": 0.25980392156862747,
700
+ "acc_stderr,none": "N/A",
701
+ "acc_norm,none": 0.25980392156862747,
702
+ "acc_norm_stderr,none": "N/A"
703
+ },
704
+ "cmmlu_computer_security": {
705
+ "name": "cmmlu_computer_security",
706
+ "alias": "cmmlu_computer_security",
707
+ "sample_len": 171,
708
+ "acc,none": 0.25146198830409355,
709
+ "acc_stderr,none": "N/A",
710
+ "acc_norm,none": 0.25146198830409355,
711
+ "acc_norm_stderr,none": "N/A"
712
+ },
713
+ "cmmlu_conceptual_physics": {
714
+ "name": "cmmlu_conceptual_physics",
715
+ "alias": "cmmlu_conceptual_physics",
716
+ "sample_len": 147,
717
+ "acc,none": 0.25170068027210885,
718
+ "acc_stderr,none": "N/A",
719
+ "acc_norm,none": 0.25170068027210885,
720
+ "acc_norm_stderr,none": "N/A"
721
+ },
722
+ "cmmlu_construction_project_management": {
723
+ "name": "cmmlu_construction_project_management",
724
+ "alias": "cmmlu_construction_project_management",
725
+ "sample_len": 139,
726
+ "acc,none": 0.2446043165467626,
727
+ "acc_stderr,none": "N/A",
728
+ "acc_norm,none": 0.2446043165467626,
729
+ "acc_norm_stderr,none": "N/A"
730
+ },
731
+ "cmmlu_economics": {
732
+ "name": "cmmlu_economics",
733
+ "alias": "cmmlu_economics",
734
+ "sample_len": 159,
735
+ "acc,none": 0.24528301886792453,
736
+ "acc_stderr,none": "N/A",
737
+ "acc_norm,none": 0.24528301886792453,
738
+ "acc_norm_stderr,none": "N/A"
739
+ },
740
+ "cmmlu_education": {
741
+ "name": "cmmlu_education",
742
+ "alias": "cmmlu_education",
743
+ "sample_len": 163,
744
+ "acc,none": 0.25153374233128833,
745
+ "acc_stderr,none": "N/A",
746
+ "acc_norm,none": 0.25153374233128833,
747
+ "acc_norm_stderr,none": "N/A"
748
+ },
749
+ "cmmlu_electrical_engineering": {
750
+ "name": "cmmlu_electrical_engineering",
751
+ "alias": "cmmlu_electrical_engineering",
752
+ "sample_len": 172,
753
+ "acc,none": 0.25,
754
+ "acc_stderr,none": "N/A",
755
+ "acc_norm,none": 0.25,
756
+ "acc_norm_stderr,none": "N/A"
757
+ },
758
+ "cmmlu_elementary_chinese": {
759
+ "name": "cmmlu_elementary_chinese",
760
+ "alias": "cmmlu_elementary_chinese",
761
+ "sample_len": 252,
762
+ "acc,none": 0.28174603174603174,
763
+ "acc_stderr,none": "N/A",
764
+ "acc_norm,none": 0.28174603174603174,
765
+ "acc_norm_stderr,none": "N/A"
766
+ },
767
+ "cmmlu_elementary_commonsense": {
768
+ "name": "cmmlu_elementary_commonsense",
769
+ "alias": "cmmlu_elementary_commonsense",
770
+ "sample_len": 198,
771
+ "acc,none": 0.24242424242424243,
772
+ "acc_stderr,none": "N/A",
773
+ "acc_norm,none": 0.24242424242424243,
774
+ "acc_norm_stderr,none": "N/A"
775
+ },
776
+ "cmmlu_elementary_information_and_technology": {
777
+ "name": "cmmlu_elementary_information_and_technology",
778
+ "alias": "cmmlu_elementary_information_and_technology",
779
+ "sample_len": 238,
780
+ "acc,none": 0.27310924369747897,
781
+ "acc_stderr,none": "N/A",
782
+ "acc_norm,none": 0.27310924369747897,
783
+ "acc_norm_stderr,none": "N/A"
784
+ },
785
+ "cmmlu_elementary_mathematics": {
786
+ "name": "cmmlu_elementary_mathematics",
787
+ "alias": "cmmlu_elementary_mathematics",
788
+ "sample_len": 230,
789
+ "acc,none": 0.2826086956521739,
790
+ "acc_stderr,none": "N/A",
791
+ "acc_norm,none": 0.2826086956521739,
792
+ "acc_norm_stderr,none": "N/A"
793
+ },
794
+ "cmmlu_ethnology": {
795
+ "name": "cmmlu_ethnology",
796
+ "alias": "cmmlu_ethnology",
797
+ "sample_len": 135,
798
+ "acc,none": 0.2518518518518518,
799
+ "acc_stderr,none": "N/A",
800
+ "acc_norm,none": 0.2518518518518518,
801
+ "acc_norm_stderr,none": "N/A"
802
+ },
803
+ "cmmlu_food_science": {
804
+ "name": "cmmlu_food_science",
805
+ "alias": "cmmlu_food_science",
806
+ "sample_len": 143,
807
+ "acc,none": 0.2517482517482518,
808
+ "acc_stderr,none": "N/A",
809
+ "acc_norm,none": 0.2517482517482518,
810
+ "acc_norm_stderr,none": "N/A"
811
+ },
812
+ "cmmlu_genetics": {
813
+ "name": "cmmlu_genetics",
814
+ "alias": "cmmlu_genetics",
815
+ "sample_len": 176,
816
+ "acc,none": 0.24431818181818182,
817
+ "acc_stderr,none": "N/A",
818
+ "acc_norm,none": 0.24431818181818182,
819
+ "acc_norm_stderr,none": "N/A"
820
+ },
821
+ "cmmlu_global_facts": {
822
+ "name": "cmmlu_global_facts",
823
+ "alias": "cmmlu_global_facts",
824
+ "sample_len": 149,
825
+ "acc,none": 0.24161073825503357,
826
+ "acc_stderr,none": "N/A",
827
+ "acc_norm,none": 0.24161073825503357,
828
+ "acc_norm_stderr,none": "N/A"
829
+ },
830
+ "cmmlu_high_school_biology": {
831
+ "name": "cmmlu_high_school_biology",
832
+ "alias": "cmmlu_high_school_biology",
833
+ "sample_len": 169,
834
+ "acc,none": 0.24260355029585798,
835
+ "acc_stderr,none": "N/A",
836
+ "acc_norm,none": 0.24260355029585798,
837
+ "acc_norm_stderr,none": "N/A"
838
+ },
839
+ "cmmlu_high_school_chemistry": {
840
+ "name": "cmmlu_high_school_chemistry",
841
+ "alias": "cmmlu_high_school_chemistry",
842
+ "sample_len": 132,
843
+ "acc,none": 0.25757575757575757,
844
+ "acc_stderr,none": "N/A",
845
+ "acc_norm,none": 0.25757575757575757,
846
+ "acc_norm_stderr,none": "N/A"
847
+ },
848
+ "cmmlu_high_school_geography": {
849
+ "name": "cmmlu_high_school_geography",
850
+ "alias": "cmmlu_high_school_geography",
851
+ "sample_len": 118,
852
+ "acc,none": 0.2542372881355932,
853
+ "acc_stderr,none": "N/A",
854
+ "acc_norm,none": 0.2542372881355932,
855
+ "acc_norm_stderr,none": "N/A"
856
+ },
857
+ "cmmlu_high_school_mathematics": {
858
+ "name": "cmmlu_high_school_mathematics",
859
+ "alias": "cmmlu_high_school_mathematics",
860
+ "sample_len": 164,
861
+ "acc,none": 0.23170731707317074,
862
+ "acc_stderr,none": "N/A",
863
+ "acc_norm,none": 0.23170731707317074,
864
+ "acc_norm_stderr,none": "N/A"
865
+ },
866
+ "cmmlu_high_school_physics": {
867
+ "name": "cmmlu_high_school_physics",
868
+ "alias": "cmmlu_high_school_physics",
869
+ "sample_len": 110,
870
+ "acc,none": 0.2545454545454545,
871
+ "acc_stderr,none": "N/A",
872
+ "acc_norm,none": 0.2545454545454545,
873
+ "acc_norm_stderr,none": "N/A"
874
+ },
875
+ "cmmlu_high_school_politics": {
876
+ "name": "cmmlu_high_school_politics",
877
+ "alias": "cmmlu_high_school_politics",
878
+ "sample_len": 143,
879
+ "acc,none": 0.2517482517482518,
880
+ "acc_stderr,none": "N/A",
881
+ "acc_norm,none": 0.2517482517482518,
882
+ "acc_norm_stderr,none": "N/A"
883
+ },
884
+ "cmmlu_human_sexuality": {
885
+ "name": "cmmlu_human_sexuality",
886
+ "alias": "cmmlu_human_sexuality",
887
+ "sample_len": 126,
888
+ "acc,none": 0.25396825396825395,
889
+ "acc_stderr,none": "N/A",
890
+ "acc_norm,none": 0.25396825396825395,
891
+ "acc_norm_stderr,none": "N/A"
892
+ },
893
+ "cmmlu_international_law": {
894
+ "name": "cmmlu_international_law",
895
+ "alias": "cmmlu_international_law",
896
+ "sample_len": 185,
897
+ "acc,none": 0.24864864864864866,
898
+ "acc_stderr,none": "N/A",
899
+ "acc_norm,none": 0.24864864864864866,
900
+ "acc_norm_stderr,none": "N/A"
901
+ },
902
+ "cmmlu_journalism": {
903
+ "name": "cmmlu_journalism",
904
+ "alias": "cmmlu_journalism",
905
+ "sample_len": 172,
906
+ "acc,none": 0.25,
907
+ "acc_stderr,none": "N/A",
908
+ "acc_norm,none": 0.25,
909
+ "acc_norm_stderr,none": "N/A"
910
+ },
911
+ "cmmlu_jurisprudence": {
912
+ "name": "cmmlu_jurisprudence",
913
+ "alias": "cmmlu_jurisprudence",
914
+ "sample_len": 411,
915
+ "acc,none": 0.25060827250608275,
916
+ "acc_stderr,none": "N/A",
917
+ "acc_norm,none": 0.25060827250608275,
918
+ "acc_norm_stderr,none": "N/A"
919
+ },
920
+ "cmmlu_legal_and_moral_basis": {
921
+ "name": "cmmlu_legal_and_moral_basis",
922
+ "alias": "cmmlu_legal_and_moral_basis",
923
+ "sample_len": 214,
924
+ "acc,none": 0.2523364485981308,
925
+ "acc_stderr,none": "N/A",
926
+ "acc_norm,none": 0.2523364485981308,
927
+ "acc_norm_stderr,none": "N/A"
928
+ },
929
+ "cmmlu_logical": {
930
+ "name": "cmmlu_logical",
931
+ "alias": "cmmlu_logical",
932
+ "sample_len": 123,
933
+ "acc,none": 0.25203252032520324,
934
+ "acc_stderr,none": "N/A",
935
+ "acc_norm,none": 0.25203252032520324,
936
+ "acc_norm_stderr,none": "N/A"
937
+ },
938
+ "cmmlu_machine_learning": {
939
+ "name": "cmmlu_machine_learning",
940
+ "alias": "cmmlu_machine_learning",
941
+ "sample_len": 122,
942
+ "acc,none": 0.2540983606557377,
943
+ "acc_stderr,none": "N/A",
944
+ "acc_norm,none": 0.2540983606557377,
945
+ "acc_norm_stderr,none": "N/A"
946
+ },
947
+ "cmmlu_management": {
948
+ "name": "cmmlu_management",
949
+ "alias": "cmmlu_management",
950
+ "sample_len": 210,
951
+ "acc,none": 0.24761904761904763,
952
+ "acc_stderr,none": "N/A",
953
+ "acc_norm,none": 0.24761904761904763,
954
+ "acc_norm_stderr,none": "N/A"
955
+ },
956
+ "cmmlu_marketing": {
957
+ "name": "cmmlu_marketing",
958
+ "alias": "cmmlu_marketing",
959
+ "sample_len": 180,
960
+ "acc,none": 0.25,
961
+ "acc_stderr,none": "N/A",
962
+ "acc_norm,none": 0.25,
963
+ "acc_norm_stderr,none": "N/A"
964
+ },
965
+ "cmmlu_marxist_theory": {
966
+ "name": "cmmlu_marxist_theory",
967
+ "alias": "cmmlu_marxist_theory",
968
+ "sample_len": 189,
969
+ "acc,none": 0.24867724867724866,
970
+ "acc_stderr,none": "N/A",
971
+ "acc_norm,none": 0.24867724867724866,
972
+ "acc_norm_stderr,none": "N/A"
973
+ },
974
+ "cmmlu_modern_chinese": {
975
+ "name": "cmmlu_modern_chinese",
976
+ "alias": "cmmlu_modern_chinese",
977
+ "sample_len": 116,
978
+ "acc,none": 0.25,
979
+ "acc_stderr,none": "N/A",
980
+ "acc_norm,none": 0.25,
981
+ "acc_norm_stderr,none": "N/A"
982
+ },
983
+ "cmmlu_nutrition": {
984
+ "name": "cmmlu_nutrition",
985
+ "alias": "cmmlu_nutrition",
986
+ "sample_len": 145,
987
+ "acc,none": 0.25517241379310346,
988
+ "acc_stderr,none": "N/A",
989
+ "acc_norm,none": 0.25517241379310346,
990
+ "acc_norm_stderr,none": "N/A"
991
+ },
992
+ "cmmlu_philosophy": {
993
+ "name": "cmmlu_philosophy",
994
+ "alias": "cmmlu_philosophy",
995
+ "sample_len": 105,
996
+ "acc,none": 0.24761904761904763,
997
+ "acc_stderr,none": "N/A",
998
+ "acc_norm,none": 0.24761904761904763,
999
+ "acc_norm_stderr,none": "N/A"
1000
+ },
1001
+ "cmmlu_professional_accounting": {
1002
+ "name": "cmmlu_professional_accounting",
1003
+ "alias": "cmmlu_professional_accounting",
1004
+ "sample_len": 175,
1005
+ "acc,none": 0.2571428571428571,
1006
+ "acc_stderr,none": "N/A",
1007
+ "acc_norm,none": 0.2571428571428571,
1008
+ "acc_norm_stderr,none": "N/A"
1009
+ },
1010
+ "cmmlu_professional_law": {
1011
+ "name": "cmmlu_professional_law",
1012
+ "alias": "cmmlu_professional_law",
1013
+ "sample_len": 211,
1014
+ "acc,none": 0.25118483412322273,
1015
+ "acc_stderr,none": "N/A",
1016
+ "acc_norm,none": 0.25118483412322273,
1017
+ "acc_norm_stderr,none": "N/A"
1018
+ },
1019
+ "cmmlu_professional_medicine": {
1020
+ "name": "cmmlu_professional_medicine",
1021
+ "alias": "cmmlu_professional_medicine",
1022
+ "sample_len": 376,
1023
+ "acc,none": 0.25,
1024
+ "acc_stderr,none": "N/A",
1025
+ "acc_norm,none": 0.25,
1026
+ "acc_norm_stderr,none": "N/A"
1027
+ },
1028
+ "cmmlu_professional_psychology": {
1029
+ "name": "cmmlu_professional_psychology",
1030
+ "alias": "cmmlu_professional_psychology",
1031
+ "sample_len": 232,
1032
+ "acc,none": 0.25,
1033
+ "acc_stderr,none": "N/A",
1034
+ "acc_norm,none": 0.25,
1035
+ "acc_norm_stderr,none": "N/A"
1036
+ },
1037
+ "cmmlu_public_relations": {
1038
+ "name": "cmmlu_public_relations",
1039
+ "alias": "cmmlu_public_relations",
1040
+ "sample_len": 174,
1041
+ "acc,none": 0.25287356321839083,
1042
+ "acc_stderr,none": "N/A",
1043
+ "acc_norm,none": 0.25287356321839083,
1044
+ "acc_norm_stderr,none": "N/A"
1045
+ },
1046
+ "cmmlu_security_study": {
1047
+ "name": "cmmlu_security_study",
1048
+ "alias": "cmmlu_security_study",
1049
+ "sample_len": 135,
1050
+ "acc,none": 0.2518518518518518,
1051
+ "acc_stderr,none": "N/A",
1052
+ "acc_norm,none": 0.2518518518518518,
1053
+ "acc_norm_stderr,none": "N/A"
1054
+ },
1055
+ "cmmlu_sociology": {
1056
+ "name": "cmmlu_sociology",
1057
+ "alias": "cmmlu_sociology",
1058
+ "sample_len": 226,
1059
+ "acc,none": 0.252212389380531,
1060
+ "acc_stderr,none": "N/A",
1061
+ "acc_norm,none": 0.252212389380531,
1062
+ "acc_norm_stderr,none": "N/A"
1063
+ },
1064
+ "cmmlu_sports_science": {
1065
+ "name": "cmmlu_sports_science",
1066
+ "alias": "cmmlu_sports_science",
1067
+ "sample_len": 165,
1068
+ "acc,none": 0.24848484848484848,
1069
+ "acc_stderr,none": "N/A",
1070
+ "acc_norm,none": 0.24848484848484848,
1071
+ "acc_norm_stderr,none": "N/A"
1072
+ },
1073
+ "cmmlu_traditional_chinese_medicine": {
1074
+ "name": "cmmlu_traditional_chinese_medicine",
1075
+ "alias": "cmmlu_traditional_chinese_medicine",
1076
+ "sample_len": 185,
1077
+ "acc,none": 0.24864864864864866,
1078
+ "acc_stderr,none": "N/A",
1079
+ "acc_norm,none": 0.24864864864864866,
1080
+ "acc_norm_stderr,none": "N/A"
1081
+ },
1082
+ "cmmlu_virology": {
1083
+ "name": "cmmlu_virology",
1084
+ "alias": "cmmlu_virology",
1085
+ "sample_len": 169,
1086
+ "acc,none": 0.25443786982248523,
1087
+ "acc_stderr,none": "N/A",
1088
+ "acc_norm,none": 0.25443786982248523,
1089
+ "acc_norm_stderr,none": "N/A"
1090
+ },
1091
+ "cmmlu_world_history": {
1092
+ "name": "cmmlu_world_history",
1093
+ "alias": "cmmlu_world_history",
1094
+ "sample_len": 161,
1095
+ "acc,none": 0.2422360248447205,
1096
+ "acc_stderr,none": "N/A",
1097
+ "acc_norm,none": 0.2422360248447205,
1098
+ "acc_norm_stderr,none": "N/A"
1099
+ },
1100
+ "cmmlu_world_religions": {
1101
+ "name": "cmmlu_world_religions",
1102
+ "alias": "cmmlu_world_religions",
1103
+ "sample_len": 160,
1104
+ "acc,none": 0.25625,
1105
+ "acc_stderr,none": "N/A",
1106
+ "acc_norm,none": 0.25625,
1107
+ "acc_norm_stderr,none": "N/A"
1108
+ },
1109
+ "mmlu_stem": {
1110
+ "alias": "stem",
1111
+ "name": "mmlu_stem",
1112
+ "sample_len": 3153,
1113
+ "acc,none": 0.21249603552172533,
1114
+ "acc_stderr,none": "N/A",
1115
+ "sample_count": {
1116
+ "acc,none": 3153
1117
+ }
1118
+ },
1119
+ "mmlu_other": {
1120
+ "alias": "other",
1121
+ "name": "mmlu_other",
1122
+ "sample_len": 3107,
1123
+ "acc,none": 0.23978113936272932,
1124
+ "acc_stderr,none": "N/A",
1125
+ "sample_count": {
1126
+ "acc,none": 3107
1127
+ }
1128
+ },
1129
+ "mmlu_social_sciences": {
1130
+ "alias": "social sciences",
1131
+ "name": "mmlu_social_sciences",
1132
+ "sample_len": 3077,
1133
+ "acc,none": 0.2170945726356841,
1134
+ "acc_stderr,none": "N/A",
1135
+ "sample_count": {
1136
+ "acc,none": 3077
1137
+ }
1138
+ },
1139
+ "mmlu_humanities": {
1140
+ "alias": "humanities",
1141
+ "name": "mmlu_humanities",
1142
+ "sample_len": 4705,
1143
+ "acc,none": 0.24208289054197663,
1144
+ "acc_stderr,none": "N/A",
1145
+ "sample_count": {
1146
+ "acc,none": 4705
1147
+ }
1148
+ },
1149
+ "mmlu": {
1150
+ "alias": "mmlu",
1151
+ "name": "mmlu",
1152
+ "sample_len": 14042,
1153
+ "acc,none": 0.22945449366187154,
1154
+ "acc_stderr,none": "N/A",
1155
+ "sample_count": {
1156
+ "acc,none": 14042
1157
+ }
1158
+ },
1159
+ "cmmlu": {
1160
+ "alias": "cmmlu",
1161
+ "name": "cmmlu",
1162
+ "sample_len": 11582,
1163
+ "acc,none": 0.2528060783975134,
1164
+ "acc_stderr,none": "N/A",
1165
+ "acc_norm,none": 0.2528060783975134,
1166
+ "acc_norm_stderr,none": "N/A",
1167
+ "sample_count": {
1168
+ "acc,none": 11582,
1169
+ "acc_norm,none": 11582
1170
+ }
1171
+ }
1172
+ },
1173
+ "lm_eval_groups": {
1174
+ "mmlu_stem": {
1175
+ "alias": "stem",
1176
+ "name": "mmlu_stem",
1177
+ "sample_len": 3153,
1178
+ "acc,none": 0.21249603552172533,
1179
+ "acc_stderr,none": "N/A",
1180
+ "sample_count": {
1181
+ "acc,none": 3153
1182
+ }
1183
+ },
1184
+ "mmlu_other": {
1185
+ "alias": "other",
1186
+ "name": "mmlu_other",
1187
+ "sample_len": 3107,
1188
+ "acc,none": 0.23978113936272932,
1189
+ "acc_stderr,none": "N/A",
1190
+ "sample_count": {
1191
+ "acc,none": 3107
1192
+ }
1193
+ },
1194
+ "mmlu_social_sciences": {
1195
+ "alias": "social sciences",
1196
+ "name": "mmlu_social_sciences",
1197
+ "sample_len": 3077,
1198
+ "acc,none": 0.2170945726356841,
1199
+ "acc_stderr,none": "N/A",
1200
+ "sample_count": {
1201
+ "acc,none": 3077
1202
+ }
1203
+ },
1204
+ "mmlu_humanities": {
1205
+ "alias": "humanities",
1206
+ "name": "mmlu_humanities",
1207
+ "sample_len": 4705,
1208
+ "acc,none": 0.24208289054197663,
1209
+ "acc_stderr,none": "N/A",
1210
+ "sample_count": {
1211
+ "acc,none": 4705
1212
+ }
1213
+ },
1214
+ "mmlu": {
1215
+ "alias": "mmlu",
1216
+ "name": "mmlu",
1217
+ "sample_len": 14042,
1218
+ "acc,none": 0.22945449366187154,
1219
+ "acc_stderr,none": "N/A",
1220
+ "sample_count": {
1221
+ "acc,none": 14042
1222
+ }
1223
+ },
1224
+ "cmmlu": {
1225
+ "alias": "cmmlu",
1226
+ "name": "cmmlu",
1227
+ "sample_len": 11582,
1228
+ "acc,none": 0.2528060783975134,
1229
+ "acc_stderr,none": "N/A",
1230
+ "acc_norm,none": 0.2528060783975134,
1231
+ "acc_norm_stderr,none": "N/A",
1232
+ "sample_count": {
1233
+ "acc,none": 11582,
1234
+ "acc_norm,none": 11582
1235
+ }
1236
+ }
1237
+ },
1238
+ "lm_eval_versions": {
1239
+ "arc_challenge": 1.0,
1240
+ "arc_easy": 1.0,
1241
+ "cmmlu": "1.0",
1242
+ "cmmlu_agronomy": 1.0,
1243
+ "cmmlu_anatomy": 1.0,
1244
+ "cmmlu_ancient_chinese": 1.0,
1245
+ "cmmlu_arts": 1.0,
1246
+ "cmmlu_astronomy": 1.0,
1247
+ "cmmlu_business_ethics": 1.0,
1248
+ "cmmlu_chinese_civil_service_exam": 1.0,
1249
+ "cmmlu_chinese_driving_rule": 1.0,
1250
+ "cmmlu_chinese_food_culture": 1.0,
1251
+ "cmmlu_chinese_foreign_policy": 1.0,
1252
+ "cmmlu_chinese_history": 1.0,
1253
+ "cmmlu_chinese_literature": 1.0,
1254
+ "cmmlu_chinese_teacher_qualification": 1.0,
1255
+ "cmmlu_clinical_knowledge": 1.0,
1256
+ "cmmlu_college_actuarial_science": 1.0,
1257
+ "cmmlu_college_education": 1.0,
1258
+ "cmmlu_college_engineering_hydrology": 1.0,
1259
+ "cmmlu_college_law": 1.0,
1260
+ "cmmlu_college_mathematics": 1.0,
1261
+ "cmmlu_college_medical_statistics": 1.0,
1262
+ "cmmlu_college_medicine": 1.0,
1263
+ "cmmlu_computer_science": 1.0,
1264
+ "cmmlu_computer_security": 1.0,
1265
+ "cmmlu_conceptual_physics": 1.0,
1266
+ "cmmlu_construction_project_management": 1.0,
1267
+ "cmmlu_economics": 1.0,
1268
+ "cmmlu_education": 1.0,
1269
+ "cmmlu_electrical_engineering": 1.0,
1270
+ "cmmlu_elementary_chinese": 1.0,
1271
+ "cmmlu_elementary_commonsense": 1.0,
1272
+ "cmmlu_elementary_information_and_technology": 1.0,
1273
+ "cmmlu_elementary_mathematics": 1.0,
1274
+ "cmmlu_ethnology": 1.0,
1275
+ "cmmlu_food_science": 1.0,
1276
+ "cmmlu_genetics": 1.0,
1277
+ "cmmlu_global_facts": 1.0,
1278
+ "cmmlu_high_school_biology": 1.0,
1279
+ "cmmlu_high_school_chemistry": 1.0,
1280
+ "cmmlu_high_school_geography": 1.0,
1281
+ "cmmlu_high_school_mathematics": 1.0,
1282
+ "cmmlu_high_school_physics": 1.0,
1283
+ "cmmlu_high_school_politics": 1.0,
1284
+ "cmmlu_human_sexuality": 1.0,
1285
+ "cmmlu_international_law": 1.0,
1286
+ "cmmlu_journalism": 1.0,
1287
+ "cmmlu_jurisprudence": 1.0,
1288
+ "cmmlu_legal_and_moral_basis": 1.0,
1289
+ "cmmlu_logical": 1.0,
1290
+ "cmmlu_machine_learning": 1.0,
1291
+ "cmmlu_management": 1.0,
1292
+ "cmmlu_marketing": 1.0,
1293
+ "cmmlu_marxist_theory": 1.0,
1294
+ "cmmlu_modern_chinese": 1.0,
1295
+ "cmmlu_nutrition": 1.0,
1296
+ "cmmlu_philosophy": 1.0,
1297
+ "cmmlu_professional_accounting": 1.0,
1298
+ "cmmlu_professional_law": 1.0,
1299
+ "cmmlu_professional_medicine": 1.0,
1300
+ "cmmlu_professional_psychology": 1.0,
1301
+ "cmmlu_public_relations": 1.0,
1302
+ "cmmlu_security_study": 1.0,
1303
+ "cmmlu_sociology": 1.0,
1304
+ "cmmlu_sports_science": 1.0,
1305
+ "cmmlu_traditional_chinese_medicine": 1.0,
1306
+ "cmmlu_virology": 1.0,
1307
+ "cmmlu_world_history": 1.0,
1308
+ "cmmlu_world_religions": 1.0,
1309
+ "hellaswag": 1.0,
1310
+ "mmlu": "2",
1311
+ "mmlu_abstract_algebra": 1.0,
1312
+ "mmlu_anatomy": 1.0,
1313
+ "mmlu_astronomy": 1.0,
1314
+ "mmlu_business_ethics": 1.0,
1315
+ "mmlu_clinical_knowledge": 1.0,
1316
+ "mmlu_college_biology": 1.0,
1317
+ "mmlu_college_chemistry": 1.0,
1318
+ "mmlu_college_computer_science": 1.0,
1319
+ "mmlu_college_mathematics": 1.0,
1320
+ "mmlu_college_medicine": 1.0,
1321
+ "mmlu_college_physics": 1.0,
1322
+ "mmlu_computer_security": 1.0,
1323
+ "mmlu_conceptual_physics": 1.0,
1324
+ "mmlu_econometrics": 1.0,
1325
+ "mmlu_electrical_engineering": 1.0,
1326
+ "mmlu_elementary_mathematics": 1.0,
1327
+ "mmlu_formal_logic": 1.0,
1328
+ "mmlu_global_facts": 1.0,
1329
+ "mmlu_high_school_biology": 1.0,
1330
+ "mmlu_high_school_chemistry": 1.0,
1331
+ "mmlu_high_school_computer_science": 1.0,
1332
+ "mmlu_high_school_european_history": 1.0,
1333
+ "mmlu_high_school_geography": 1.0,
1334
+ "mmlu_high_school_government_and_politics": 1.0,
1335
+ "mmlu_high_school_macroeconomics": 1.0,
1336
+ "mmlu_high_school_mathematics": 1.0,
1337
+ "mmlu_high_school_microeconomics": 1.0,
1338
+ "mmlu_high_school_physics": 1.0,
1339
+ "mmlu_high_school_psychology": 1.0,
1340
+ "mmlu_high_school_statistics": 1.0,
1341
+ "mmlu_high_school_us_history": 1.0,
1342
+ "mmlu_high_school_world_history": 1.0,
1343
+ "mmlu_human_aging": 1.0,
1344
+ "mmlu_human_sexuality": 1.0,
1345
+ "mmlu_humanities": "2",
1346
+ "mmlu_international_law": 1.0,
1347
+ "mmlu_jurisprudence": 1.0,
1348
+ "mmlu_logical_fallacies": 1.0,
1349
+ "mmlu_machine_learning": 1.0,
1350
+ "mmlu_management": 1.0,
1351
+ "mmlu_marketing": 1.0,
1352
+ "mmlu_medical_genetics": 1.0,
1353
+ "mmlu_miscellaneous": 1.0,
1354
+ "mmlu_moral_disputes": 1.0,
1355
+ "mmlu_moral_scenarios": 1.0,
1356
+ "mmlu_nutrition": 1.0,
1357
+ "mmlu_other": "2",
1358
+ "mmlu_philosophy": 1.0,
1359
+ "mmlu_prehistory": 1.0,
1360
+ "mmlu_professional_accounting": 1.0,
1361
+ "mmlu_professional_law": 1.0,
1362
+ "mmlu_professional_medicine": 1.0,
1363
+ "mmlu_professional_psychology": 1.0,
1364
+ "mmlu_public_relations": 1.0,
1365
+ "mmlu_security_studies": 1.0,
1366
+ "mmlu_social_sciences": "2",
1367
+ "mmlu_sociology": 1.0,
1368
+ "mmlu_stem": "2",
1369
+ "mmlu_us_foreign_policy": 1.0,
1370
+ "mmlu_virology": 1.0,
1371
+ "mmlu_world_religions": 1.0,
1372
+ "openbookqa": 1.0,
1373
+ "piqa": 1.0,
1374
+ "sciq": 1.0,
1375
+ "winogrande": 1.0
1376
+ },
1377
+ "lm_eval_config": {
1378
+ "model": "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model",
1379
+ "model_args": null,
1380
+ "model_num_parameters": 4717699584,
1381
+ "model_dtype": "torch.bfloat16",
1382
+ "model_revision": "main",
1383
+ "model_sha": "",
1384
+ "batch_size": "auto:4",
1385
+ "batch_sizes": [
1386
+ 64,
1387
+ 64,
1388
+ 64,
1389
+ 64
1390
+ ],
1391
+ "device": null,
1392
+ "use_cache": null,
1393
+ "limit": null,
1394
+ "bootstrap_iters": 0,
1395
+ "gen_kwargs": null,
1396
+ "random_seed": 0,
1397
+ "numpy_seed": 1234,
1398
+ "torch_seed": 1234,
1399
+ "fewshot_seed": 1234
1400
+ }
1401
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_opencompass5.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model",
3
+ "revision": null,
4
+ "compact_stage": null,
5
+ "cycle": null,
6
+ "anchor": null,
7
+ "tokenizer": "/workspace/models/qwen3-8b-base-49e3418",
8
+ "protocol": "OpenCompass 0.5.4 canonical PPL prompts; full-prompt mean CE; lowest PPL",
9
+ "max_batch": 32,
10
+ "token_budget": 8192,
11
+ "limit": null,
12
+ "results": {
13
+ "race-middle": {
14
+ "accuracy": 0.21030640668523676,
15
+ "correct": 302,
16
+ "samples": 1436,
17
+ "choices": 5744
18
+ },
19
+ "race-high": {
20
+ "accuracy": 0.22898799313893653,
21
+ "correct": 801,
22
+ "samples": 3498,
23
+ "choices": 13992
24
+ },
25
+ "C3": {
26
+ "accuracy": 0.2580821917808219,
27
+ "correct": 471,
28
+ "samples": 1825,
29
+ "choices": 7300
30
+ },
31
+ "cmnli": {
32
+ "accuracy": 0.3508700269585818,
33
+ "correct": 4295,
34
+ "samples": 12241,
35
+ "choices": 36723
36
+ },
37
+ "chid-dev": {
38
+ "accuracy": 0.12871287128712872,
39
+ "correct": 26,
40
+ "samples": 202,
41
+ "choices": 1414
42
+ }
43
+ }
44
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/eval/final_ppl.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model",
3
+ "dataset": "Salesforce/wikitext:wikitext-2-raw-v1:test",
4
+ "protocol": "HCHC experiment.py: non-empty rows joined with double newline before one-shot tokenization",
5
+ "sequence_length": 2048,
6
+ "batch_size": 4,
7
+ "dtype": "bfloat16",
8
+ "residual_anchor": null,
9
+ "residual_gamma": null,
10
+ "metrics": {
11
+ "nll": 5.628321035977067,
12
+ "perplexity": 278.1946465063952,
13
+ "tokens": 296815,
14
+ "sequences": 145,
15
+ "source_tokens": 298938
16
+ }
17
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/execution.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "commit": "071af23f4ba37d191d2f64c742cff39978361646",
3
+ "session": "vast-paper_revision-qwen3-base-half2-55563310-20261012",
4
+ "started": "2026-10-12T14:14:05.973961+00:00",
5
+ "gpu0": [
6
+ "come",
7
+ "mka",
8
+ "replaceme"
9
+ ],
10
+ "gpu1": [
11
+ "abprune"
12
+ ],
13
+ "removed_blocks": 18,
14
+ "original_layers": 36,
15
+ "auto_return": false,
16
+ "lane": "abprune",
17
+ "previous_execution": {
18
+ "commit": "2439e302ff8de33e864075ac868c854cdb9a3d55",
19
+ "session": "vast-paper_revision-qwen3-base-half2-55563310-20261012",
20
+ "started": "2026-10-12T14:08:54.493091+00:00",
21
+ "gpu0": [
22
+ "come",
23
+ "mka",
24
+ "replaceme"
25
+ ],
26
+ "gpu1": [
27
+ "abprune"
28
+ ],
29
+ "removed_blocks": 18,
30
+ "original_layers": 36,
31
+ "auto_return": false
32
+ }
33
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/aggregate.log ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"utc": "2026-10-12T15:26:49.247271+00:00", "command": ["/opt/conda/bin/python", "/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012/scripts/aggregate_transport_rho_fit_14bench.py", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme"]}
2
+ {
3
+ "task_scores": {
4
+ "race_high": 0.22898799313893653,
5
+ "race_middle": 0.21030640668523676,
6
+ "c3": 0.2580821917808219,
7
+ "cmnli": 0.3508700269585818,
8
+ "chid": 0.12871287128712872,
9
+ "piqa": 0.5772578890097932,
10
+ "winogrande": 0.5169692186266772,
11
+ "hellaswag": 0.3126867157936666,
12
+ "arc_challenge": 0.25426621160409557,
13
+ "arc_easy": 0.3223905723905724,
14
+ "openbookqa": 0.278,
15
+ "sciq": 0.269,
16
+ "mmlu": 0.22945449366187154,
17
+ "cmmlu": 0.2528060783975134
18
+ },
19
+ "macro_mean_14": 0.2992707620953497,
20
+ "tasks": [
21
+ "race_high",
22
+ "race_middle",
23
+ "c3",
24
+ "cmnli",
25
+ "chid",
26
+ "piqa",
27
+ "winogrande",
28
+ "hellaswag",
29
+ "arc_challenge",
30
+ "arc_easy",
31
+ "openbookqa",
32
+ "sciq",
33
+ "mmlu",
34
+ "cmmlu"
35
+ ],
36
+ "opencompass_protocol": "OpenCompass 0.5.4 canonical PPL prompts; full-prompt mean CE; lowest PPL",
37
+ "lm_eval_num_fewshot": 0
38
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/lmeval.log ADDED
The diff for this file is too large to render. See raw diff
 
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/opencompass.log ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"utc": "2026-10-12T15:11:27.520184+00:00", "command": ["/opt/conda/bin/python", "/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012/scripts/eval_opencompass_ppl_fast.py", "--model", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model", "--tokenizer", "/workspace/models/qwen3-8b-base-49e3418", "--data-root", "/workspace/artifacts/qwen3-base-half2-20261012/eval_data/data", "--max-batch", "32", "--token-budget", "8192", "--output", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/eval/final_opencompass5.json"]}
2
+ [transformers] `torch_dtype` is deprecated! Use `dtype` instead!
3
+
4
+ task=race-middle samples=1436
5
+ choices=1011/5744
6
+ choices=2010/5744
7
+ choices=3015/5744
8
+ choices=4018/5744
9
+ choices=5010/5744
10
+ choices=5744/5744
11
+ {"race-middle": {"accuracy": 0.21030640668523676, "correct": 302, "samples": 1436, "choices": 5744}}
12
+ task=race-high samples=3498
13
+ choices=1010/13992
14
+ choices=2006/13992
15
+ choices=3015/13992
16
+ choices=4007/13992
17
+ choices=5005/13992
18
+ choices=6008/13992
19
+ choices=7015/13992
20
+ choices=8005/13992
21
+ choices=9010/13992
22
+ choices=10007/13992
23
+ choices=11012/13992
24
+ choices=12007/13992
25
+ choices=13005/13992
26
+ choices=13992/13992
27
+ {"race-high": {"accuracy": 0.22898799313893653, "correct": 801, "samples": 3498, "choices": 13992}}
28
+ task=C3 samples=1825
29
+ choices=1024/7300
30
+ choices=2016/7300
31
+ choices=3008/7300
32
+ choices=4000/7300
33
+ choices=5024/7300
34
+ choices=6016/7300
35
+ choices=7008/7300
36
+ choices=7300/7300
37
+ {"C3": {"accuracy": 0.2580821917808219, "correct": 471, "samples": 1825, "choices": 7300}}
38
+ task=cmnli samples=12241
39
+ choices=1024/36723
40
+ choices=2016/36723
41
+ choices=3008/36723
42
+ choices=4000/36723
43
+ choices=5024/36723
44
+ choices=6016/36723
45
+ choices=7008/36723
46
+ choices=8000/36723
47
+ choices=9024/36723
48
+ choices=10016/36723
49
+ choices=11008/36723
50
+ choices=12000/36723
51
+ choices=13024/36723
52
+ choices=14016/36723
53
+ choices=15008/36723
54
+ choices=16000/36723
55
+ choices=17024/36723
56
+ choices=18016/36723
57
+ choices=19008/36723
58
+ choices=20000/36723
59
+ choices=21024/36723
60
+ choices=22016/36723
61
+ choices=23008/36723
62
+ choices=24000/36723
63
+ choices=25024/36723
64
+ choices=26016/36723
65
+ choices=27008/36723
66
+ choices=28000/36723
67
+ choices=29024/36723
68
+ choices=30016/36723
69
+ choices=31008/36723
70
+ choices=32000/36723
71
+ choices=33024/36723
72
+ choices=34016/36723
73
+ choices=35008/36723
74
+ choices=36000/36723
75
+ choices=36723/36723
76
+ {"cmnli": {"accuracy": 0.3508700269585818, "correct": 4295, "samples": 12241, "choices": 36723}}
77
+ task=chid-dev samples=202
78
+ choices=1024/1414
79
+ choices=1414/1414
80
+ {"chid-dev": {"accuracy": 0.12871287128712872, "correct": 26, "samples": 202, "choices": 1414}}
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/ppl.log ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"utc": "2026-10-12T15:11:08.523208+00:00", "command": ["/opt/conda/bin/python", "/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012/scripts/evaluate_hchc_wikitext2_ppl.py", "--model", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model", "--batch-size", "4", "--output", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/eval/final_ppl.json"]}
2
+ [transformers] `torch_dtype` is deprecated! Use `dtype` instead!
3
+
4
+ Using the latest cached version of the dataset since Salesforce/wikitext couldn't be found on the Hugging Face Hub (offline mode is enabled).
5
+ Found the latest cached dataset configuration 'wikitext-2-raw-v1' at /workspace/.hf_datasets36/Salesforce___wikitext/wikitext-2-raw-v1/0.0.0/b08601e04326c79dfdd32d625aee71d232d685c3 (last modified on Mon Oct 12 14:08:51 2026).
6
+ [transformers] Token indices sequence length is longer than the specified maximum sequence length for this model (298938 > 131072). Running this sequence through the model will result in indexing errors
7
+ {
8
+ "model": "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model",
9
+ "dataset": "Salesforce/wikitext:wikitext-2-raw-v1:test",
10
+ "protocol": "HCHC experiment.py: non-empty rows joined with double newline before one-shot tokenization",
11
+ "sequence_length": 2048,
12
+ "batch_size": 4,
13
+ "dtype": "bfloat16",
14
+ "residual_anchor": null,
15
+ "residual_gamma": null,
16
+ "metrics": {
17
+ "nll": 5.628321035977067,
18
+ "perplexity": 278.1946465063952,
19
+ "tokens": 296815,
20
+ "sequences": 145,
21
+ "source_tokens": 298938
22
+ }
23
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/pruning.log ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {"utc": "2026-10-12T14:50:19.049172+00:00", "command": ["bash", "/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012/scripts/run_qwen3_8b_base_replaceme_depth.sh", "/workspace/external/qwen3-base-half2-legacy", "/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012", "/workspace/artifacts/qwen3-base-half2-20261012/full/replaceme", "/workspace/models/qwen3-8b-base-49e3418", "18", "14", "0"]}
2
+ error: patch failed: compare_model/ReplaceMe/ReplaceMe/lstsq.py:92
3
+ error: compare_model/ReplaceMe/ReplaceMe/lstsq.py: patch does not apply
4
+ error: patch failed: compare_model/ReplaceMe/ReplaceMe/utils.py:80
5
+ error: compare_model/ReplaceMe/ReplaceMe/utils.py: patch does not apply
6
+ qwen3_8b_base_replaceme_18block=model_ready_evaluation_deferred
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/logs/train.log ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Seeded with seed: 42
2
+ Seeded with seed: 42
3
+ Seeded with seed: 42
4
+ Seeded with seed: 42
5
+ Seeded with seed: 42
6
+ Seeded with seed: 42
7
+ 2026-10-12 14:50:21 [INFO] Using shared selected span; skipping ReplaceMe distance profiling
8
+ [transformers] The following generation flags are not valid and may be ignored: ['output_hidden_states']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
9
+
10
+ 2026-10-12 14:50:23 [INFO] HTTP Request: HEAD https://huggingface.co/datasets/DKYoon/SlimPajama-6B/resolve/b5f90f419b7489cdba26fdbc8c022fcb5562f968/SlimPajama-6B.py "HTTP/1.1 404 Not Found"
11
+ 2026-10-12 14:50:23 [INFO] HTTP Request: HEAD https://s3.amazonaws.com/datasets.huggingface.co/datasets/datasets/DKYoon/SlimPajama-6B/DKYoon/SlimPajama-6B.py "HTTP/1.1 404 Not Found"
12
+ 2026-10-12 14:50:23 [INFO] HTTP Request: GET https://huggingface.co/api/datasets/DKYoon/SlimPajama-6B/revision/b5f90f419b7489cdba26fdbc8c022fcb5562f968 "HTTP/1.1 200 OK"
13
+ 2026-10-12 14:50:23 [INFO] HTTP Request: HEAD https://huggingface.co/datasets/DKYoon/SlimPajama-6B/resolve/b5f90f419b7489cdba26fdbc8c022fcb5562f968/.huggingface.yaml "HTTP/1.1 404 Not Found"
14
+ 2026-10-12 14:50:24 [INFO] HTTP Request: GET https://huggingface.co/api/datasets/DKYoon/SlimPajama-6B/tree/b5f90f419b7489cdba26fdbc8c022fcb5562f968/data?recursive=true&expand=false "HTTP/1.1 200 OK"
15
+ 2026-10-12 14:50:24 [INFO] HTTP Request: GET https://huggingface.co/api/datasets/DKYoon/SlimPajama-6B/tree/b5f90f419b7489cdba26fdbc8c022fcb5562f968?recursive=false&expand=false "HTTP/1.1 200 OK"
16
+ 2026-10-12 14:50:24 [INFO] HTTP Request: HEAD https://huggingface.co/datasets/DKYoon/SlimPajama-6B/resolve/b5f90f419b7489cdba26fdbc8c022fcb5562f968/dataset_infos.json "HTTP/1.1 404 Not Found"
17
+
18
+
19
+
20
+ 2026-10-12 15:11:07 [INFO] Skipping evaluation for /workspace/artifacts/qwen3-base-half2-20261012/full/replaceme/model_staged_ReplaceMe_lstsq_1
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/manifest.json ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "sha256-tree-v1",
3
+ "files": [
4
+ {
5
+ "path": "code/abprune_compact.py",
6
+ "size": 12360,
7
+ "sha256": "34f00dc3b96ea3c3dd6dafada682352e2b332e6b1c79fb2033e13f9585254ff3"
8
+ },
9
+ {
10
+ "path": "code/bootstrap_qwen3_base_half2.sh",
11
+ "size": 2462,
12
+ "sha256": "d8a1db6ecee76eb1d0bd77996ae383c28f3e4a7e3cf83c1d30e5f2d5833ca286"
13
+ },
14
+ {
15
+ "path": "code/come.py",
16
+ "size": 24499,
17
+ "sha256": "782e306e43f59e6fc1df28ba346ee57b03004c283376c661233b144f7491d9f8"
18
+ },
19
+ {
20
+ "path": "code/eval_llama31_8b_12bench.py",
21
+ "size": 6694,
22
+ "sha256": "94f6ca3e633f10b5cdef756c1e88e32cdf1615a8f17d078918c0b412a445fb37"
23
+ },
24
+ {
25
+ "path": "code/eval_opencompass_ppl_fast.py",
26
+ "size": 9619,
27
+ "sha256": "e1bf9a9c3e658d3205ec6210c87eb2d07d55f428e6dec055d8160251d4e0ba59"
28
+ },
29
+ {
30
+ "path": "code/evaluate_hchc_wikitext2_ppl.py",
31
+ "size": 5422,
32
+ "sha256": "a1c1c0bf8422ddc70cc5e9c0049830b9aa594742fdeffa110de7b3dcf30c1dd3"
33
+ },
34
+ {
35
+ "path": "code/mka.py",
36
+ "size": 21026,
37
+ "sha256": "ad9ea0af779cf5714e98f6872500f6059c8731635aae425b53d19fbfb7fecd0a"
38
+ },
39
+ {
40
+ "path": "code/mka_transport.py",
41
+ "size": 11149,
42
+ "sha256": "f5b26134798f6fd5d57798fed534889bfc682b1c700a7ab23e2fd7f2382b813e"
43
+ },
44
+ {
45
+ "path": "code/replaceme_llama_instruction_mask_bf16.patch",
46
+ "size": 1885,
47
+ "sha256": "20ec4b19aa1bdb06f0ed6c4023e23758e4cfb5caae57e1cc5d33008692b8e804"
48
+ },
49
+ {
50
+ "path": "code/replaceme_qwen_layer_types.patch",
51
+ "size": 1209,
52
+ "sha256": "b9c2c5e3fab4f41887bd19017026cee370b4a16e27eb942b97de008a44d35094"
53
+ },
54
+ {
55
+ "path": "code/run_come_pruning.py",
56
+ "size": 4432,
57
+ "sha256": "4972ff9bee6185c4cda1f5de673852f983e2c63609729ad17a31e1125ee5de83"
58
+ },
59
+ {
60
+ "path": "code/run_mka_pruning.py",
61
+ "size": 18530,
62
+ "sha256": "efb6f3d8f8f06cf462e3edd7e865375046f24d6411bb4c0f789836b1358d9144"
63
+ },
64
+ {
65
+ "path": "code/run_qwen3_8b_base_replaceme_depth.sh",
66
+ "size": 4200,
67
+ "sha256": "07e63f3c044803ae94ef644354e6926df04ba2d8b8aa7403878aa0a26fb94b44"
68
+ },
69
+ {
70
+ "path": "code/run_qwen3_8b_native_span_transport_additive_u.sh",
71
+ "size": 6258,
72
+ "sha256": "2059e1f14dc6943ac51cfd58305fc1fd9a602d67278e07afadda0e9ececac05b"
73
+ },
74
+ {
75
+ "path": "code/run_qwen3_base_half2.py",
76
+ "size": 16054,
77
+ "sha256": "a2e9df5a7a4c99f896186d90dd6d21b15b301e18d8f56a3fe0c22e4035e9779b"
78
+ },
79
+ {
80
+ "path": "environment.json",
81
+ "size": 305,
82
+ "sha256": "d436d2d3bcb986067bce8932da45b28ec66bc229ac5b910a6592591565e8d609"
83
+ },
84
+ {
85
+ "path": "eval/final_14bench.json",
86
+ "size": 891,
87
+ "sha256": "01e2cb58c06beb1c6a48b82d4f45be511d1bd4050a29e4b5502138552c4f77c2"
88
+ },
89
+ {
90
+ "path": "eval/final_lmeval9.json",
91
+ "size": 42631,
92
+ "sha256": "703ccba34646b2fe1a4de616f4486e53594e2714d78d2e48b8387c04b2e345a3"
93
+ },
94
+ {
95
+ "path": "eval/final_opencompass5.json",
96
+ "size": 1042,
97
+ "sha256": "2c7a47b3af341333596650c5900f1b0c181112d1e1eb050ea34ee7d8d71eabe4"
98
+ },
99
+ {
100
+ "path": "eval/final_ppl.json",
101
+ "size": 533,
102
+ "sha256": "493d630f927365e333fb289c3e1f8834e35e7bae4fa5fa90218fa3b71c113c48"
103
+ },
104
+ {
105
+ "path": "execution.json",
106
+ "size": 754,
107
+ "sha256": "6faf4aa1e9fc64a47fffba0accc233149c5c2a7619dd72639f95954414e3738b"
108
+ },
109
+ {
110
+ "path": "logs/aggregate.log",
111
+ "size": 1178,
112
+ "sha256": "c2b8c041891857d39612ddaaae5860fe2adbe7dc694968e9695ba1662e50ebe4"
113
+ },
114
+ {
115
+ "path": "logs/lmeval.log",
116
+ "size": 180554,
117
+ "sha256": "9161d0e4a2c1186f4ce7ecb4c78688e2e4193d6dc956e6873dd444567fc2050e"
118
+ },
119
+ {
120
+ "path": "logs/opencompass.log",
121
+ "size": 2703,
122
+ "sha256": "fdbb789ceda4a9d35e0a44dd9d7921f83edbde2b6fbcd954e110ee4875431480"
123
+ },
124
+ {
125
+ "path": "logs/ppl.log",
126
+ "size": 1732,
127
+ "sha256": "536cbbc63592bdc22aae799df0ace15e25d116e70bf57444570437b0055bb860"
128
+ },
129
+ {
130
+ "path": "logs/pruning.log",
131
+ "size": 810,
132
+ "sha256": "61ff6f1c257ea78c72bbcc4b02e0d02411d8f3569be04022c45b7f5357a9b847"
133
+ },
134
+ {
135
+ "path": "logs/train.log",
136
+ "size": 95890,
137
+ "sha256": "378d03ded175336b42af853f2d5f80fd287e40dc7dd3547cabb13ea721dde768"
138
+ },
139
+ {
140
+ "path": "model/chat_template.jinja",
141
+ "size": 4116,
142
+ "sha256": "87a2728cb8dc9fe424d624542f6060ec05a1d285ebbec578bb078900e33396b5"
143
+ },
144
+ {
145
+ "path": "model/config.json",
146
+ "size": 1199,
147
+ "sha256": "8cb2efb3502597445802deb8a64fbac611af77bd80730afd29726d344dd23023"
148
+ },
149
+ {
150
+ "path": "model/generation_config.json",
151
+ "size": 139,
152
+ "sha256": "b9c7db969a66eb1b0bdec913124f92ceabaec624630bbced7778b8f3452a2bee"
153
+ },
154
+ {
155
+ "path": "model/model.safetensors",
156
+ "size": 9435422336,
157
+ "sha256": "27fd55d4981905d0dc56c497562a61d733b63d8830f1ddc75982bdd70b31045a"
158
+ },
159
+ {
160
+ "path": "model/tokenizer.json",
161
+ "size": 11422650,
162
+ "sha256": "be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506"
163
+ },
164
+ {
165
+ "path": "model/tokenizer_config.json",
166
+ "size": 696,
167
+ "sha256": "5f007d04324afa93876e2a484190e868136c69dfe0e1a29a1063eae583df9d32"
168
+ },
169
+ {
170
+ "path": "offline_eval.json",
171
+ "size": 365,
172
+ "sha256": "b75809008c1c7a4b1ef8e8c3c6e09d2ea87eebb56c647a3206ef54086cc27cd0"
173
+ },
174
+ {
175
+ "path": "protocol.json",
176
+ "size": 1390,
177
+ "sha256": "867ecbc2b47d851b2312a1a9cfeaa45105fb1386be0fb002cc0d321ed64f2904"
178
+ },
179
+ {
180
+ "path": "protocol.md",
181
+ "size": 6251,
182
+ "sha256": "95cc1031a4b9ec1892cf825908628d03a085052d052483b4042fd92c32b06cb0"
183
+ },
184
+ {
185
+ "path": "selection/COMPLETE",
186
+ "size": 0,
187
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
188
+ },
189
+ {
190
+ "path": "selection/selection.json",
191
+ "size": 37647,
192
+ "sha256": "27e44fdbef1a31ac9b575b072a6969adf23d65c43619235da1a1327fe010abb0"
193
+ },
194
+ {
195
+ "path": "selection/selection.log",
196
+ "size": 26034,
197
+ "sha256": "4fca8c66b83a549f0187a643f7546c23a570c37b99fab1af2ea66c7ff2d193b5"
198
+ },
199
+ {
200
+ "path": "selection/slimpajama500_seed42.pt",
201
+ "size": 4235401,
202
+ "sha256": "0f3a56be04acac5ca8ad09dd10e02280659326af9c065f6c57a86d27e69ff997"
203
+ },
204
+ {
205
+ "path": "selection/summary.json",
206
+ "size": 1572,
207
+ "sha256": "276c2782d23141519ea1bb9676f21ae70a9dff42c50b976612524588c352890d"
208
+ }
209
+ ],
210
+ "total_files": 41,
211
+ "total_bytes": 9451634618
212
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/chat_template.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
+ {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- set reasoning_content = '' %}
31
+ {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
+ {%- set reasoning_content = message.reasoning_content %}
33
+ {%- else %}
34
+ {%- if '</think>' in message.content %}
35
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
+ {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- endif %}
38
+ {%- endif %}
39
+ {%- if loop.index0 > ns.last_query_index %}
40
+ {%- if loop.last or (not loop.last and reasoning_content) %}
41
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
42
+ {%- else %}
43
+ {{- '<|im_start|>' + message.role + '\n' + content }}
44
+ {%- endif %}
45
+ {%- else %}
46
+ {{- '<|im_start|>' + message.role + '\n' + content }}
47
+ {%- endif %}
48
+ {%- if message.tool_calls %}
49
+ {%- for tool_call in message.tool_calls %}
50
+ {%- if (loop.first and content) or (not loop.first) %}
51
+ {{- '\n' }}
52
+ {%- endif %}
53
+ {%- if tool_call.function %}
54
+ {%- set tool_call = tool_call.function %}
55
+ {%- endif %}
56
+ {{- '<tool_call>\n{"name": "' }}
57
+ {{- tool_call.name }}
58
+ {{- '", "arguments": ' }}
59
+ {%- if tool_call.arguments is string %}
60
+ {{- tool_call.arguments }}
61
+ {%- else %}
62
+ {{- tool_call.arguments | tojson }}
63
+ {%- endif %}
64
+ {{- '}\n</tool_call>' }}
65
+ {%- endfor %}
66
+ {%- endif %}
67
+ {{- '<|im_end|>\n' }}
68
+ {%- elif message.role == "tool" %}
69
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
70
+ {{- '<|im_start|>user' }}
71
+ {%- endif %}
72
+ {{- '\n<tool_response>\n' }}
73
+ {{- message.content }}
74
+ {{- '\n</tool_response>' }}
75
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
+ {{- '<|im_end|>\n' }}
77
+ {%- endif %}
78
+ {%- endif %}
79
+ {%- endfor %}
80
+ {%- if add_generation_prompt %}
81
+ {{- '<|im_start|>assistant\n' }}
82
+ {%- if enable_thinking is defined and enable_thinking is false %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/config.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "dtype": "bfloat16",
9
+ "eos_token_id": 151643,
10
+ "head_dim": 128,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 4096,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 12288,
15
+ "layer_types": [
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention"
34
+ ],
35
+ "max_position_embeddings": 32768,
36
+ "max_window_layers": 36,
37
+ "model_type": "qwen3",
38
+ "num_attention_heads": 32,
39
+ "num_hidden_layers": 18,
40
+ "num_key_value_heads": 8,
41
+ "pad_token_id": null,
42
+ "rms_norm_eps": 1e-06,
43
+ "rope_parameters": {
44
+ "rope_theta": 1000000,
45
+ "rope_type": "default"
46
+ },
47
+ "sliding_window": null,
48
+ "tie_word_embeddings": false,
49
+ "transformers_version": "5.15.1",
50
+ "use_cache": true,
51
+ "use_sliding_window": false,
52
+ "vocab_size": 151936
53
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": false,
4
+ "eos_token_id": 151643,
5
+ "max_new_tokens": 2048,
6
+ "transformers_version": "5.15.1"
7
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27fd55d4981905d0dc56c497562a61d733b63d8830f1ddc75982bdd70b31045a
3
+ size 9435422336
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/model/tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|endoftext|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": true,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null
30
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/offline_eval.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "wikitext_cache": "/workspace/artifacts/qwen3-base-half2-20261012/wikitext2_cache",
3
+ "dataset": "Salesforce/wikitext",
4
+ "config": "wikitext-2-raw-v1",
5
+ "splits": {
6
+ "test": 4358,
7
+ "train": 36718,
8
+ "validation": 3760
9
+ },
10
+ "fingerprints": {
11
+ "test": "a46124b21ac53738",
12
+ "train": "5d4fb603254a7a5b",
13
+ "validation": "51d84d52d095f90d"
14
+ }
15
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/protocol.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "method": "ReplaceMe streaming closed-form LSTSQ",
3
+ "model": "Qwen/Qwen3-8B-Base",
4
+ "model_revision": "49e3418fbbbca6ecbdf9608b4d22e5a407081db4",
5
+ "selected_span_source": "SlimPajama-500 original RePlaceMe angular-distance selector",
6
+ "removed_interval": [
7
+ 14,
8
+ 32
9
+ ],
10
+ "removed_original_layers": [
11
+ 14,
12
+ 15,
13
+ 16,
14
+ 17,
15
+ 18,
16
+ 19,
17
+ 20,
18
+ 21,
19
+ 22,
20
+ 23,
21
+ 24,
22
+ 25,
23
+ 26,
24
+ 27,
25
+ 28,
26
+ 29,
27
+ 30,
28
+ 31
29
+ ],
30
+ "left_boundary_layer": 13,
31
+ "calibration": {
32
+ "dataset": "DKYoon/SlimPajama-6B",
33
+ "records": 10000,
34
+ "sequence_length": 1024,
35
+ "batch_size": 8,
36
+ "valid_tokens_only": true,
37
+ "dtype": "bfloat16",
38
+ "seed": 42
39
+ },
40
+ "fit": {
41
+ "solver": "closed_form_lstsq",
42
+ "ridge_alpha": 0.0
43
+ },
44
+ "selection": {
45
+ "method": "replaceme",
46
+ "score_direction": "min",
47
+ "removed_start": 14,
48
+ "removed_end": 31,
49
+ "compare_left": 13,
50
+ "compare_right": 31,
51
+ "selected_score": 0.31078056192398074,
52
+ "inferred_pruned_layers_zero_based": [
53
+ 14,
54
+ 15,
55
+ 16,
56
+ 17,
57
+ 18,
58
+ 19,
59
+ 20,
60
+ 21,
61
+ 22,
62
+ 23,
63
+ 24,
64
+ 25,
65
+ 26,
66
+ 27,
67
+ 28,
68
+ 29,
69
+ 30,
70
+ 31
71
+ ],
72
+ "notes": "Unified span score: compare last-token hidden states of the first and last removed layers.",
73
+ "removed_interval_half_open": [
74
+ 14,
75
+ 32
76
+ ]
77
+ }
78
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/protocol.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Qwen3 Base 50 percent pruning with four methods
2
+
3
+ Prune Qwen3 8B Base from 36 to 18 decoder blocks using native CoMe, corrected local MKA, ReplaceMe and Fisher plus Transport plus FiT ABPrune. GPU0 runs CoMe, MKA and ReplaceMe sequentially, advancing each immediately to WikiText2 PPL and Bench14. GPU1 selects the new 18-block spans, then runs ABPrune and its evaluations independently. This is a full-method comparison, not the earlier no-FiT merge-coefficient ablation.
4
+
5
+ ## Resources and provenance
6
+
7
+ Instance `55563310`, offer `52960990`, machine `101241`, Lithuania: two RTX PRO 6000 Max-Q 96 GB GPUs, reported RAM 515109 MiB, 64 effective CPU cores, 220 GB disk. Listed total USD 2.7277777777777774 per hour with disk; traffic is additional. Offer reliability 0.9986672 and download/upload 2185.1/2158.0 Mbps. Session alias `vast-paper_revision-qwen3-base-half2-55563310-20261012`; branch `codex/vast-paper_revision-qwen3-base-half2-55563310-20261012`.
8
+
9
+ Remote project `/workspace/paper_revision/sessions/vast-paper_revision-qwen3-base-half2-55563310-20261012`, artifacts `/workspace/artifacts/qwen3-base-half2-20261012`, patched ABPrune engine `/workspace/external/qwen3-base-half2`, original selector and ReplaceMe engine in the same prefix with suffix `-legacy`. Source code moves by Git bundle; the server receives no Git hosting credentials. Model `Qwen/Qwen3-8B-Base` is pinned to `49e3418fbbbca6ecbdf9608b4d22e5a407081db4`.
10
+
11
+ Docker image `pytorch/pytorch:2.9.1-cuda12.8-cudnn9-devel`. Bootstrap pins transformers 5.15.1, datasets 3.6.0, Hugging Face Hub 1.33.0 and lm_eval 0.4.12. Exact Python, torch, CUDA and dependency versions are captured in `environment.json`, rather than inferred from the image. BF16 model and evaluation; FP32 transport solve.
12
+
13
+ The ABPrune engine starts from vendor bundle commit `39e59afe09d0124e9bd95cb2ea1b52e84f5202a9`, plus immutable historical source overlay `61734e7b1a77fd279fe1e2584f7a0fdc26c175c2` and existing loader/mask compatibility patches. Native corrected MKA files were imported unchanged from committed branch `leejunyoung8631/rr3`, file-history commit `9c3fcb4d77ce1c91ffe8a36df4d96c0c7d87bf40`. This is the same corrected variant used by prior MKA baseline campaigns, not an exact paper reproduction and not the fixed-span MKA initialization ablation.
14
+
15
+ ## Data and method settings
16
+
17
+ All calibration uses SlimPajama, not SlimOrca. ABPrune and ReplaceMe selectors share 500 packed 1024-token SlimPajama samples, seed42, batch2 and one chunk cache. Compute width18 from the original selection engine; do not extend the old width9 interval manually. Record `fuse_region_cosine` and `replaceme` selections separately. The dataset revision is `b5f90f419b7489cdba26fdbc8c022fcb5562f968`.
18
+
19
+ ABPrune progressively absorbs the selected 18 original blocks into one fixed anchor. Same-anchor contextual parameter Fisher, epsilon0, source feature Transport ON with ridge relative 0.001, additive-U FiT on MLP only. Calibration64 x1024, batch2. Each stage fits524288 tokens, or512 x1024 sequences, batch1, one epoch, LR1e-4, weight decay0, no LoRA/head permutation. Joint loss keeps hidden MSE1, MLP MSE1 and KL0.02. A two-stage smoke uses4 calibration sequences and20 fitting sequences before the full18 stages.
20
+
21
+ CoMe uses its native stagewise angular-last selector and channel coefficients:256 SlimPajama source rows packed into2048-token windows, seed10, batch1, power1, minimum retention0, allow-repeat, no Transport or FiT. MKA uses100 distinct-document SlimPajama windows x512, seed0, sequence mean pooling, current-model NPIB recomputed per stage, sigma8, alpha0.5, diffusion dimensions2, MI neighbors5, entropy neighbors50 and beta1. It merges all seven attention and MLP projections, retains anchor norms and allows repeated merges; no Transport or FiT. Preserve actual lineage in each native checkpoint.
22
+
23
+ ReplaceMe uses its separately selected width18 interval and existing closed-form streaming least squares. SlimPajama10000 records, max length1024, batch8, seed42, BF16, valid-token masks, alpha0 and no4bit. Existing BF16 and Qwen layer-type compatibility patches are unchanged; the runner accepts width18 in addition to earlier5/9/14 widths.
24
+
25
+ ## Evaluation and retention
26
+
27
+ Use full WikiText2 test HCHC packing,2048-token windows, BF16 eager, batch4, expected145 windows and296815 predicted tokens. Bench14 preserves established legacy OpenCompass-five full-prompt choice-label likelihood and lm-eval-nine zero-shot protocols: RACE-H, RACE-M, C3, CMNLI, CHID, PIQA, WinoGrande, HellaSwag, ARC-C, ARC-E, OpenBookQA, SciQ, MMLU and CMMLU. ZS12 excludes MMLU/CMMLU; Bench14 macro is the unweighted14-task mean. This is not the newer answer-sentence-only RACE experiment.
28
+
29
+ Transfer hash-pinned local OpenCompass-five and131-configuration lm_eval dataset archives before evaluation. Warm and export WikiText once during preparation, then run all evaluations with strict offline datasets and local models. Missing caches fail explicitly without online fallback.
30
+
31
+ Controller command: `python scripts/run_qwen3_base_half2.py --project PROJECT --external EXTERNAL --root ROOT --model MODEL --session SESSION`. Bootstrap command: `bash scripts/bootstrap_qwen3_base_half2.sh PROJECT EXTERNAL ROOT MODEL`. Execution commit, exact commands, stage logs, method protocols, selections and metrics are saved by the controller.
32
+
33
+ Save native full checkpoints and the final compact ABPrune anchor with base-model pin. Back up each method with evaluation records, selectors, code and environment to private `LJYAI/paper_revision/runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/METHOD`, verify all file hashes and record immutable revisions. Final results go to `results/qwen3_base_half18_20261012/`, followed by a remote commit and local bundle recovery/push. Do not return this new instance without further user instruction.
34
+
35
+ ## Current status
36
+
37
+ Instance is running, SSH registration and host setup are in progress. No 50 percent result is complete at this checkpoint. Source branch is clean before new task files; no unrelated user changes are overwritten. The writing skill keeps the full-method comparison and the earlier no-FiT ablation distinct in the experiment record.
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/COMPLETE ADDED
File without changes
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/selection.json ADDED
@@ -0,0 +1,2119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "num_hidden_layers": 36,
3
+ "num_batches": 250,
4
+ "num_examples": 500,
5
+ "selections": [
6
+ {
7
+ "method": "llm_streamline",
8
+ "score_direction": "max",
9
+ "removed_start": 15,
10
+ "removed_end": 32,
11
+ "compare_left": 14,
12
+ "compare_right": 32,
13
+ "selected_score": 0.5545816756486893,
14
+ "inferred_pruned_layers_zero_based": [
15
+ 15,
16
+ 16,
17
+ 17,
18
+ 18,
19
+ 19,
20
+ 20,
21
+ 21,
22
+ 22,
23
+ 23,
24
+ 24,
25
+ 25,
26
+ 26,
27
+ 27,
28
+ 28,
29
+ 29,
30
+ 30,
31
+ 31,
32
+ 32
33
+ ],
34
+ "notes": "Unified span score: compare hidden_states[r-1] and hidden_states[r+w-1]."
35
+ },
36
+ {
37
+ "method": "replaceme",
38
+ "score_direction": "min",
39
+ "removed_start": 14,
40
+ "removed_end": 31,
41
+ "compare_left": 13,
42
+ "compare_right": 31,
43
+ "selected_score": 0.31078056192398074,
44
+ "inferred_pruned_layers_zero_based": [
45
+ 14,
46
+ 15,
47
+ 16,
48
+ 17,
49
+ 18,
50
+ 19,
51
+ 20,
52
+ 21,
53
+ 22,
54
+ 23,
55
+ 24,
56
+ 25,
57
+ 26,
58
+ 27,
59
+ 28,
60
+ 29,
61
+ 30,
62
+ 31
63
+ ],
64
+ "notes": "Unified span score: compare last-token hidden states of the first and last removed layers."
65
+ },
66
+ {
67
+ "method": "fuse_region_cosine",
68
+ "score_direction": "min",
69
+ "removed_start": 15,
70
+ "removed_end": 32,
71
+ "compare_left": 14,
72
+ "compare_right": 32,
73
+ "selected_score": 0.44541832387447355,
74
+ "inferred_pruned_layers_zero_based": [
75
+ 15,
76
+ 16,
77
+ 17,
78
+ 18,
79
+ 19,
80
+ 20,
81
+ 21,
82
+ 22,
83
+ 23,
84
+ 24,
85
+ 25,
86
+ 26,
87
+ 27,
88
+ 28,
89
+ 29,
90
+ 30,
91
+ 31,
92
+ 32
93
+ ],
94
+ "notes": "Unified span score: compare hidden_states[r-1] and hidden_states[r+w-1] using token-level 1-cosine."
95
+ },
96
+ {
97
+ "method": "fuse_region_cosine_mlp_pre_residual",
98
+ "score_direction": "min",
99
+ "removed_start": 7,
100
+ "removed_end": 24,
101
+ "compare_left": 6,
102
+ "compare_right": 24,
103
+ "selected_score": 0.8522758095264434,
104
+ "inferred_pruned_layers_zero_based": [
105
+ 7,
106
+ 8,
107
+ 9,
108
+ 10,
109
+ 11,
110
+ 12,
111
+ 13,
112
+ 14,
113
+ 15,
114
+ 16,
115
+ 17,
116
+ 18,
117
+ 19,
118
+ 20,
119
+ 21,
120
+ 22,
121
+ 23,
122
+ 24
123
+ ],
124
+ "notes": "Unified span score: compare pre-residual MLP outputs of the left boundary layer and the last removed layer."
125
+ }
126
+ ],
127
+ "per_start": {
128
+ "llm_streamline": [
129
+ {
130
+ "removed_start": 1,
131
+ "removed_end": 18,
132
+ "compare_left": 0,
133
+ "compare_right": 18,
134
+ "score": 0.4001441835165024,
135
+ "inferred_pruned_layers_zero_based": [
136
+ 1,
137
+ 2,
138
+ 3,
139
+ 4,
140
+ 5,
141
+ 6,
142
+ 7,
143
+ 8,
144
+ 9,
145
+ 10,
146
+ 11,
147
+ 12,
148
+ 13,
149
+ 14,
150
+ 15,
151
+ 16,
152
+ 17,
153
+ 18
154
+ ]
155
+ },
156
+ {
157
+ "removed_start": 2,
158
+ "removed_end": 19,
159
+ "compare_left": 1,
160
+ "compare_right": 19,
161
+ "score": 0.41873254787921904,
162
+ "inferred_pruned_layers_zero_based": [
163
+ 2,
164
+ 3,
165
+ 4,
166
+ 5,
167
+ 6,
168
+ 7,
169
+ 8,
170
+ 9,
171
+ 10,
172
+ 11,
173
+ 12,
174
+ 13,
175
+ 14,
176
+ 15,
177
+ 16,
178
+ 17,
179
+ 18,
180
+ 19
181
+ ]
182
+ },
183
+ {
184
+ "removed_start": 3,
185
+ "removed_end": 20,
186
+ "compare_left": 2,
187
+ "compare_right": 20,
188
+ "score": 0.4322152615785599,
189
+ "inferred_pruned_layers_zero_based": [
190
+ 3,
191
+ 4,
192
+ 5,
193
+ 6,
194
+ 7,
195
+ 8,
196
+ 9,
197
+ 10,
198
+ 11,
199
+ 12,
200
+ 13,
201
+ 14,
202
+ 15,
203
+ 16,
204
+ 17,
205
+ 18,
206
+ 19,
207
+ 20
208
+ ]
209
+ },
210
+ {
211
+ "removed_start": 4,
212
+ "removed_end": 21,
213
+ "compare_left": 3,
214
+ "compare_right": 21,
215
+ "score": 0.458461238026619,
216
+ "inferred_pruned_layers_zero_based": [
217
+ 4,
218
+ 5,
219
+ 6,
220
+ 7,
221
+ 8,
222
+ 9,
223
+ 10,
224
+ 11,
225
+ 12,
226
+ 13,
227
+ 14,
228
+ 15,
229
+ 16,
230
+ 17,
231
+ 18,
232
+ 19,
233
+ 20,
234
+ 21
235
+ ]
236
+ },
237
+ {
238
+ "removed_start": 5,
239
+ "removed_end": 22,
240
+ "compare_left": 4,
241
+ "compare_right": 22,
242
+ "score": 0.49698565900325775,
243
+ "inferred_pruned_layers_zero_based": [
244
+ 5,
245
+ 6,
246
+ 7,
247
+ 8,
248
+ 9,
249
+ 10,
250
+ 11,
251
+ 12,
252
+ 13,
253
+ 14,
254
+ 15,
255
+ 16,
256
+ 17,
257
+ 18,
258
+ 19,
259
+ 20,
260
+ 21,
261
+ 22
262
+ ]
263
+ },
264
+ {
265
+ "removed_start": 6,
266
+ "removed_end": 23,
267
+ "compare_left": 5,
268
+ "compare_right": 23,
269
+ "score": 0.513720078587532,
270
+ "inferred_pruned_layers_zero_based": [
271
+ 6,
272
+ 7,
273
+ 8,
274
+ 9,
275
+ 10,
276
+ 11,
277
+ 12,
278
+ 13,
279
+ 14,
280
+ 15,
281
+ 16,
282
+ 17,
283
+ 18,
284
+ 19,
285
+ 20,
286
+ 21,
287
+ 22,
288
+ 23
289
+ ]
290
+ },
291
+ {
292
+ "removed_start": 7,
293
+ "removed_end": 24,
294
+ "compare_left": 6,
295
+ "compare_right": 24,
296
+ "score": 0.5292018551826477,
297
+ "inferred_pruned_layers_zero_based": [
298
+ 7,
299
+ 8,
300
+ 9,
301
+ 10,
302
+ 11,
303
+ 12,
304
+ 13,
305
+ 14,
306
+ 15,
307
+ 16,
308
+ 17,
309
+ 18,
310
+ 19,
311
+ 20,
312
+ 21,
313
+ 22,
314
+ 23,
315
+ 24
316
+ ]
317
+ },
318
+ {
319
+ "removed_start": 8,
320
+ "removed_end": 25,
321
+ "compare_left": 7,
322
+ "compare_right": 25,
323
+ "score": 0.5275396839380264,
324
+ "inferred_pruned_layers_zero_based": [
325
+ 8,
326
+ 9,
327
+ 10,
328
+ 11,
329
+ 12,
330
+ 13,
331
+ 14,
332
+ 15,
333
+ 16,
334
+ 17,
335
+ 18,
336
+ 19,
337
+ 20,
338
+ 21,
339
+ 22,
340
+ 23,
341
+ 24,
342
+ 25
343
+ ]
344
+ },
345
+ {
346
+ "removed_start": 9,
347
+ "removed_end": 26,
348
+ "compare_left": 8,
349
+ "compare_right": 26,
350
+ "score": 0.51713119494915,
351
+ "inferred_pruned_layers_zero_based": [
352
+ 9,
353
+ 10,
354
+ 11,
355
+ 12,
356
+ 13,
357
+ 14,
358
+ 15,
359
+ 16,
360
+ 17,
361
+ 18,
362
+ 19,
363
+ 20,
364
+ 21,
365
+ 22,
366
+ 23,
367
+ 24,
368
+ 25,
369
+ 26
370
+ ]
371
+ },
372
+ {
373
+ "removed_start": 10,
374
+ "removed_end": 27,
375
+ "compare_left": 9,
376
+ "compare_right": 27,
377
+ "score": 0.5140425094366073,
378
+ "inferred_pruned_layers_zero_based": [
379
+ 10,
380
+ 11,
381
+ 12,
382
+ 13,
383
+ 14,
384
+ 15,
385
+ 16,
386
+ 17,
387
+ 18,
388
+ 19,
389
+ 20,
390
+ 21,
391
+ 22,
392
+ 23,
393
+ 24,
394
+ 25,
395
+ 26,
396
+ 27
397
+ ]
398
+ },
399
+ {
400
+ "removed_start": 11,
401
+ "removed_end": 28,
402
+ "compare_left": 10,
403
+ "compare_right": 28,
404
+ "score": 0.5293747123479843,
405
+ "inferred_pruned_layers_zero_based": [
406
+ 11,
407
+ 12,
408
+ 13,
409
+ 14,
410
+ 15,
411
+ 16,
412
+ 17,
413
+ 18,
414
+ 19,
415
+ 20,
416
+ 21,
417
+ 22,
418
+ 23,
419
+ 24,
420
+ 25,
421
+ 26,
422
+ 27,
423
+ 28
424
+ ]
425
+ },
426
+ {
427
+ "removed_start": 12,
428
+ "removed_end": 29,
429
+ "compare_left": 11,
430
+ "compare_right": 29,
431
+ "score": 0.5324888409376144,
432
+ "inferred_pruned_layers_zero_based": [
433
+ 12,
434
+ 13,
435
+ 14,
436
+ 15,
437
+ 16,
438
+ 17,
439
+ 18,
440
+ 19,
441
+ 20,
442
+ 21,
443
+ 22,
444
+ 23,
445
+ 24,
446
+ 25,
447
+ 26,
448
+ 27,
449
+ 28,
450
+ 29
451
+ ]
452
+ },
453
+ {
454
+ "removed_start": 13,
455
+ "removed_end": 30,
456
+ "compare_left": 12,
457
+ "compare_right": 30,
458
+ "score": 0.552883662700653,
459
+ "inferred_pruned_layers_zero_based": [
460
+ 13,
461
+ 14,
462
+ 15,
463
+ 16,
464
+ 17,
465
+ 18,
466
+ 19,
467
+ 20,
468
+ 21,
469
+ 22,
470
+ 23,
471
+ 24,
472
+ 25,
473
+ 26,
474
+ 27,
475
+ 28,
476
+ 29,
477
+ 30
478
+ ]
479
+ },
480
+ {
481
+ "removed_start": 14,
482
+ "removed_end": 31,
483
+ "compare_left": 13,
484
+ "compare_right": 31,
485
+ "score": 0.5463030400276184,
486
+ "inferred_pruned_layers_zero_based": [
487
+ 14,
488
+ 15,
489
+ 16,
490
+ 17,
491
+ 18,
492
+ 19,
493
+ 20,
494
+ 21,
495
+ 22,
496
+ 23,
497
+ 24,
498
+ 25,
499
+ 26,
500
+ 27,
501
+ 28,
502
+ 29,
503
+ 30,
504
+ 31
505
+ ]
506
+ },
507
+ {
508
+ "removed_start": 15,
509
+ "removed_end": 32,
510
+ "compare_left": 14,
511
+ "compare_right": 32,
512
+ "score": 0.5545816756486893,
513
+ "inferred_pruned_layers_zero_based": [
514
+ 15,
515
+ 16,
516
+ 17,
517
+ 18,
518
+ 19,
519
+ 20,
520
+ 21,
521
+ 22,
522
+ 23,
523
+ 24,
524
+ 25,
525
+ 26,
526
+ 27,
527
+ 28,
528
+ 29,
529
+ 30,
530
+ 31,
531
+ 32
532
+ ]
533
+ },
534
+ {
535
+ "removed_start": 16,
536
+ "removed_end": 33,
537
+ "compare_left": 15,
538
+ "compare_right": 33,
539
+ "score": 0.5435223225355148,
540
+ "inferred_pruned_layers_zero_based": [
541
+ 16,
542
+ 17,
543
+ 18,
544
+ 19,
545
+ 20,
546
+ 21,
547
+ 22,
548
+ 23,
549
+ 24,
550
+ 25,
551
+ 26,
552
+ 27,
553
+ 28,
554
+ 29,
555
+ 30,
556
+ 31,
557
+ 32,
558
+ 33
559
+ ]
560
+ },
561
+ {
562
+ "removed_start": 17,
563
+ "removed_end": 34,
564
+ "compare_left": 16,
565
+ "compare_right": 34,
566
+ "score": 0.5471235717535019,
567
+ "inferred_pruned_layers_zero_based": [
568
+ 17,
569
+ 18,
570
+ 19,
571
+ 20,
572
+ 21,
573
+ 22,
574
+ 23,
575
+ 24,
576
+ 25,
577
+ 26,
578
+ 27,
579
+ 28,
580
+ 29,
581
+ 30,
582
+ 31,
583
+ 32,
584
+ 33,
585
+ 34
586
+ ]
587
+ },
588
+ {
589
+ "removed_start": 18,
590
+ "removed_end": 35,
591
+ "compare_left": 17,
592
+ "compare_right": 35,
593
+ "score": 0.5483626971244812,
594
+ "inferred_pruned_layers_zero_based": [
595
+ 18,
596
+ 19,
597
+ 20,
598
+ 21,
599
+ 22,
600
+ 23,
601
+ 24,
602
+ 25,
603
+ 26,
604
+ 27,
605
+ 28,
606
+ 29,
607
+ 30,
608
+ 31,
609
+ 32,
610
+ 33,
611
+ 34,
612
+ 35
613
+ ]
614
+ }
615
+ ],
616
+ "replaceme": [
617
+ {
618
+ "removed_start": 1,
619
+ "removed_end": 18,
620
+ "compare_left": 0,
621
+ "compare_right": 18,
622
+ "score": 0.3623302321434021,
623
+ "inferred_pruned_layers_zero_based": [
624
+ 1,
625
+ 2,
626
+ 3,
627
+ 4,
628
+ 5,
629
+ 6,
630
+ 7,
631
+ 8,
632
+ 9,
633
+ 10,
634
+ 11,
635
+ 12,
636
+ 13,
637
+ 14,
638
+ 15,
639
+ 16,
640
+ 17,
641
+ 18
642
+ ]
643
+ },
644
+ {
645
+ "removed_start": 2,
646
+ "removed_end": 19,
647
+ "compare_left": 1,
648
+ "compare_right": 19,
649
+ "score": 0.3579166704416275,
650
+ "inferred_pruned_layers_zero_based": [
651
+ 2,
652
+ 3,
653
+ 4,
654
+ 5,
655
+ 6,
656
+ 7,
657
+ 8,
658
+ 9,
659
+ 10,
660
+ 11,
661
+ 12,
662
+ 13,
663
+ 14,
664
+ 15,
665
+ 16,
666
+ 17,
667
+ 18,
668
+ 19
669
+ ]
670
+ },
671
+ {
672
+ "removed_start": 3,
673
+ "removed_end": 20,
674
+ "compare_left": 2,
675
+ "compare_right": 20,
676
+ "score": 0.3477127702236176,
677
+ "inferred_pruned_layers_zero_based": [
678
+ 3,
679
+ 4,
680
+ 5,
681
+ 6,
682
+ 7,
683
+ 8,
684
+ 9,
685
+ 10,
686
+ 11,
687
+ 12,
688
+ 13,
689
+ 14,
690
+ 15,
691
+ 16,
692
+ 17,
693
+ 18,
694
+ 19,
695
+ 20
696
+ ]
697
+ },
698
+ {
699
+ "removed_start": 4,
700
+ "removed_end": 21,
701
+ "compare_left": 3,
702
+ "compare_right": 21,
703
+ "score": 0.33255866980552673,
704
+ "inferred_pruned_layers_zero_based": [
705
+ 4,
706
+ 5,
707
+ 6,
708
+ 7,
709
+ 8,
710
+ 9,
711
+ 10,
712
+ 11,
713
+ 12,
714
+ 13,
715
+ 14,
716
+ 15,
717
+ 16,
718
+ 17,
719
+ 18,
720
+ 19,
721
+ 20,
722
+ 21
723
+ ]
724
+ },
725
+ {
726
+ "removed_start": 5,
727
+ "removed_end": 22,
728
+ "compare_left": 4,
729
+ "compare_right": 22,
730
+ "score": 0.32646954023838043,
731
+ "inferred_pruned_layers_zero_based": [
732
+ 5,
733
+ 6,
734
+ 7,
735
+ 8,
736
+ 9,
737
+ 10,
738
+ 11,
739
+ 12,
740
+ 13,
741
+ 14,
742
+ 15,
743
+ 16,
744
+ 17,
745
+ 18,
746
+ 19,
747
+ 20,
748
+ 21,
749
+ 22
750
+ ]
751
+ },
752
+ {
753
+ "removed_start": 6,
754
+ "removed_end": 23,
755
+ "compare_left": 5,
756
+ "compare_right": 23,
757
+ "score": 0.3202547243833542,
758
+ "inferred_pruned_layers_zero_based": [
759
+ 6,
760
+ 7,
761
+ 8,
762
+ 9,
763
+ 10,
764
+ 11,
765
+ 12,
766
+ 13,
767
+ 14,
768
+ 15,
769
+ 16,
770
+ 17,
771
+ 18,
772
+ 19,
773
+ 20,
774
+ 21,
775
+ 22,
776
+ 23
777
+ ]
778
+ },
779
+ {
780
+ "removed_start": 7,
781
+ "removed_end": 24,
782
+ "compare_left": 6,
783
+ "compare_right": 24,
784
+ "score": 0.32113656747341157,
785
+ "inferred_pruned_layers_zero_based": [
786
+ 7,
787
+ 8,
788
+ 9,
789
+ 10,
790
+ 11,
791
+ 12,
792
+ 13,
793
+ 14,
794
+ 15,
795
+ 16,
796
+ 17,
797
+ 18,
798
+ 19,
799
+ 20,
800
+ 21,
801
+ 22,
802
+ 23,
803
+ 24
804
+ ]
805
+ },
806
+ {
807
+ "removed_start": 8,
808
+ "removed_end": 25,
809
+ "compare_left": 7,
810
+ "compare_right": 25,
811
+ "score": 0.32462449729442594,
812
+ "inferred_pruned_layers_zero_based": [
813
+ 8,
814
+ 9,
815
+ 10,
816
+ 11,
817
+ 12,
818
+ 13,
819
+ 14,
820
+ 15,
821
+ 16,
822
+ 17,
823
+ 18,
824
+ 19,
825
+ 20,
826
+ 21,
827
+ 22,
828
+ 23,
829
+ 24,
830
+ 25
831
+ ]
832
+ },
833
+ {
834
+ "removed_start": 9,
835
+ "removed_end": 26,
836
+ "compare_left": 8,
837
+ "compare_right": 26,
838
+ "score": 0.3259439049959183,
839
+ "inferred_pruned_layers_zero_based": [
840
+ 9,
841
+ 10,
842
+ 11,
843
+ 12,
844
+ 13,
845
+ 14,
846
+ 15,
847
+ 16,
848
+ 17,
849
+ 18,
850
+ 19,
851
+ 20,
852
+ 21,
853
+ 22,
854
+ 23,
855
+ 24,
856
+ 25,
857
+ 26
858
+ ]
859
+ },
860
+ {
861
+ "removed_start": 10,
862
+ "removed_end": 27,
863
+ "compare_left": 9,
864
+ "compare_right": 27,
865
+ "score": 0.3204443471431732,
866
+ "inferred_pruned_layers_zero_based": [
867
+ 10,
868
+ 11,
869
+ 12,
870
+ 13,
871
+ 14,
872
+ 15,
873
+ 16,
874
+ 17,
875
+ 18,
876
+ 19,
877
+ 20,
878
+ 21,
879
+ 22,
880
+ 23,
881
+ 24,
882
+ 25,
883
+ 26,
884
+ 27
885
+ ]
886
+ },
887
+ {
888
+ "removed_start": 11,
889
+ "removed_end": 28,
890
+ "compare_left": 10,
891
+ "compare_right": 28,
892
+ "score": 0.31944401013851165,
893
+ "inferred_pruned_layers_zero_based": [
894
+ 11,
895
+ 12,
896
+ 13,
897
+ 14,
898
+ 15,
899
+ 16,
900
+ 17,
901
+ 18,
902
+ 19,
903
+ 20,
904
+ 21,
905
+ 22,
906
+ 23,
907
+ 24,
908
+ 25,
909
+ 26,
910
+ 27,
911
+ 28
912
+ ]
913
+ },
914
+ {
915
+ "removed_start": 12,
916
+ "removed_end": 29,
917
+ "compare_left": 11,
918
+ "compare_right": 29,
919
+ "score": 0.3113690857887268,
920
+ "inferred_pruned_layers_zero_based": [
921
+ 12,
922
+ 13,
923
+ 14,
924
+ 15,
925
+ 16,
926
+ 17,
927
+ 18,
928
+ 19,
929
+ 20,
930
+ 21,
931
+ 22,
932
+ 23,
933
+ 24,
934
+ 25,
935
+ 26,
936
+ 27,
937
+ 28,
938
+ 29
939
+ ]
940
+ },
941
+ {
942
+ "removed_start": 13,
943
+ "removed_end": 30,
944
+ "compare_left": 12,
945
+ "compare_right": 30,
946
+ "score": 0.3139335271120071,
947
+ "inferred_pruned_layers_zero_based": [
948
+ 13,
949
+ 14,
950
+ 15,
951
+ 16,
952
+ 17,
953
+ 18,
954
+ 19,
955
+ 20,
956
+ 21,
957
+ 22,
958
+ 23,
959
+ 24,
960
+ 25,
961
+ 26,
962
+ 27,
963
+ 28,
964
+ 29,
965
+ 30
966
+ ]
967
+ },
968
+ {
969
+ "removed_start": 14,
970
+ "removed_end": 31,
971
+ "compare_left": 13,
972
+ "compare_right": 31,
973
+ "score": 0.31078056192398074,
974
+ "inferred_pruned_layers_zero_based": [
975
+ 14,
976
+ 15,
977
+ 16,
978
+ 17,
979
+ 18,
980
+ 19,
981
+ 20,
982
+ 21,
983
+ 22,
984
+ 23,
985
+ 24,
986
+ 25,
987
+ 26,
988
+ 27,
989
+ 28,
990
+ 29,
991
+ 30,
992
+ 31
993
+ ]
994
+ },
995
+ {
996
+ "removed_start": 15,
997
+ "removed_end": 32,
998
+ "compare_left": 14,
999
+ "compare_right": 32,
1000
+ "score": 0.315525742650032,
1001
+ "inferred_pruned_layers_zero_based": [
1002
+ 15,
1003
+ 16,
1004
+ 17,
1005
+ 18,
1006
+ 19,
1007
+ 20,
1008
+ 21,
1009
+ 22,
1010
+ 23,
1011
+ 24,
1012
+ 25,
1013
+ 26,
1014
+ 27,
1015
+ 28,
1016
+ 29,
1017
+ 30,
1018
+ 31,
1019
+ 32
1020
+ ]
1021
+ },
1022
+ {
1023
+ "removed_start": 16,
1024
+ "removed_end": 33,
1025
+ "compare_left": 15,
1026
+ "compare_right": 33,
1027
+ "score": 0.31517581713199616,
1028
+ "inferred_pruned_layers_zero_based": [
1029
+ 16,
1030
+ 17,
1031
+ 18,
1032
+ 19,
1033
+ 20,
1034
+ 21,
1035
+ 22,
1036
+ 23,
1037
+ 24,
1038
+ 25,
1039
+ 26,
1040
+ 27,
1041
+ 28,
1042
+ 29,
1043
+ 30,
1044
+ 31,
1045
+ 32,
1046
+ 33
1047
+ ]
1048
+ },
1049
+ {
1050
+ "removed_start": 17,
1051
+ "removed_end": 34,
1052
+ "compare_left": 16,
1053
+ "compare_right": 34,
1054
+ "score": 0.3145262675285339,
1055
+ "inferred_pruned_layers_zero_based": [
1056
+ 17,
1057
+ 18,
1058
+ 19,
1059
+ 20,
1060
+ 21,
1061
+ 22,
1062
+ 23,
1063
+ 24,
1064
+ 25,
1065
+ 26,
1066
+ 27,
1067
+ 28,
1068
+ 29,
1069
+ 30,
1070
+ 31,
1071
+ 32,
1072
+ 33,
1073
+ 34
1074
+ ]
1075
+ },
1076
+ {
1077
+ "removed_start": 18,
1078
+ "removed_end": 35,
1079
+ "compare_left": 17,
1080
+ "compare_right": 35,
1081
+ "score": 0.49567853558063507,
1082
+ "inferred_pruned_layers_zero_based": [
1083
+ 18,
1084
+ 19,
1085
+ 20,
1086
+ 21,
1087
+ 22,
1088
+ 23,
1089
+ 24,
1090
+ 25,
1091
+ 26,
1092
+ 27,
1093
+ 28,
1094
+ 29,
1095
+ 30,
1096
+ 31,
1097
+ 32,
1098
+ 33,
1099
+ 34,
1100
+ 35
1101
+ ]
1102
+ }
1103
+ ],
1104
+ "fuse_region_cosine": [
1105
+ {
1106
+ "removed_start": 1,
1107
+ "removed_end": 18,
1108
+ "compare_left": 0,
1109
+ "compare_right": 18,
1110
+ "score": 0.5998558185100555,
1111
+ "inferred_pruned_layers_zero_based": [
1112
+ 1,
1113
+ 2,
1114
+ 3,
1115
+ 4,
1116
+ 5,
1117
+ 6,
1118
+ 7,
1119
+ 8,
1120
+ 9,
1121
+ 10,
1122
+ 11,
1123
+ 12,
1124
+ 13,
1125
+ 14,
1126
+ 15,
1127
+ 16,
1128
+ 17,
1129
+ 18
1130
+ ]
1131
+ },
1132
+ {
1133
+ "removed_start": 2,
1134
+ "removed_end": 19,
1135
+ "compare_left": 1,
1136
+ "compare_right": 19,
1137
+ "score": 0.5812674527168273,
1138
+ "inferred_pruned_layers_zero_based": [
1139
+ 2,
1140
+ 3,
1141
+ 4,
1142
+ 5,
1143
+ 6,
1144
+ 7,
1145
+ 8,
1146
+ 9,
1147
+ 10,
1148
+ 11,
1149
+ 12,
1150
+ 13,
1151
+ 14,
1152
+ 15,
1153
+ 16,
1154
+ 17,
1155
+ 18,
1156
+ 19
1157
+ ]
1158
+ },
1159
+ {
1160
+ "removed_start": 3,
1161
+ "removed_end": 20,
1162
+ "compare_left": 2,
1163
+ "compare_right": 20,
1164
+ "score": 0.5677847363948823,
1165
+ "inferred_pruned_layers_zero_based": [
1166
+ 3,
1167
+ 4,
1168
+ 5,
1169
+ 6,
1170
+ 7,
1171
+ 8,
1172
+ 9,
1173
+ 10,
1174
+ 11,
1175
+ 12,
1176
+ 13,
1177
+ 14,
1178
+ 15,
1179
+ 16,
1180
+ 17,
1181
+ 18,
1182
+ 19,
1183
+ 20
1184
+ ]
1185
+ },
1186
+ {
1187
+ "removed_start": 4,
1188
+ "removed_end": 21,
1189
+ "compare_left": 3,
1190
+ "compare_right": 21,
1191
+ "score": 0.541538762331009,
1192
+ "inferred_pruned_layers_zero_based": [
1193
+ 4,
1194
+ 5,
1195
+ 6,
1196
+ 7,
1197
+ 8,
1198
+ 9,
1199
+ 10,
1200
+ 11,
1201
+ 12,
1202
+ 13,
1203
+ 14,
1204
+ 15,
1205
+ 16,
1206
+ 17,
1207
+ 18,
1208
+ 19,
1209
+ 20,
1210
+ 21
1211
+ ]
1212
+ },
1213
+ {
1214
+ "removed_start": 5,
1215
+ "removed_end": 22,
1216
+ "compare_left": 4,
1217
+ "compare_right": 22,
1218
+ "score": 0.5030143401622772,
1219
+ "inferred_pruned_layers_zero_based": [
1220
+ 5,
1221
+ 6,
1222
+ 7,
1223
+ 8,
1224
+ 9,
1225
+ 10,
1226
+ 11,
1227
+ 12,
1228
+ 13,
1229
+ 14,
1230
+ 15,
1231
+ 16,
1232
+ 17,
1233
+ 18,
1234
+ 19,
1235
+ 20,
1236
+ 21,
1237
+ 22
1238
+ ]
1239
+ },
1240
+ {
1241
+ "removed_start": 6,
1242
+ "removed_end": 23,
1243
+ "compare_left": 5,
1244
+ "compare_right": 23,
1245
+ "score": 0.486279922246933,
1246
+ "inferred_pruned_layers_zero_based": [
1247
+ 6,
1248
+ 7,
1249
+ 8,
1250
+ 9,
1251
+ 10,
1252
+ 11,
1253
+ 12,
1254
+ 13,
1255
+ 14,
1256
+ 15,
1257
+ 16,
1258
+ 17,
1259
+ 18,
1260
+ 19,
1261
+ 20,
1262
+ 21,
1263
+ 22,
1264
+ 23
1265
+ ]
1266
+ },
1267
+ {
1268
+ "removed_start": 7,
1269
+ "removed_end": 24,
1270
+ "compare_left": 6,
1271
+ "compare_right": 24,
1272
+ "score": 0.4707981493473053,
1273
+ "inferred_pruned_layers_zero_based": [
1274
+ 7,
1275
+ 8,
1276
+ 9,
1277
+ 10,
1278
+ 11,
1279
+ 12,
1280
+ 13,
1281
+ 14,
1282
+ 15,
1283
+ 16,
1284
+ 17,
1285
+ 18,
1286
+ 19,
1287
+ 20,
1288
+ 21,
1289
+ 22,
1290
+ 23,
1291
+ 24
1292
+ ]
1293
+ },
1294
+ {
1295
+ "removed_start": 8,
1296
+ "removed_end": 25,
1297
+ "compare_left": 7,
1298
+ "compare_right": 25,
1299
+ "score": 0.4724603159427643,
1300
+ "inferred_pruned_layers_zero_based": [
1301
+ 8,
1302
+ 9,
1303
+ 10,
1304
+ 11,
1305
+ 12,
1306
+ 13,
1307
+ 14,
1308
+ 15,
1309
+ 16,
1310
+ 17,
1311
+ 18,
1312
+ 19,
1313
+ 20,
1314
+ 21,
1315
+ 22,
1316
+ 23,
1317
+ 24,
1318
+ 25
1319
+ ]
1320
+ },
1321
+ {
1322
+ "removed_start": 9,
1323
+ "removed_end": 26,
1324
+ "compare_left": 8,
1325
+ "compare_right": 26,
1326
+ "score": 0.48286880588531494,
1327
+ "inferred_pruned_layers_zero_based": [
1328
+ 9,
1329
+ 10,
1330
+ 11,
1331
+ 12,
1332
+ 13,
1333
+ 14,
1334
+ 15,
1335
+ 16,
1336
+ 17,
1337
+ 18,
1338
+ 19,
1339
+ 20,
1340
+ 21,
1341
+ 22,
1342
+ 23,
1343
+ 24,
1344
+ 25,
1345
+ 26
1346
+ ]
1347
+ },
1348
+ {
1349
+ "removed_start": 10,
1350
+ "removed_end": 27,
1351
+ "compare_left": 9,
1352
+ "compare_right": 27,
1353
+ "score": 0.48595749270915983,
1354
+ "inferred_pruned_layers_zero_based": [
1355
+ 10,
1356
+ 11,
1357
+ 12,
1358
+ 13,
1359
+ 14,
1360
+ 15,
1361
+ 16,
1362
+ 17,
1363
+ 18,
1364
+ 19,
1365
+ 20,
1366
+ 21,
1367
+ 22,
1368
+ 23,
1369
+ 24,
1370
+ 25,
1371
+ 26,
1372
+ 27
1373
+ ]
1374
+ },
1375
+ {
1376
+ "removed_start": 11,
1377
+ "removed_end": 28,
1378
+ "compare_left": 10,
1379
+ "compare_right": 28,
1380
+ "score": 0.47062529051303864,
1381
+ "inferred_pruned_layers_zero_based": [
1382
+ 11,
1383
+ 12,
1384
+ 13,
1385
+ 14,
1386
+ 15,
1387
+ 16,
1388
+ 17,
1389
+ 18,
1390
+ 19,
1391
+ 20,
1392
+ 21,
1393
+ 22,
1394
+ 23,
1395
+ 24,
1396
+ 25,
1397
+ 26,
1398
+ 27,
1399
+ 28
1400
+ ]
1401
+ },
1402
+ {
1403
+ "removed_start": 12,
1404
+ "removed_end": 29,
1405
+ "compare_left": 11,
1406
+ "compare_right": 29,
1407
+ "score": 0.46751115810871124,
1408
+ "inferred_pruned_layers_zero_based": [
1409
+ 12,
1410
+ 13,
1411
+ 14,
1412
+ 15,
1413
+ 16,
1414
+ 17,
1415
+ 18,
1416
+ 19,
1417
+ 20,
1418
+ 21,
1419
+ 22,
1420
+ 23,
1421
+ 24,
1422
+ 25,
1423
+ 26,
1424
+ 27,
1425
+ 28,
1426
+ 29
1427
+ ]
1428
+ },
1429
+ {
1430
+ "removed_start": 13,
1431
+ "removed_end": 30,
1432
+ "compare_left": 12,
1433
+ "compare_right": 30,
1434
+ "score": 0.4471163386106491,
1435
+ "inferred_pruned_layers_zero_based": [
1436
+ 13,
1437
+ 14,
1438
+ 15,
1439
+ 16,
1440
+ 17,
1441
+ 18,
1442
+ 19,
1443
+ 20,
1444
+ 21,
1445
+ 22,
1446
+ 23,
1447
+ 24,
1448
+ 25,
1449
+ 26,
1450
+ 27,
1451
+ 28,
1452
+ 29,
1453
+ 30
1454
+ ]
1455
+ },
1456
+ {
1457
+ "removed_start": 14,
1458
+ "removed_end": 31,
1459
+ "compare_left": 13,
1460
+ "compare_right": 31,
1461
+ "score": 0.453696959733963,
1462
+ "inferred_pruned_layers_zero_based": [
1463
+ 14,
1464
+ 15,
1465
+ 16,
1466
+ 17,
1467
+ 18,
1468
+ 19,
1469
+ 20,
1470
+ 21,
1471
+ 22,
1472
+ 23,
1473
+ 24,
1474
+ 25,
1475
+ 26,
1476
+ 27,
1477
+ 28,
1478
+ 29,
1479
+ 30,
1480
+ 31
1481
+ ]
1482
+ },
1483
+ {
1484
+ "removed_start": 15,
1485
+ "removed_end": 32,
1486
+ "compare_left": 14,
1487
+ "compare_right": 32,
1488
+ "score": 0.44541832387447355,
1489
+ "inferred_pruned_layers_zero_based": [
1490
+ 15,
1491
+ 16,
1492
+ 17,
1493
+ 18,
1494
+ 19,
1495
+ 20,
1496
+ 21,
1497
+ 22,
1498
+ 23,
1499
+ 24,
1500
+ 25,
1501
+ 26,
1502
+ 27,
1503
+ 28,
1504
+ 29,
1505
+ 30,
1506
+ 31,
1507
+ 32
1508
+ ]
1509
+ },
1510
+ {
1511
+ "removed_start": 16,
1512
+ "removed_end": 33,
1513
+ "compare_left": 15,
1514
+ "compare_right": 33,
1515
+ "score": 0.4564776759147644,
1516
+ "inferred_pruned_layers_zero_based": [
1517
+ 16,
1518
+ 17,
1519
+ 18,
1520
+ 19,
1521
+ 20,
1522
+ 21,
1523
+ 22,
1524
+ 23,
1525
+ 24,
1526
+ 25,
1527
+ 26,
1528
+ 27,
1529
+ 28,
1530
+ 29,
1531
+ 30,
1532
+ 31,
1533
+ 32,
1534
+ 33
1535
+ ]
1536
+ },
1537
+ {
1538
+ "removed_start": 17,
1539
+ "removed_end": 34,
1540
+ "compare_left": 16,
1541
+ "compare_right": 34,
1542
+ "score": 0.45287642765045166,
1543
+ "inferred_pruned_layers_zero_based": [
1544
+ 17,
1545
+ 18,
1546
+ 19,
1547
+ 20,
1548
+ 21,
1549
+ 22,
1550
+ 23,
1551
+ 24,
1552
+ 25,
1553
+ 26,
1554
+ 27,
1555
+ 28,
1556
+ 29,
1557
+ 30,
1558
+ 31,
1559
+ 32,
1560
+ 33,
1561
+ 34
1562
+ ]
1563
+ },
1564
+ {
1565
+ "removed_start": 18,
1566
+ "removed_end": 35,
1567
+ "compare_left": 17,
1568
+ "compare_right": 35,
1569
+ "score": 0.4516373028755188,
1570
+ "inferred_pruned_layers_zero_based": [
1571
+ 18,
1572
+ 19,
1573
+ 20,
1574
+ 21,
1575
+ 22,
1576
+ 23,
1577
+ 24,
1578
+ 25,
1579
+ 26,
1580
+ 27,
1581
+ 28,
1582
+ 29,
1583
+ 30,
1584
+ 31,
1585
+ 32,
1586
+ 33,
1587
+ 34,
1588
+ 35
1589
+ ]
1590
+ }
1591
+ ],
1592
+ "fuse_region_cosine_mlp_pre_residual": [
1593
+ {
1594
+ "removed_start": 1,
1595
+ "removed_end": 18,
1596
+ "compare_left": 0,
1597
+ "compare_right": 18,
1598
+ "score": 0.998951346874237,
1599
+ "inferred_pruned_layers_zero_based": [
1600
+ 1,
1601
+ 2,
1602
+ 3,
1603
+ 4,
1604
+ 5,
1605
+ 6,
1606
+ 7,
1607
+ 8,
1608
+ 9,
1609
+ 10,
1610
+ 11,
1611
+ 12,
1612
+ 13,
1613
+ 14,
1614
+ 15,
1615
+ 16,
1616
+ 17,
1617
+ 18
1618
+ ]
1619
+ },
1620
+ {
1621
+ "removed_start": 2,
1622
+ "removed_end": 19,
1623
+ "compare_left": 1,
1624
+ "compare_right": 19,
1625
+ "score": 0.9171930348873139,
1626
+ "inferred_pruned_layers_zero_based": [
1627
+ 2,
1628
+ 3,
1629
+ 4,
1630
+ 5,
1631
+ 6,
1632
+ 7,
1633
+ 8,
1634
+ 9,
1635
+ 10,
1636
+ 11,
1637
+ 12,
1638
+ 13,
1639
+ 14,
1640
+ 15,
1641
+ 16,
1642
+ 17,
1643
+ 18,
1644
+ 19
1645
+ ]
1646
+ },
1647
+ {
1648
+ "removed_start": 3,
1649
+ "removed_end": 20,
1650
+ "compare_left": 2,
1651
+ "compare_right": 20,
1652
+ "score": 0.968644463300705,
1653
+ "inferred_pruned_layers_zero_based": [
1654
+ 3,
1655
+ 4,
1656
+ 5,
1657
+ 6,
1658
+ 7,
1659
+ 8,
1660
+ 9,
1661
+ 10,
1662
+ 11,
1663
+ 12,
1664
+ 13,
1665
+ 14,
1666
+ 15,
1667
+ 16,
1668
+ 17,
1669
+ 18,
1670
+ 19,
1671
+ 20
1672
+ ]
1673
+ },
1674
+ {
1675
+ "removed_start": 4,
1676
+ "removed_end": 21,
1677
+ "compare_left": 3,
1678
+ "compare_right": 21,
1679
+ "score": 0.9799396152496338,
1680
+ "inferred_pruned_layers_zero_based": [
1681
+ 4,
1682
+ 5,
1683
+ 6,
1684
+ 7,
1685
+ 8,
1686
+ 9,
1687
+ 10,
1688
+ 11,
1689
+ 12,
1690
+ 13,
1691
+ 14,
1692
+ 15,
1693
+ 16,
1694
+ 17,
1695
+ 18,
1696
+ 19,
1697
+ 20,
1698
+ 21
1699
+ ]
1700
+ },
1701
+ {
1702
+ "removed_start": 5,
1703
+ "removed_end": 22,
1704
+ "compare_left": 4,
1705
+ "compare_right": 22,
1706
+ "score": 0.9321213603019715,
1707
+ "inferred_pruned_layers_zero_based": [
1708
+ 5,
1709
+ 6,
1710
+ 7,
1711
+ 8,
1712
+ 9,
1713
+ 10,
1714
+ 11,
1715
+ 12,
1716
+ 13,
1717
+ 14,
1718
+ 15,
1719
+ 16,
1720
+ 17,
1721
+ 18,
1722
+ 19,
1723
+ 20,
1724
+ 21,
1725
+ 22
1726
+ ]
1727
+ },
1728
+ {
1729
+ "removed_start": 6,
1730
+ "removed_end": 23,
1731
+ "compare_left": 5,
1732
+ "compare_right": 23,
1733
+ "score": 0.8878195629119873,
1734
+ "inferred_pruned_layers_zero_based": [
1735
+ 6,
1736
+ 7,
1737
+ 8,
1738
+ 9,
1739
+ 10,
1740
+ 11,
1741
+ 12,
1742
+ 13,
1743
+ 14,
1744
+ 15,
1745
+ 16,
1746
+ 17,
1747
+ 18,
1748
+ 19,
1749
+ 20,
1750
+ 21,
1751
+ 22,
1752
+ 23
1753
+ ]
1754
+ },
1755
+ {
1756
+ "removed_start": 7,
1757
+ "removed_end": 24,
1758
+ "compare_left": 6,
1759
+ "compare_right": 24,
1760
+ "score": 0.8522758095264434,
1761
+ "inferred_pruned_layers_zero_based": [
1762
+ 7,
1763
+ 8,
1764
+ 9,
1765
+ 10,
1766
+ 11,
1767
+ 12,
1768
+ 13,
1769
+ 14,
1770
+ 15,
1771
+ 16,
1772
+ 17,
1773
+ 18,
1774
+ 19,
1775
+ 20,
1776
+ 21,
1777
+ 22,
1778
+ 23,
1779
+ 24
1780
+ ]
1781
+ },
1782
+ {
1783
+ "removed_start": 8,
1784
+ "removed_end": 25,
1785
+ "compare_left": 7,
1786
+ "compare_right": 25,
1787
+ "score": 0.967814395904541,
1788
+ "inferred_pruned_layers_zero_based": [
1789
+ 8,
1790
+ 9,
1791
+ 10,
1792
+ 11,
1793
+ 12,
1794
+ 13,
1795
+ 14,
1796
+ 15,
1797
+ 16,
1798
+ 17,
1799
+ 18,
1800
+ 19,
1801
+ 20,
1802
+ 21,
1803
+ 22,
1804
+ 23,
1805
+ 24,
1806
+ 25
1807
+ ]
1808
+ },
1809
+ {
1810
+ "removed_start": 9,
1811
+ "removed_end": 26,
1812
+ "compare_left": 8,
1813
+ "compare_right": 26,
1814
+ "score": 0.9738603377342224,
1815
+ "inferred_pruned_layers_zero_based": [
1816
+ 9,
1817
+ 10,
1818
+ 11,
1819
+ 12,
1820
+ 13,
1821
+ 14,
1822
+ 15,
1823
+ 16,
1824
+ 17,
1825
+ 18,
1826
+ 19,
1827
+ 20,
1828
+ 21,
1829
+ 22,
1830
+ 23,
1831
+ 24,
1832
+ 25,
1833
+ 26
1834
+ ]
1835
+ },
1836
+ {
1837
+ "removed_start": 10,
1838
+ "removed_end": 27,
1839
+ "compare_left": 9,
1840
+ "compare_right": 27,
1841
+ "score": 0.9975382511615754,
1842
+ "inferred_pruned_layers_zero_based": [
1843
+ 10,
1844
+ 11,
1845
+ 12,
1846
+ 13,
1847
+ 14,
1848
+ 15,
1849
+ 16,
1850
+ 17,
1851
+ 18,
1852
+ 19,
1853
+ 20,
1854
+ 21,
1855
+ 22,
1856
+ 23,
1857
+ 24,
1858
+ 25,
1859
+ 26,
1860
+ 27
1861
+ ]
1862
+ },
1863
+ {
1864
+ "removed_start": 11,
1865
+ "removed_end": 28,
1866
+ "compare_left": 10,
1867
+ "compare_right": 28,
1868
+ "score": 0.9783859169483184,
1869
+ "inferred_pruned_layers_zero_based": [
1870
+ 11,
1871
+ 12,
1872
+ 13,
1873
+ 14,
1874
+ 15,
1875
+ 16,
1876
+ 17,
1877
+ 18,
1878
+ 19,
1879
+ 20,
1880
+ 21,
1881
+ 22,
1882
+ 23,
1883
+ 24,
1884
+ 25,
1885
+ 26,
1886
+ 27,
1887
+ 28
1888
+ ]
1889
+ },
1890
+ {
1891
+ "removed_start": 12,
1892
+ "removed_end": 29,
1893
+ "compare_left": 11,
1894
+ "compare_right": 29,
1895
+ "score": 0.9918379864692688,
1896
+ "inferred_pruned_layers_zero_based": [
1897
+ 12,
1898
+ 13,
1899
+ 14,
1900
+ 15,
1901
+ 16,
1902
+ 17,
1903
+ 18,
1904
+ 19,
1905
+ 20,
1906
+ 21,
1907
+ 22,
1908
+ 23,
1909
+ 24,
1910
+ 25,
1911
+ 26,
1912
+ 27,
1913
+ 28,
1914
+ 29
1915
+ ]
1916
+ },
1917
+ {
1918
+ "removed_start": 13,
1919
+ "removed_end": 30,
1920
+ "compare_left": 12,
1921
+ "compare_right": 30,
1922
+ "score": 0.956602737903595,
1923
+ "inferred_pruned_layers_zero_based": [
1924
+ 13,
1925
+ 14,
1926
+ 15,
1927
+ 16,
1928
+ 17,
1929
+ 18,
1930
+ 19,
1931
+ 20,
1932
+ 21,
1933
+ 22,
1934
+ 23,
1935
+ 24,
1936
+ 25,
1937
+ 26,
1938
+ 27,
1939
+ 28,
1940
+ 29,
1941
+ 30
1942
+ ]
1943
+ },
1944
+ {
1945
+ "removed_start": 14,
1946
+ "removed_end": 31,
1947
+ "compare_left": 13,
1948
+ "compare_right": 31,
1949
+ "score": 1.0131061437129973,
1950
+ "inferred_pruned_layers_zero_based": [
1951
+ 14,
1952
+ 15,
1953
+ 16,
1954
+ 17,
1955
+ 18,
1956
+ 19,
1957
+ 20,
1958
+ 21,
1959
+ 22,
1960
+ 23,
1961
+ 24,
1962
+ 25,
1963
+ 26,
1964
+ 27,
1965
+ 28,
1966
+ 29,
1967
+ 30,
1968
+ 31
1969
+ ]
1970
+ },
1971
+ {
1972
+ "removed_start": 15,
1973
+ "removed_end": 32,
1974
+ "compare_left": 14,
1975
+ "compare_right": 32,
1976
+ "score": 0.9944792635440827,
1977
+ "inferred_pruned_layers_zero_based": [
1978
+ 15,
1979
+ 16,
1980
+ 17,
1981
+ 18,
1982
+ 19,
1983
+ 20,
1984
+ 21,
1985
+ 22,
1986
+ 23,
1987
+ 24,
1988
+ 25,
1989
+ 26,
1990
+ 27,
1991
+ 28,
1992
+ 29,
1993
+ 30,
1994
+ 31,
1995
+ 32
1996
+ ]
1997
+ },
1998
+ {
1999
+ "removed_start": 16,
2000
+ "removed_end": 33,
2001
+ "compare_left": 15,
2002
+ "compare_right": 33,
2003
+ "score": 1.0215474195480347,
2004
+ "inferred_pruned_layers_zero_based": [
2005
+ 16,
2006
+ 17,
2007
+ 18,
2008
+ 19,
2009
+ 20,
2010
+ 21,
2011
+ 22,
2012
+ 23,
2013
+ 24,
2014
+ 25,
2015
+ 26,
2016
+ 27,
2017
+ 28,
2018
+ 29,
2019
+ 30,
2020
+ 31,
2021
+ 32,
2022
+ 33
2023
+ ]
2024
+ },
2025
+ {
2026
+ "removed_start": 17,
2027
+ "removed_end": 34,
2028
+ "compare_left": 16,
2029
+ "compare_right": 34,
2030
+ "score": 1.0073524992465972,
2031
+ "inferred_pruned_layers_zero_based": [
2032
+ 17,
2033
+ 18,
2034
+ 19,
2035
+ 20,
2036
+ 21,
2037
+ 22,
2038
+ 23,
2039
+ 24,
2040
+ 25,
2041
+ 26,
2042
+ 27,
2043
+ 28,
2044
+ 29,
2045
+ 30,
2046
+ 31,
2047
+ 32,
2048
+ 33,
2049
+ 34
2050
+ ]
2051
+ },
2052
+ {
2053
+ "removed_start": 18,
2054
+ "removed_end": 35,
2055
+ "compare_left": 17,
2056
+ "compare_right": 35,
2057
+ "score": 1.0098007888793945,
2058
+ "inferred_pruned_layers_zero_based": [
2059
+ 18,
2060
+ 19,
2061
+ 20,
2062
+ 21,
2063
+ 22,
2064
+ 23,
2065
+ 24,
2066
+ 25,
2067
+ 26,
2068
+ 27,
2069
+ 28,
2070
+ 29,
2071
+ 30,
2072
+ 31,
2073
+ 32,
2074
+ 33,
2075
+ 34,
2076
+ 35
2077
+ ]
2078
+ }
2079
+ ]
2080
+ },
2081
+ "config": {
2082
+ "model": "/workspace/models/qwen3-8b-base-49e3418",
2083
+ "dataset": "slimpajama",
2084
+ "dataset_config": null,
2085
+ "split": "train",
2086
+ "text_field": "text",
2087
+ "instruction_format": "slimorca",
2088
+ "seq_len": 1024,
2089
+ "target_tokens": 500000,
2090
+ "num_sequences": 500,
2091
+ "batch_size": 2,
2092
+ "prune_layers": 18,
2093
+ "max_batches": 0,
2094
+ "device": "cuda",
2095
+ "dtype": "bfloat16",
2096
+ "trust_remote_code": false,
2097
+ "data_spec": {
2098
+ "dataset": "slimpajama",
2099
+ "config": null,
2100
+ "split": "train",
2101
+ "text_field": "text",
2102
+ "num_samples": 0,
2103
+ "seq_len": 1024,
2104
+ "num_sequences": 500,
2105
+ "target_tokens": 500000,
2106
+ "batch_size": 2,
2107
+ "shuffle": false,
2108
+ "num_workers": 0,
2109
+ "seed": 42,
2110
+ "add_bos": false
2111
+ }
2112
+ },
2113
+ "data": {
2114
+ "actual_num_chunks": 500,
2115
+ "seq_len": 1024,
2116
+ "actual_total_tokens": 512000,
2117
+ "chunk_cache_path": "/workspace/artifacts/qwen3-base-half2-20261012/selection/slimpajama500_seed42.pt"
2118
+ }
2119
+ }
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/selection.log ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"utc": "2026-10-12T14:08:54.494731+00:00", "command": ["bash", "/workspace/external/qwen3-base-half2-legacy/run_compare_layer_selection_metrics.sh"]}
2
+ [transformers] `torch_dtype` is deprecated! Use `dtype` instead!
3
+ [transformers] The following generation flags are not valid and may be ignored: ['output_hidden_states']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
4
+
5
+ [data] chunk cache miss, will build and save: /workspace/artifacts/qwen3-base-half2-20261012/selection/slimpajama500_seed42.pt
6
+ [data] wrote chunk cache: /workspace/artifacts/qwen3-base-half2-20261012/selection/slimpajama500_seed42.pt
7
+
8
+
9
+ Data summary
10
+ ============
11
+ chunks=500 seq_len=1024 actual_total_tokens=512000
12
+ chunk_cache_path=/workspace/artifacts/qwen3-base-half2-20261012/selection/slimpajama500_seed42.pt
13
+
14
+ Selection summary
15
+ =================
16
+ llm_streamline score=5.545817e-01 removed=15..32 compare=14 -> 32 pruned_layers=[15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
17
+ replaceme score=3.107806e-01 removed=14..31 compare=13 -> 31 pruned_layers=[14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
18
+ fuse_region_cosine score=4.454183e-01 removed=15..32 compare=14 -> 32 pruned_layers=[15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
19
+ fuse_region_cosine_mlp_pre_residual score=8.522758e-01 removed=7..24 compare=6 -> 24 pruned_layers=[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
20
+
21
+ Top starts per method
22
+ =====================
23
+ llm_streamline
24
+ removed_start=15 score=5.545817e-01 pruned=[15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
25
+ removed_start=13 score=5.528837e-01 pruned=[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
26
+ removed_start=18 score=5.483627e-01 pruned=[18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
27
+ removed_start=17 score=5.471236e-01 pruned=[17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
28
+ removed_start=14 score=5.463030e-01 pruned=[14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
29
+ replaceme
30
+ removed_start=14 score=3.107806e-01 pruned=[14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
31
+ removed_start=12 score=3.113691e-01 pruned=[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
32
+ removed_start=13 score=3.139335e-01 pruned=[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
33
+ removed_start=17 score=3.145263e-01 pruned=[17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
34
+ removed_start=16 score=3.151758e-01 pruned=[16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
35
+ fuse_region_cosine
36
+ removed_start=15 score=4.454183e-01 pruned=[15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
37
+ removed_start=13 score=4.471163e-01 pruned=[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
38
+ removed_start=18 score=4.516373e-01 pruned=[18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
39
+ removed_start=17 score=4.528764e-01 pruned=[17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
40
+ removed_start=14 score=4.536970e-01 pruned=[14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
41
+ fuse_region_cosine_mlp_pre_residual
42
+ removed_start= 7 score=8.522758e-01 pruned=[7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
43
+ removed_start= 6 score=8.878196e-01 pruned=[6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
44
+ removed_start= 2 score=9.171930e-01 pruned=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
45
+ removed_start= 5 score=9.321214e-01 pruned=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
46
+ removed_start=13 score=9.566027e-01 pruned=[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
47
+
48
+ Wrote /workspace/artifacts/qwen3-base-half2-20261012/selection/selection.json
49
+ output_json=/workspace/artifacts/qwen3-base-half2-20261012/selection/selection.json
50
+ chunk_cache_path=/workspace/artifacts/qwen3-base-half2-20261012/selection/slimpajama500_seed42.pt
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/slimpajama500_seed42.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f3a56be04acac5ca8ad09dd10e02280659326af9c065f6c57a86d27e69ff997
3
+ size 4235401
runs/vast-paper_revision-qwen3-base-half2-55563310-20261012/20261012-qwen3-base-half18/replaceme/selection/summary.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "Qwen/Qwen3-8B-Base",
3
+ "revision": "49e3418fbbbca6ecbdf9608b4d22e5a407081db4",
4
+ "sequences": 500,
5
+ "sequence_length": 1024,
6
+ "seed": 42,
7
+ "selections": {
8
+ "replaceme": {
9
+ "method": "replaceme",
10
+ "score_direction": "min",
11
+ "removed_start": 14,
12
+ "removed_end": 31,
13
+ "compare_left": 13,
14
+ "compare_right": 31,
15
+ "selected_score": 0.31078056192398074,
16
+ "inferred_pruned_layers_zero_based": [
17
+ 14,
18
+ 15,
19
+ 16,
20
+ 17,
21
+ 18,
22
+ 19,
23
+ 20,
24
+ 21,
25
+ 22,
26
+ 23,
27
+ 24,
28
+ 25,
29
+ 26,
30
+ 27,
31
+ 28,
32
+ 29,
33
+ 30,
34
+ 31
35
+ ],
36
+ "notes": "Unified span score: compare last-token hidden states of the first and last removed layers.",
37
+ "removed_interval_half_open": [
38
+ 14,
39
+ 32
40
+ ]
41
+ },
42
+ "fuse_region_cosine": {
43
+ "method": "fuse_region_cosine",
44
+ "score_direction": "min",
45
+ "removed_start": 15,
46
+ "removed_end": 32,
47
+ "compare_left": 14,
48
+ "compare_right": 32,
49
+ "selected_score": 0.44541832387447355,
50
+ "inferred_pruned_layers_zero_based": [
51
+ 15,
52
+ 16,
53
+ 17,
54
+ 18,
55
+ 19,
56
+ 20,
57
+ 21,
58
+ 22,
59
+ 23,
60
+ 24,
61
+ 25,
62
+ 26,
63
+ 27,
64
+ 28,
65
+ 29,
66
+ 30,
67
+ 31,
68
+ 32
69
+ ],
70
+ "notes": "Unified span score: compare hidden_states[r-1] and hidden_states[r+w-1] using token-level 1-cosine.",
71
+ "removed_interval_half_open": [
72
+ 15,
73
+ 33
74
+ ]
75
+ }
76
+ }
77
+ }