Upload folder using huggingface_hub
Browse files- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/README.md +5 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/SHA256SUMS +45 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/checkpoints/students/native_k160000_r8/native_region_delta.pt +3 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/data/flores_teacher_train_hyps.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/fixed_k160000.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/native_region_k160000_r8.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/no_mask.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/base_k160000_masks.json +30 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/native_region_k160000_r8.json +18 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/r8_k160000_masks.json +30 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/build_flores.log +3 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/build_ntrex.log +6 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/download_hy_lora_conditions.log +2 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_base_k160000.log +12 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_native_region_k160000_r8.log +19 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_r8_k160000.log +14 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/generate_flores_teacher_hyps.log +5 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/package_issue33_hf_upload.log +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/progress.log +14 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/runner_outer.log +60 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/summarize_issue33_k160000_r8.log +4 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/train_native_region_k160000_r8.log +11 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_base_fixed_k160000.log +56 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_native_region_k160000_r8.log +56 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_r8_fixed_k160000.log +56 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifest.json +42 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/config.json +59 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/native_region_delta_config.json +14 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/train_summary.json +117 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/notes/issue33_native_region_mvc.md +34 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/evaluate_native_region_delta_translation.py +177 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/issue33_native_region_runner.sh +284 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/package_issue33_hf_upload.sh +106 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/summarize_issue33_native_region.py +153 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/train_native_region_delta_translation.py +290 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/translation_native_region.py +155 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/spec/native_region_mvc_issue33.json +58 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/summaries/issue33_native_region_k160000_r8.json +32 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/summaries/issue33_native_region_k160000_r8.md +15 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/base_fixed_k160000.json +25 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/base_fixed_k160000.scored_pool.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/native_region_k160000_r8.json +25 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/native_region_k160000_r8.scored_pool.jsonl +0 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/r8_fixed_k160000.json +25 -0
- circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/r8_fixed_k160000.scored_pool.jsonl +0 -0
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue 33 Native Selected-Region Student Artifacts
|
| 2 |
+
|
| 3 |
+
This folder contains compact artifacts for the issue #33 EN->PT native selected-region student run: spec, notes, reusable scripts, FLORES teacher hypothesis data when packaged, NTREX eval summaries, generated hypotheses, XCOMET summaries, logs, and the native region delta checkpoint when present.
|
| 4 |
+
|
| 5 |
+
The checkpoint is the experiment-owned selected-region slice edit only. Upstream HY-MT weights, XCOMET weights, Hugging Face cache directories, API keys, and service tokens are intentionally excluded.
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/SHA256SUMS
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
5377eebba36af3224b8578fbc9e2c2147e388c8616478df454af1046572ba380 ./README.md
|
| 2 |
+
57311c9080321e1501f1aad273141477511760ec83f310066003d9fa5bf86407 ./SHA256SUMS
|
| 3 |
+
8e495b612ae0b39782e6f01339f003802e6e6d66dd2df7420baa7a05135abfa1 ./checkpoints/students/native_k160000_r8/native_region_delta.pt
|
| 4 |
+
f6250df9e1f5c8bcdad0cf064f8ad5ad58cd3c413dbbc52db8f2fdcc6b742449 ./data/flores_teacher_train_hyps.jsonl
|
| 5 |
+
5e62ef48e601ce757fc16457bcecd111b061e10f375fd0be2ee0577c7a005219 ./dumps/fixed_k160000.jsonl
|
| 6 |
+
dcb0e935e85c599e638149bfdbf6b38e869acdfb6254b9441c71e0f15b95499a ./dumps/native_region_k160000_r8.jsonl
|
| 7 |
+
376c838cfc0186fa06d57e65807773320ac112ec3251adaffe16145533595f40 ./dumps/no_mask.jsonl
|
| 8 |
+
389c5670cef01f37142b42d39e1d56b915a60f872a3aa697eb55454014518d79 ./eval/base_k160000_masks.json
|
| 9 |
+
3b5d282c6ff4c675d5f2cdf57d0a4b6d56b815d8abaa8df060cb5182b4bd6866 ./eval/native_region_k160000_r8.json
|
| 10 |
+
5d23689341f142dc78ac159c290c4c85fe7137cb14e119bbc51d4513f1121ddf ./eval/r8_k160000_masks.json
|
| 11 |
+
0d6096293966e0c1513e1cbf1babf8977bae85e7b74a189e5f0b4f5597dd747a ./logs/build_flores.log
|
| 12 |
+
35216e1631ff96c59dadabdb99d6b0e5ccd378a82eb2396e4ae4885951dcbd05 ./logs/build_ntrex.log
|
| 13 |
+
354f6f1634af03560bf6e8bfb41786dda72bad51f890c3759449c5bee332f949 ./logs/download_hy_lora_conditions.log
|
| 14 |
+
806dbbf60a8cf81357e0d8b5a2c7909adb0493f812715b0c87684856a794cbd9 ./logs/eval_base_k160000.log
|
| 15 |
+
a6bf9e90e5d27e6b0f59eeb811871322478e4bd4ded5969d8d26b87f3d590d84 ./logs/eval_native_region_k160000_r8.log
|
| 16 |
+
e5b4e6a536edd0357eff261f94da92609397acfdd84332ed0ceddccbd9765331 ./logs/eval_r8_k160000.log
|
| 17 |
+
28a0b3ca62680abcbfc47769b0645dcf155e5fa23bef6440fb68b3f6a641078b ./logs/generate_flores_teacher_hyps.log
|
| 18 |
+
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ./logs/package_issue33_hf_upload.log
|
| 19 |
+
7fe93e156c539a317d2f9e9e878c9883a81ef500930e2e259b82f4fc73101ab3 ./logs/progress.log
|
| 20 |
+
b4427f5f59f03921a3d665e719c1aa7db65c517a61a566c209d2d80cbe5f12f6 ./logs/runner_outer.log
|
| 21 |
+
d36549469909fec423d61a31cbe096f61f5be0a1d753312a331de896c30ddcc0 ./logs/summarize_issue33_k160000_r8.log
|
| 22 |
+
a8a83a601e7c8742baff8625bfb233b4bd5c51afd96b69f8ab3e09f8b677a3fa ./logs/train_native_region_k160000_r8.log
|
| 23 |
+
2d7e9e4a7d252bb58aa1284035060d4df60a116c83a01afd2d58df30edb4d7f6 ./logs/xcomet_base_fixed_k160000.log
|
| 24 |
+
c1cb58da8e4a407ea43a7fea3f1261033002ce41852e457bbf1ae0991738f130 ./logs/xcomet_native_region_k160000_r8.log
|
| 25 |
+
9cd8ec5b86a7c4e1b6a67356d6729dbe0ee2e9ff0460b19ecf4c9712e36b2ed8 ./logs/xcomet_r8_fixed_k160000.log
|
| 26 |
+
78efa64b813d573843b1a1a42ead9dec9258410b4130075c70c626d5dbf61edd ./manifest.json
|
| 27 |
+
f47756d43f191446b39a0d334f4ea6fd9f6e284780bca20829b2c95d2e357f78 ./manifests/students/native_k160000_r8/config.json
|
| 28 |
+
b7c852002b46ed04766af112a27ad124735e01c82b2026120a52b6918cc6b171 ./manifests/students/native_k160000_r8/native_region_delta_config.json
|
| 29 |
+
a10193dc61826976e2abb9497f37009fca8e3de5011777422df9122e1a78d0f6 ./manifests/students/native_k160000_r8/train_summary.json
|
| 30 |
+
999bdc1224133f6979c0a38e82dfa47f981804e36a15e589ec8a121deee45a32 ./notes/issue33_native_region_mvc.md
|
| 31 |
+
1e8fd77f80848dd8b601b180abf895a96c28c20673c503805542bbf0661ab40e ./scripts/evaluate_native_region_delta_translation.py
|
| 32 |
+
2f1927c360063d7772025c8bcfc9dfe0cc4293598f5744311bd82f4813551c6a ./scripts/issue33_native_region_runner.sh
|
| 33 |
+
f4bc614fc0943abbff070f4769cc0f8a7c074541ddcffa071aa5579d1dc8a3de ./scripts/package_issue33_hf_upload.sh
|
| 34 |
+
5a3f35a35acb4167cc9c4f349d3638cd007ca68f9b149169d4db17c481a7c0f6 ./scripts/summarize_issue33_native_region.py
|
| 35 |
+
277b881a7b8bf170928b85871c70680619c4c793d5e732f20a6babd03861d4ce ./scripts/train_native_region_delta_translation.py
|
| 36 |
+
f297051a8e09341abf6f1d87ad330a7240ccc2388ba4081487efe41e39a2131d ./scripts/translation_native_region.py
|
| 37 |
+
5b25d49517c46c4661447930322054ab8b1acba6451171d441dcbe8f035f7d71 ./spec/native_region_mvc_issue33.json
|
| 38 |
+
468a00a7a476a39d5aeca9dfb3d133d8d4864644d9390e99f75d63468f5c3fd7 ./summaries/issue33_native_region_k160000_r8.json
|
| 39 |
+
2dbb25a2d883c7faf1ecaeb6149cde74e3d59951951fc10d81a6d1062a8e4e18 ./summaries/issue33_native_region_k160000_r8.md
|
| 40 |
+
fdbbbc45d92b5bc682f434547a585137f6df055519ee86a433ec5c08c41f26b7 ./xcomet/base_fixed_k160000.json
|
| 41 |
+
0827072b81648d4b68586c6a7b2cff916fbcc4d826587a4b4532d4a4398bd8ad ./xcomet/base_fixed_k160000.scored_pool.jsonl
|
| 42 |
+
065770e05d353611f48a431945937df58f3ad1a21477d801d9d2bde67db2756d ./xcomet/native_region_k160000_r8.json
|
| 43 |
+
a9dc9c58f2cbe7394261147fc62c29114e3b53ec65b61d8614cab3838c62e82a ./xcomet/native_region_k160000_r8.scored_pool.jsonl
|
| 44 |
+
8965fdcfaa323feb9898494449a8c38b3b79b75f87654af12cbd44e0b2db229c ./xcomet/r8_fixed_k160000.json
|
| 45 |
+
4cc25e049f6b71ba945bf5843566db8926acd78dbb6c76a26ec97b09a4b01cd4 ./xcomet/r8_fixed_k160000.scored_pool.jsonl
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/checkpoints/students/native_k160000_r8/native_region_delta.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e495b612ae0b39782e6f01339f003802e6e6d66dd2df7420baa7a05135abfa1
|
| 3 |
+
size 21725255
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/data/flores_teacher_train_hyps.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/fixed_k160000.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/native_region_k160000_r8.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/dumps/no_mask.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/base_k160000_masks.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "tencent/HY-MT1.5-1.8B",
|
| 3 |
+
"adapter": null,
|
| 4 |
+
"n_layers": 32,
|
| 5 |
+
"d_ffn": 6144,
|
| 6 |
+
"n_examples": 1012,
|
| 7 |
+
"n_calib": 64,
|
| 8 |
+
"results": {
|
| 9 |
+
"no_mask": {
|
| 10 |
+
"scores": {
|
| 11 |
+
"chrFpp": 54.22844417616828,
|
| 12 |
+
"chrF": 56.92735106386091,
|
| 13 |
+
"BLEU": 25.81246822014709,
|
| 14 |
+
"n": 1012
|
| 15 |
+
},
|
| 16 |
+
"kept": -1
|
| 17 |
+
},
|
| 18 |
+
"fixed_k160000": {
|
| 19 |
+
"scores": {
|
| 20 |
+
"chrFpp": 46.99461052474228,
|
| 21 |
+
"chrF": 49.88832385757205,
|
| 22 |
+
"BLEU": 18.22647479890369,
|
| 23 |
+
"n": 1012
|
| 24 |
+
},
|
| 25 |
+
"kept": 160000,
|
| 26 |
+
"mask_path": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 27 |
+
"elapsed_s": 50.31123614311218
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/native_region_k160000_r8.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "tencent/HY-MT1.5-1.8B",
|
| 3 |
+
"student_dir": "/root/runs/issue33_native_region/students/native_k160000_r8",
|
| 4 |
+
"mask": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 5 |
+
"mask_kept": 160000,
|
| 6 |
+
"rank": 8,
|
| 7 |
+
"n_layers": 32,
|
| 8 |
+
"d_ffn": 6144,
|
| 9 |
+
"scores": {
|
| 10 |
+
"chrFpp": 50.97431297760433,
|
| 11 |
+
"chrF": 53.79762252779031,
|
| 12 |
+
"BLEU": 22.184172798821177,
|
| 13 |
+
"n": 1012
|
| 14 |
+
},
|
| 15 |
+
"dump_hyps": "/root/runs/issue33_native_region/dumps/native_region_k160000_r8.jsonl",
|
| 16 |
+
"elapsed_s": 89.59548020362854,
|
| 17 |
+
"method": "native_selected_region_delta"
|
| 18 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/eval/r8_k160000_masks.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "tencent/HY-MT1.5-1.8B",
|
| 3 |
+
"adapter": "/root/runs/issue33_native_region/hy_lora_conditions/low_rank_lens/k160_r8/adapter",
|
| 4 |
+
"n_layers": 32,
|
| 5 |
+
"d_ffn": 6144,
|
| 6 |
+
"n_examples": 1012,
|
| 7 |
+
"n_calib": 64,
|
| 8 |
+
"results": {
|
| 9 |
+
"no_mask": {
|
| 10 |
+
"scores": {
|
| 11 |
+
"chrFpp": 53.72683437781636,
|
| 12 |
+
"chrF": 56.546862635098364,
|
| 13 |
+
"BLEU": 24.989224851370132,
|
| 14 |
+
"n": 1012
|
| 15 |
+
},
|
| 16 |
+
"kept": -1
|
| 17 |
+
},
|
| 18 |
+
"fixed_k160000": {
|
| 19 |
+
"scores": {
|
| 20 |
+
"chrFpp": 51.21928365554815,
|
| 21 |
+
"chrF": 53.989194431609235,
|
| 22 |
+
"BLEU": 22.699147288564674,
|
| 23 |
+
"n": 1012
|
| 24 |
+
},
|
| 25 |
+
"kept": 160000,
|
| 26 |
+
"mask_path": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 27 |
+
"elapsed_s": 54.19245409965515
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/build_flores.log
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
wrote 1012 pairs -> /root/runs/flores_eval/flores_en2pt_devtest.jsonl
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/build_ntrex.log
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
NTREX-128 columns sample: ['sna_Latn', 'est_Latn', 'glg_Latn', 'bem_Latn', 'nob_Latn', 'zul_Latn', 'hye_Armn', 'nep_Deva'] ...
|
| 3 |
+
NTREX-128 size: 1997 rows
|
| 4 |
+
src column: eng_Latn
|
| 5 |
+
tgt column: por_Latn
|
| 6 |
+
wrote 1012 pairs -> /root/runs/ntrex_eval/ntrex_en2pt.jsonl
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/download_hy_lora_conditions.log
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/root/runs/issue33_native_region/hy_lora_conditions
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_base_k160000.log
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] tokenizer from tencent/HY-MT1.5-1.8B
|
| 2 |
+
[load] base model tencent/HY-MT1.5-1.8B
|
| 3 |
+
[data] eval_rows=1012
|
| 4 |
+
[mean] building mean cache from 64 prompts
|
| 5 |
+
[eval] no-mask
|
| 6 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 7 |
+
no_mask: {'chrFpp': 54.22844417616828, 'chrF': 56.92735106386091, 'BLEU': 25.81246822014709, 'n': 1012}
|
| 8 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/base_k160000/no_mask.jsonl
|
| 9 |
+
[eval] mask=fixed_k160000 from /root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz
|
| 10 |
+
fixed_k160000: kept=160000 {'chrFpp': 46.99461052474228, 'chrF': 49.88832385757205, 'BLEU': 18.22647479890369, 'n': 1012} (50.3s)
|
| 11 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/base_k160000/fixed_k160000.jsonl
|
| 12 |
+
[done] wrote /root/runs/issue33_native_region/eval/base_k160000_masks.json
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_native_region_k160000_r8.log
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 2 |
+
{
|
| 3 |
+
"model": "tencent/HY-MT1.5-1.8B",
|
| 4 |
+
"student_dir": "/root/runs/issue33_native_region/students/native_k160000_r8",
|
| 5 |
+
"mask": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 6 |
+
"mask_kept": 160000,
|
| 7 |
+
"rank": 8,
|
| 8 |
+
"n_layers": 32,
|
| 9 |
+
"d_ffn": 6144,
|
| 10 |
+
"scores": {
|
| 11 |
+
"chrFpp": 50.97431297760433,
|
| 12 |
+
"chrF": 53.79762252779031,
|
| 13 |
+
"BLEU": 22.184172798821177,
|
| 14 |
+
"n": 1012
|
| 15 |
+
},
|
| 16 |
+
"dump_hyps": "/root/runs/issue33_native_region/dumps/native_region_k160000_r8.jsonl",
|
| 17 |
+
"elapsed_s": 89.59548020362854,
|
| 18 |
+
"method": "native_selected_region_delta"
|
| 19 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/eval_r8_k160000.log
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] tokenizer from tencent/HY-MT1.5-1.8B
|
| 2 |
+
[load] base model tencent/HY-MT1.5-1.8B
|
| 3 |
+
[load] adapter /root/runs/issue33_native_region/hy_lora_conditions/low_rank_lens/k160_r8/adapter
|
| 4 |
+
[merge] merging adapter in memory
|
| 5 |
+
[data] eval_rows=1012
|
| 6 |
+
[mean] building mean cache from 64 prompts
|
| 7 |
+
[eval] no-mask
|
| 8 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 9 |
+
no_mask: {'chrFpp': 53.72683437781636, 'chrF': 56.546862635098364, 'BLEU': 24.989224851370132, 'n': 1012}
|
| 10 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/r8_k160000/no_mask.jsonl
|
| 11 |
+
[eval] mask=fixed_k160000 from /root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz
|
| 12 |
+
fixed_k160000: kept=160000 {'chrFpp': 51.21928365554815, 'chrF': 53.989194431609235, 'BLEU': 22.699147288564674, 'n': 1012} (54.2s)
|
| 13 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/r8_k160000/fixed_k160000.jsonl
|
| 14 |
+
[done] wrote /root/runs/issue33_native_region/eval/r8_k160000_masks.json
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/generate_flores_teacher_hyps.log
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 2 |
+
[load] 1012 pairs (slice [0,1012) of 1012) from /root/runs/flores_eval/flores_en2pt_devtest.jsonl
|
| 3 |
+
[gen] load tencent/HY-MT1.5-1.8B
|
| 4 |
+
[gen] 1012 in 47s (21.7 sent/s)
|
| 5 |
+
[save] /root/runs/issue33_native_region/data/flores_teacher_train_hyps.jsonl (1012 rows)
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/package_issue33_hf_upload.log
ADDED
|
File without changes
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/progress.log
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[2026-05-13T16:44:53+00:00] issue33 start model=tencent/HY-MT1.5-1.8B k=160000 ranks=8 xcomet_mode=direct
|
| 2 |
+
[2026-05-13T16:44:53+00:00] download preserved mask/reference adapters from Occupying-Mars/hy-lora-conditions
|
| 3 |
+
[2026-05-13T16:44:59+00:00] build FLORES EN->PT devtest jsonl
|
| 4 |
+
[2026-05-13T16:45:04+00:00] build NTREX EN->PT held-out jsonl
|
| 5 |
+
[2026-05-13T16:45:07+00:00] generate FLORES teacher-hyp train data
|
| 6 |
+
[2026-05-13T16:46:08+00:00] evaluate base selected-region anchor
|
| 7 |
+
[2026-05-13T16:47:56+00:00] evaluate best trained reference from issue #28 r8 for comparison
|
| 8 |
+
[2026-05-13T16:49:48+00:00] train native selected-region student k=160000 rank=8
|
| 9 |
+
[2026-05-13T16:50:54+00:00] evaluate native selected-region student k=160000 rank=8
|
| 10 |
+
[2026-05-13T16:52:29+00:00] score base selected-region anchor
|
| 11 |
+
[2026-05-13T17:00:55+00:00] score best trained reference from issue #28 r8
|
| 12 |
+
[2026-05-13T17:08:01+00:00] score native selected-region student k=160000 rank=8
|
| 13 |
+
[2026-05-13T17:14:58+00:00] summarize issue33 k=160000 rank=8
|
| 14 |
+
[2026-05-13T17:14:58+00:00] package and upload issue33 artifacts
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/runner_outer.log
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[2026-05-13T16:44:53+00:00] issue33 start model=tencent/HY-MT1.5-1.8B k=160000 ranks=8 xcomet_mode=direct
|
| 2 |
+
[2026-05-13T16:44:53+00:00] download preserved mask/reference adapters from Occupying-Mars/hy-lora-conditions
|
| 3 |
+
|
| 4 |
+
/root/runs/issue33_native_region/hy_lora_conditions
|
| 5 |
+
[2026-05-13T16:44:59+00:00] build FLORES EN->PT devtest jsonl
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
wrote 1012 pairs -> /root/runs/flores_eval/flores_en2pt_devtest.jsonl
|
| 9 |
+
[2026-05-13T16:45:04+00:00] build NTREX EN->PT held-out jsonl
|
| 10 |
+
|
| 11 |
+
NTREX-128 columns sample: ['sna_Latn', 'est_Latn', 'glg_Latn', 'bem_Latn', 'nob_Latn', 'zul_Latn', 'hye_Armn', 'nep_Deva'] ...
|
| 12 |
+
NTREX-128 size: 1997 rows
|
| 13 |
+
src column: eng_Latn
|
| 14 |
+
tgt column: por_Latn
|
| 15 |
+
wrote 1012 pairs -> /root/runs/ntrex_eval/ntrex_en2pt.jsonl
|
| 16 |
+
[2026-05-13T16:45:07+00:00] generate FLORES teacher-hyp train data
|
| 17 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 18 |
+
[load] 1012 pairs (slice [0,1012) of 1012) from /root/runs/flores_eval/flores_en2pt_devtest.jsonl
|
| 19 |
+
[gen] load tencent/HY-MT1.5-1.8B
|
| 20 |
+
[gen] 1012 in 47s (21.7 sent/s)
|
| 21 |
+
[save] /root/runs/issue33_native_region/data/flores_teacher_train_hyps.jsonl (1012 rows)
|
| 22 |
+
[2026-05-13T16:46:08+00:00] evaluate base selected-region anchor
|
| 23 |
+
[load] tokenizer from tencent/HY-MT1.5-1.8B
|
| 24 |
+
[load] base model tencent/HY-MT1.5-1.8B
|
| 25 |
+
[data] eval_rows=1012
|
| 26 |
+
[mean] building mean cache from 64 prompts
|
| 27 |
+
[eval] no-mask
|
| 28 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 29 |
+
no_mask: {'chrFpp': 54.22844417616828, 'chrF': 56.92735106386091, 'BLEU': 25.81246822014709, 'n': 1012}
|
| 30 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/base_k160000/no_mask.jsonl
|
| 31 |
+
[eval] mask=fixed_k160000 from /root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz
|
| 32 |
+
fixed_k160000: kept=160000 {'chrFpp': 46.99461052474228, 'chrF': 49.88832385757205, 'BLEU': 18.22647479890369, 'n': 1012} (50.3s)
|
| 33 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/base_k160000/fixed_k160000.jsonl
|
| 34 |
+
[done] wrote /root/runs/issue33_native_region/eval/base_k160000_masks.json
|
| 35 |
+
[2026-05-13T16:47:56+00:00] evaluate best trained reference from issue #28 r8 for comparison
|
| 36 |
+
[load] tokenizer from tencent/HY-MT1.5-1.8B
|
| 37 |
+
[load] base model tencent/HY-MT1.5-1.8B
|
| 38 |
+
[load] adapter /root/runs/issue33_native_region/hy_lora_conditions/low_rank_lens/k160_r8/adapter
|
| 39 |
+
[merge] merging adapter in memory
|
| 40 |
+
[data] eval_rows=1012
|
| 41 |
+
[mean] building mean cache from 64 prompts
|
| 42 |
+
[eval] no-mask
|
| 43 |
+
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
|
| 44 |
+
no_mask: {'chrFpp': 53.72683437781636, 'chrF': 56.546862635098364, 'BLEU': 24.989224851370132, 'n': 1012}
|
| 45 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/r8_k160000/no_mask.jsonl
|
| 46 |
+
[eval] mask=fixed_k160000 from /root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz
|
| 47 |
+
fixed_k160000: kept=160000 {'chrFpp': 51.21928365554815, 'chrF': 53.989194431609235, 'BLEU': 22.699147288564674, 'n': 1012} (54.2s)
|
| 48 |
+
dumped 1012 hyps -> /root/runs/issue33_native_region/dumps/r8_k160000/fixed_k160000.jsonl
|
| 49 |
+
[done] wrote /root/runs/issue33_native_region/eval/r8_k160000_masks.json
|
| 50 |
+
[2026-05-13T16:49:48+00:00] train native selected-region student k=160000 rank=8
|
| 51 |
+
[2026-05-13T16:50:54+00:00] evaluate native selected-region student k=160000 rank=8
|
| 52 |
+
[2026-05-13T16:52:29+00:00] score base selected-region anchor
|
| 53 |
+
[2026-05-13T17:00:55+00:00] score best trained reference from issue #28 r8
|
| 54 |
+
[2026-05-13T17:08:01+00:00] score native selected-region student k=160000 rank=8
|
| 55 |
+
[2026-05-13T17:14:58+00:00] summarize issue33 k=160000 rank=8
|
| 56 |
+
{
|
| 57 |
+
"out_json": "/root/runs/issue33_native_region/summaries/issue33_native_region_k160000_r8.json",
|
| 58 |
+
"out_md": "/root/runs/issue33_native_region/summaries/issue33_native_region_k160000_r8.md"
|
| 59 |
+
}
|
| 60 |
+
[2026-05-13T17:14:58+00:00] package and upload issue33 artifacts
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/summarize_issue33_k160000_r8.log
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"out_json": "/root/runs/issue33_native_region/summaries/issue33_native_region_k160000_r8.json",
|
| 3 |
+
"out_md": "/root/runs/issue33_native_region/summaries/issue33_native_region_k160000_r8.md"
|
| 4 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/train_native_region_k160000_r8.log
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"data_rows": 1012, "dropped_rows": 0}
|
| 2 |
+
{"mask_kept": 160000, "mask": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz"}
|
| 3 |
+
{"rank": 8, "trainable_parameters": 5412864, "zero_init_means_initial_eval_matches_base_selected_region": true}
|
| 4 |
+
{"step": 1, "loss": 0.748046875, "masked_kl": 0.607421875, "ce": 0.7060546875, "lr": 3.3333333333333335e-05, "elapsed_s": 0.6507542133331299}
|
| 5 |
+
{"step": 25, "loss": 0.6422627766927084, "masked_kl": 0.5158182779947916, "ce": 0.6314798990885416, "lr": 0.00018807712330634642, "elapsed_s": 12.182272672653198}
|
| 6 |
+
{"step": 50, "loss": 0.46009765625, "masked_kl": 0.36353515625, "ce": 0.48236328125, "lr": 0.00014154150130018866, "elapsed_s": 23.924031734466553}
|
| 7 |
+
{"step": 75, "loss": 0.3659765625, "masked_kl": 0.2878173828125, "ce": 0.3909765625, "lr": 7.810966761934053e-05, "elapsed_s": 35.229416608810425}
|
| 8 |
+
{"step": 100, "loss": 0.367216796875, "masked_kl": 0.2874072265625, "ce": 0.3992724609375, "lr": 2.3581308246275103e-05, "elapsed_s": 45.786269187927246}
|
| 9 |
+
{"step": 125, "loss": 0.3673876953125, "masked_kl": 0.286630859375, "ce": 0.4037890625, "lr": 1.3479116011769767e-07, "elapsed_s": 57.23423790931702}
|
| 10 |
+
{"step": 127, "loss": 0.39501953125, "masked_kl": 0.311279296875, "ce": 0.4197998046875, "lr": 0.0, "elapsed_s": 58.13042879104614}
|
| 11 |
+
{"done": true, "out_dir": "/root/runs/issue33_native_region/students/native_k160000_r8", "elapsed_s": 58.131454944610596}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_base_fixed_k160000.log
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] 1012 rows from /root/runs/issue33_native_region/dumps/base_k160000/fixed_k160000.jsonl
|
| 2 |
+
|
| 3 |
+
[comet] loading Unbabel/XCOMET-XXL from /root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt
|
| 4 |
+
/root/work/circuit-shotting/.venv/lib/python3.12/site-packages/pytorch_lightning/core/saving.py:197: Found keys that are not in the model state dict but in the checkpoint: ['encoder.model.embeddings.position_ids']
|
| 5 |
+
[comet] scoring 1012 rows batch=8 chunk=128
|
| 6 |
+
GPU available: True (cuda), used: True
|
| 7 |
+
TPU available: False, using: 0 TPU cores
|
| 8 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 9 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 10 |
+
You are using a CUDA device ('NVIDIA RTX PRO 6000 Blackwell Server Edition') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision
|
| 11 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 12 |
+
[chunk] 128/1012 mean=0.5578 throughput=2.90 seg/s
|
| 13 |
+
GPU available: True (cuda), used: True
|
| 14 |
+
TPU available: False, using: 0 TPU cores
|
| 15 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 16 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 17 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 18 |
+
[chunk] 256/1012 mean=0.5899 throughput=3.01 seg/s
|
| 19 |
+
GPU available: True (cuda), used: True
|
| 20 |
+
TPU available: False, using: 0 TPU cores
|
| 21 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 22 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 23 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 24 |
+
[chunk] 384/1012 mean=0.6023 throughput=3.08 seg/s
|
| 25 |
+
GPU available: True (cuda), used: True
|
| 26 |
+
TPU available: False, using: 0 TPU cores
|
| 27 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 28 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 29 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 30 |
+
[chunk] 512/1012 mean=0.6041 throughput=3.08 seg/s
|
| 31 |
+
GPU available: True (cuda), used: True
|
| 32 |
+
TPU available: False, using: 0 TPU cores
|
| 33 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 34 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 35 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 36 |
+
[chunk] 640/1012 mean=0.6153 throughput=3.08 seg/s
|
| 37 |
+
GPU available: True (cuda), used: True
|
| 38 |
+
TPU available: False, using: 0 TPU cores
|
| 39 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 40 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 41 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 42 |
+
[chunk] 768/1012 mean=0.6158 throughput=3.03 seg/s
|
| 43 |
+
GPU available: True (cuda), used: True
|
| 44 |
+
TPU available: False, using: 0 TPU cores
|
| 45 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 46 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 47 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 48 |
+
[chunk] 896/1012 mean=0.6235 throughput=3.02 seg/s
|
| 49 |
+
GPU available: True (cuda), used: True
|
| 50 |
+
TPU available: False, using: 0 TPU cores
|
| 51 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 52 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 53 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 54 |
+
[chunk] 1012/1012 mean=0.6259 throughput=2.98 seg/s
|
| 55 |
+
[save] scored pool -> /root/runs/issue33_native_region/xcomet/base_fixed_k160000.scored_pool.jsonl
|
| 56 |
+
[save] summary -> /root/runs/issue33_native_region/xcomet/base_fixed_k160000.json
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_native_region_k160000_r8.log
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] 1012 rows from /root/runs/issue33_native_region/dumps/native_region_k160000_r8.jsonl
|
| 2 |
+
|
| 3 |
+
[comet] loading Unbabel/XCOMET-XXL from /root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt
|
| 4 |
+
/root/work/circuit-shotting/.venv/lib/python3.12/site-packages/pytorch_lightning/core/saving.py:197: Found keys that are not in the model state dict but in the checkpoint: ['encoder.model.embeddings.position_ids']
|
| 5 |
+
[comet] scoring 1012 rows batch=8 chunk=128
|
| 6 |
+
GPU available: True (cuda), used: True
|
| 7 |
+
TPU available: False, using: 0 TPU cores
|
| 8 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 9 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 10 |
+
You are using a CUDA device ('NVIDIA RTX PRO 6000 Blackwell Server Edition') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision
|
| 11 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 12 |
+
[chunk] 128/1012 mean=0.7877 throughput=3.04 seg/s
|
| 13 |
+
GPU available: True (cuda), used: True
|
| 14 |
+
TPU available: False, using: 0 TPU cores
|
| 15 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 16 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 17 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 18 |
+
[chunk] 256/1012 mean=0.7973 throughput=3.11 seg/s
|
| 19 |
+
GPU available: True (cuda), used: True
|
| 20 |
+
TPU available: False, using: 0 TPU cores
|
| 21 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 22 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 23 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 24 |
+
[chunk] 384/1012 mean=0.8007 throughput=3.10 seg/s
|
| 25 |
+
GPU available: True (cuda), used: True
|
| 26 |
+
TPU available: False, using: 0 TPU cores
|
| 27 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 28 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 29 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 30 |
+
[chunk] 512/1012 mean=0.8006 throughput=3.10 seg/s
|
| 31 |
+
GPU available: True (cuda), used: True
|
| 32 |
+
TPU available: False, using: 0 TPU cores
|
| 33 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 34 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 35 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 36 |
+
[chunk] 640/1012 mean=0.7974 throughput=3.11 seg/s
|
| 37 |
+
GPU available: True (cuda), used: True
|
| 38 |
+
TPU available: False, using: 0 TPU cores
|
| 39 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 40 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 41 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 42 |
+
[chunk] 768/1012 mean=0.7923 throughput=3.06 seg/s
|
| 43 |
+
GPU available: True (cuda), used: True
|
| 44 |
+
TPU available: False, using: 0 TPU cores
|
| 45 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 46 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 47 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 48 |
+
[chunk] 896/1012 mean=0.7925 throughput=3.07 seg/s
|
| 49 |
+
GPU available: True (cuda), used: True
|
| 50 |
+
TPU available: False, using: 0 TPU cores
|
| 51 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 52 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 53 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 54 |
+
[chunk] 1012/1012 mean=0.7951 throughput=3.04 seg/s
|
| 55 |
+
[save] scored pool -> /root/runs/issue33_native_region/xcomet/native_region_k160000_r8.scored_pool.jsonl
|
| 56 |
+
[save] summary -> /root/runs/issue33_native_region/xcomet/native_region_k160000_r8.json
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/logs/xcomet_r8_fixed_k160000.log
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] 1012 rows from /root/runs/issue33_native_region/dumps/r8_k160000/fixed_k160000.jsonl
|
| 2 |
+
|
| 3 |
+
[comet] loading Unbabel/XCOMET-XXL from /root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt
|
| 4 |
+
/root/work/circuit-shotting/.venv/lib/python3.12/site-packages/pytorch_lightning/core/saving.py:197: Found keys that are not in the model state dict but in the checkpoint: ['encoder.model.embeddings.position_ids']
|
| 5 |
+
[comet] scoring 1012 rows batch=8 chunk=128
|
| 6 |
+
GPU available: True (cuda), used: True
|
| 7 |
+
TPU available: False, using: 0 TPU cores
|
| 8 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 9 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 10 |
+
You are using a CUDA device ('NVIDIA RTX PRO 6000 Blackwell Server Edition') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision
|
| 11 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 12 |
+
[chunk] 128/1012 mean=0.8068 throughput=2.93 seg/s
|
| 13 |
+
GPU available: True (cuda), used: True
|
| 14 |
+
TPU available: False, using: 0 TPU cores
|
| 15 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 16 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 17 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 18 |
+
[chunk] 256/1012 mean=0.8169 throughput=2.99 seg/s
|
| 19 |
+
GPU available: True (cuda), used: True
|
| 20 |
+
TPU available: False, using: 0 TPU cores
|
| 21 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 22 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 23 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 24 |
+
[chunk] 384/1012 mean=0.8189 throughput=3.04 seg/s
|
| 25 |
+
GPU available: True (cuda), used: True
|
| 26 |
+
TPU available: False, using: 0 TPU cores
|
| 27 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 28 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 29 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 30 |
+
[chunk] 512/1012 mean=0.8223 throughput=3.03 seg/s
|
| 31 |
+
GPU available: True (cuda), used: True
|
| 32 |
+
TPU available: False, using: 0 TPU cores
|
| 33 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 34 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 35 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 36 |
+
[chunk] 640/1012 mean=0.8135 throughput=3.03 seg/s
|
| 37 |
+
GPU available: True (cuda), used: True
|
| 38 |
+
TPU available: False, using: 0 TPU cores
|
| 39 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 40 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 41 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 42 |
+
[chunk] 768/1012 mean=0.8111 throughput=2.97 seg/s
|
| 43 |
+
GPU available: True (cuda), used: True
|
| 44 |
+
TPU available: False, using: 0 TPU cores
|
| 45 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 46 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 47 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 48 |
+
[chunk] 896/1012 mean=0.8100 throughput=2.98 seg/s
|
| 49 |
+
GPU available: True (cuda), used: True
|
| 50 |
+
TPU available: False, using: 0 TPU cores
|
| 51 |
+
💡 Tip: For seamless cloud logging and experiment tracking, try installing [litlogger](https://pypi.org/project/litlogger/) to enable LitLogger, which logs metrics and artifacts automatically to the Lightning Experiments platform.
|
| 52 |
+
💡 Tip: For seamless cloud uploads and versioning, try installing [litmodels](https://pypi.org/project/litmodels/) to enable LitModelCheckpoint, which syncs automatically with the Lightning model registry.
|
| 53 |
+
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]
|
| 54 |
+
[chunk] 1012/1012 mean=0.8104 throughput=2.97 seg/s
|
| 55 |
+
[save] scored pool -> /root/runs/issue33_native_region/xcomet/r8_fixed_k160000.scored_pool.jsonl
|
| 56 |
+
[save] summary -> /root/runs/issue33_native_region/xcomet/r8_fixed_k160000.json
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifest.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"issue": 33,
|
| 3 |
+
"task": "Native selected-region EN->PT student training",
|
| 4 |
+
"run_root": "/root/runs/issue33_native_region",
|
| 5 |
+
"upload_prefix": "issue33_native_region_20260513T171458Z",
|
| 6 |
+
"summaries": {
|
| 7 |
+
"issue33_native_region_k160000_r8.json": {
|
| 8 |
+
"issue": 33,
|
| 9 |
+
"run_root": "/root/runs/issue33_native_region",
|
| 10 |
+
"k": 160000,
|
| 11 |
+
"rank": 8,
|
| 12 |
+
"rows": [
|
| 13 |
+
{
|
| 14 |
+
"condition": "base_selected_region_k160000",
|
| 15 |
+
"role": "initial selected-region baseline",
|
| 16 |
+
"xcomet": 0.6259405999205152,
|
| 17 |
+
"reference_xcomet": 0.6278288431,
|
| 18 |
+
"chrFpp": 46.99461052474228
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"condition": "best_trained_reference_issue28_r8",
|
| 22 |
+
"role": "comparison reference, not teacher",
|
| 23 |
+
"xcomet": 0.8103810173308426,
|
| 24 |
+
"reference_xcomet": 0.8145537329,
|
| 25 |
+
"chrFpp": 51.21928365554815
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"condition": "native_region_k160000_r8",
|
| 29 |
+
"role": "issue33 trained native selected-region student",
|
| 30 |
+
"xcomet": 0.7950550597565977,
|
| 31 |
+
"reference_xcomet": null,
|
| 32 |
+
"chrFpp": 50.97431297760433
|
| 33 |
+
}
|
| 34 |
+
],
|
| 35 |
+
"native_delta_vs_base_selected": 0.16911445983608253,
|
| 36 |
+
"native_delta_vs_best_trained_reference": -0.01532595757424482,
|
| 37 |
+
"pass_floor_for_continuation": true
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"file_count": 42,
|
| 41 |
+
"weights_policy": "Includes only experiment-native small checkpoints. Excludes upstream HY-MT/XCOMET weights, HF caches, API keys, and service tokens."
|
| 42 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/config.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"issue": 33,
|
| 3 |
+
"script": "train_native_region_delta_translation.py",
|
| 4 |
+
"args": {
|
| 5 |
+
"model": "tencent/HY-MT1.5-1.8B",
|
| 6 |
+
"jsonl": "/root/runs/issue33_native_region/data/flores_teacher_train_hyps.jsonl",
|
| 7 |
+
"fixed_mask": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 8 |
+
"out_dir": "/root/runs/issue33_native_region/students/native_k160000_r8",
|
| 9 |
+
"target_field": "model_hyp",
|
| 10 |
+
"target_language": "Portuguese",
|
| 11 |
+
"prompt_style": "hy_mt",
|
| 12 |
+
"device": "cuda",
|
| 13 |
+
"dtype": "bfloat16",
|
| 14 |
+
"seed": 33,
|
| 15 |
+
"max_rows": null,
|
| 16 |
+
"max_seq_length": 1024,
|
| 17 |
+
"n_calib": 128,
|
| 18 |
+
"mean_on": "full",
|
| 19 |
+
"rank": 8,
|
| 20 |
+
"epochs": 1.0,
|
| 21 |
+
"max_steps": null,
|
| 22 |
+
"batch_size": 2,
|
| 23 |
+
"grad_accum": 4,
|
| 24 |
+
"lr": 0.0002,
|
| 25 |
+
"weight_decay": 0.0,
|
| 26 |
+
"warmup_ratio": 0.05,
|
| 27 |
+
"max_grad_norm": 1.0,
|
| 28 |
+
"masked_kl_beta": 1.0,
|
| 29 |
+
"ce_beta": 0.2,
|
| 30 |
+
"kl_temperature": 1.0,
|
| 31 |
+
"kl_on": "answer",
|
| 32 |
+
"eval_every": 25,
|
| 33 |
+
"num_workers": 0
|
| 34 |
+
},
|
| 35 |
+
"n_rows": 1012,
|
| 36 |
+
"dropped_rows": 0,
|
| 37 |
+
"n_layers": 32,
|
| 38 |
+
"hidden_size": 2048,
|
| 39 |
+
"d_ffn": 6144,
|
| 40 |
+
"mask_kept": 160000,
|
| 41 |
+
"rank": 8,
|
| 42 |
+
"trainable_parameters": 5412864,
|
| 43 |
+
"total_steps": 127,
|
| 44 |
+
"warmup_steps": 6,
|
| 45 |
+
"logs": [],
|
| 46 |
+
"method": {
|
| 47 |
+
"student": "selected native MLP slices",
|
| 48 |
+
"selected_slice_edits": [
|
| 49 |
+
"gate_proj rows",
|
| 50 |
+
"up_proj rows",
|
| 51 |
+
"down_proj columns"
|
| 52 |
+
],
|
| 53 |
+
"nonselected_mlp_channels": "mean ablated at down_proj input",
|
| 54 |
+
"teacher_logits": "full unmasked base model",
|
| 55 |
+
"global_adapter": false,
|
| 56 |
+
"peft_lora": false,
|
| 57 |
+
"initial_state": "base selected-region masked circuit plus zero low-rank slice edits"
|
| 58 |
+
}
|
| 59 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/native_region_delta_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rank": 8,
|
| 3 |
+
"hidden_size": 2048,
|
| 4 |
+
"mask_path": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 5 |
+
"means_path": "/root/runs/issue33_native_region/students/native_k160000_r8/means.pt",
|
| 6 |
+
"trainable_parameters": 5412864,
|
| 7 |
+
"parameterization": "selected native MLP gate/up/down low-rank slice edits",
|
| 8 |
+
"model": "tencent/HY-MT1.5-1.8B",
|
| 9 |
+
"target_language": "Portuguese",
|
| 10 |
+
"prompt_style": "hy_mt",
|
| 11 |
+
"mask_kept": 160000,
|
| 12 |
+
"n_layers": 32,
|
| 13 |
+
"d_ffn": 6144
|
| 14 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/manifests/students/native_k160000_r8/train_summary.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"issue": 33,
|
| 3 |
+
"script": "train_native_region_delta_translation.py",
|
| 4 |
+
"args": {
|
| 5 |
+
"model": "tencent/HY-MT1.5-1.8B",
|
| 6 |
+
"jsonl": "/root/runs/issue33_native_region/data/flores_teacher_train_hyps.jsonl",
|
| 7 |
+
"fixed_mask": "/root/runs/issue33_native_region/hy_lora_conditions/masks/base_attr/relp_k160000.full.npz",
|
| 8 |
+
"out_dir": "/root/runs/issue33_native_region/students/native_k160000_r8",
|
| 9 |
+
"target_field": "model_hyp",
|
| 10 |
+
"target_language": "Portuguese",
|
| 11 |
+
"prompt_style": "hy_mt",
|
| 12 |
+
"device": "cuda",
|
| 13 |
+
"dtype": "bfloat16",
|
| 14 |
+
"seed": 33,
|
| 15 |
+
"max_rows": null,
|
| 16 |
+
"max_seq_length": 1024,
|
| 17 |
+
"n_calib": 128,
|
| 18 |
+
"mean_on": "full",
|
| 19 |
+
"rank": 8,
|
| 20 |
+
"epochs": 1.0,
|
| 21 |
+
"max_steps": null,
|
| 22 |
+
"batch_size": 2,
|
| 23 |
+
"grad_accum": 4,
|
| 24 |
+
"lr": 0.0002,
|
| 25 |
+
"weight_decay": 0.0,
|
| 26 |
+
"warmup_ratio": 0.05,
|
| 27 |
+
"max_grad_norm": 1.0,
|
| 28 |
+
"masked_kl_beta": 1.0,
|
| 29 |
+
"ce_beta": 0.2,
|
| 30 |
+
"kl_temperature": 1.0,
|
| 31 |
+
"kl_on": "answer",
|
| 32 |
+
"eval_every": 25,
|
| 33 |
+
"num_workers": 0
|
| 34 |
+
},
|
| 35 |
+
"n_rows": 1012,
|
| 36 |
+
"dropped_rows": 0,
|
| 37 |
+
"n_layers": 32,
|
| 38 |
+
"hidden_size": 2048,
|
| 39 |
+
"d_ffn": 6144,
|
| 40 |
+
"mask_kept": 160000,
|
| 41 |
+
"rank": 8,
|
| 42 |
+
"trainable_parameters": 5412864,
|
| 43 |
+
"total_steps": 127,
|
| 44 |
+
"warmup_steps": 6,
|
| 45 |
+
"logs": [
|
| 46 |
+
{
|
| 47 |
+
"step": 1,
|
| 48 |
+
"loss": 0.748046875,
|
| 49 |
+
"masked_kl": 0.607421875,
|
| 50 |
+
"ce": 0.7060546875,
|
| 51 |
+
"lr": 3.3333333333333335e-05,
|
| 52 |
+
"elapsed_s": 0.6507542133331299
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"step": 25,
|
| 56 |
+
"loss": 0.6422627766927084,
|
| 57 |
+
"masked_kl": 0.5158182779947916,
|
| 58 |
+
"ce": 0.6314798990885416,
|
| 59 |
+
"lr": 0.00018807712330634642,
|
| 60 |
+
"elapsed_s": 12.182272672653198
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"step": 50,
|
| 64 |
+
"loss": 0.46009765625,
|
| 65 |
+
"masked_kl": 0.36353515625,
|
| 66 |
+
"ce": 0.48236328125,
|
| 67 |
+
"lr": 0.00014154150130018866,
|
| 68 |
+
"elapsed_s": 23.924031734466553
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"step": 75,
|
| 72 |
+
"loss": 0.3659765625,
|
| 73 |
+
"masked_kl": 0.2878173828125,
|
| 74 |
+
"ce": 0.3909765625,
|
| 75 |
+
"lr": 7.810966761934053e-05,
|
| 76 |
+
"elapsed_s": 35.229416608810425
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"step": 100,
|
| 80 |
+
"loss": 0.367216796875,
|
| 81 |
+
"masked_kl": 0.2874072265625,
|
| 82 |
+
"ce": 0.3992724609375,
|
| 83 |
+
"lr": 2.3581308246275103e-05,
|
| 84 |
+
"elapsed_s": 45.786269187927246
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"step": 125,
|
| 88 |
+
"loss": 0.3673876953125,
|
| 89 |
+
"masked_kl": 0.286630859375,
|
| 90 |
+
"ce": 0.4037890625,
|
| 91 |
+
"lr": 1.3479116011769767e-07,
|
| 92 |
+
"elapsed_s": 57.23423790931702
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"step": 127,
|
| 96 |
+
"loss": 0.39501953125,
|
| 97 |
+
"masked_kl": 0.311279296875,
|
| 98 |
+
"ce": 0.4197998046875,
|
| 99 |
+
"lr": 0.0,
|
| 100 |
+
"elapsed_s": 58.13042879104614
|
| 101 |
+
}
|
| 102 |
+
],
|
| 103 |
+
"method": {
|
| 104 |
+
"student": "selected native MLP slices",
|
| 105 |
+
"selected_slice_edits": [
|
| 106 |
+
"gate_proj rows",
|
| 107 |
+
"up_proj rows",
|
| 108 |
+
"down_proj columns"
|
| 109 |
+
],
|
| 110 |
+
"nonselected_mlp_channels": "mean ablated at down_proj input",
|
| 111 |
+
"teacher_logits": "full unmasked base model",
|
| 112 |
+
"global_adapter": false,
|
| 113 |
+
"peft_lora": false,
|
| 114 |
+
"initial_state": "base selected-region masked circuit plus zero low-rank slice edits"
|
| 115 |
+
},
|
| 116 |
+
"elapsed_s": 58.131454944610596
|
| 117 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/notes/issue33_native_region_mvc.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue 33 Native Selected-Region MVC
|
| 2 |
+
|
| 3 |
+
Goal: train the selected EN->PT MLP region itself into a stronger masked-region
|
| 4 |
+
student. This run starts from the live base selected-region masked circuit, not a
|
| 5 |
+
fresh replacement writer and not a global LoRA adapter.
|
| 6 |
+
|
| 7 |
+
Pipeline:
|
| 8 |
+
|
| 9 |
+
```text
|
| 10 |
+
preserved ReLP k=160k mask
|
| 11 |
+
-> base masked-region anchor on NTREX
|
| 12 |
+
-> preserved best trained reference from issue #28 r8 for comparison
|
| 13 |
+
-> FLORES teacher-hyp rows from unmasked Tencent HY-MT
|
| 14 |
+
-> train rank-8 native selected-region slice edits
|
| 15 |
+
-> NTREX generation
|
| 16 |
+
-> XCOMET-XXL scoring
|
| 17 |
+
-> backup to TokenBender/synth-data-en-pt-circuit and TokenBender/circuit-discovery
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
The trainable object is a set of local low-rank edits over selected native MLP
|
| 21 |
+
slices:
|
| 22 |
+
|
| 23 |
+
- selected `gate_proj` output rows
|
| 24 |
+
- selected `up_proj` output rows
|
| 25 |
+
- selected `down_proj` input columns
|
| 26 |
+
|
| 27 |
+
During the masked objective and evaluation, selected MLP intermediate channels
|
| 28 |
+
stay live and non-selected MLP intermediate channels are replaced by their
|
| 29 |
+
calibration mean at the `down_proj` input. The full unmasked base model supplies
|
| 30 |
+
teacher logits for distillation. The best trained reference from issue #28 r8 is
|
| 31 |
+
only a comparison point.
|
| 32 |
+
|
| 33 |
+
First-pass continuation rule: continue beyond rank 8 only if the native student
|
| 34 |
+
beats the reproduced base selected-region baseline by at least `+0.03` XCOMET.
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/evaluate_native_region_delta_translation.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Evaluate a native selected-region EN->PT student under its fixed mask."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import json
|
| 8 |
+
import time
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
import sacrebleu
|
| 12 |
+
import torch
|
| 13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 14 |
+
|
| 15 |
+
from translation_io import DEFAULT_PROMPT_STYLE, Pair, generate_translations, load_flores_devtest_any
|
| 16 |
+
from translation_native_region import load_native_region_delta
|
| 17 |
+
from translation_region_student import count_mask, load_mask_npz, text_config
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def parse_args() -> argparse.Namespace:
|
| 21 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 22 |
+
p.add_argument("--model", required=True)
|
| 23 |
+
p.add_argument("--student-dir", required=True)
|
| 24 |
+
p.add_argument("--mask", required=True)
|
| 25 |
+
p.add_argument("--out", required=True)
|
| 26 |
+
p.add_argument("--dump-hyps", required=True)
|
| 27 |
+
p.add_argument("--device", default="cuda")
|
| 28 |
+
p.add_argument("--dtype", default="bfloat16", choices=["float32", "float16", "bfloat16"])
|
| 29 |
+
p.add_argument("--target-language", default="Portuguese")
|
| 30 |
+
p.add_argument("--prompt-style", default=DEFAULT_PROMPT_STYLE)
|
| 31 |
+
p.add_argument("--src-lang", default="eng_Latn")
|
| 32 |
+
p.add_argument("--tgt-lang", default="por_Latn")
|
| 33 |
+
p.add_argument("--input-jsonl", default=None)
|
| 34 |
+
p.add_argument("--max-examples", type=int, default=None)
|
| 35 |
+
p.add_argument("--batch-size", type=int, default=8)
|
| 36 |
+
p.add_argument("--max-new-tokens", type=int, default=384)
|
| 37 |
+
p.add_argument("--category", default="ntrex_test")
|
| 38 |
+
p.add_argument("--tag", default="heldout")
|
| 39 |
+
p.add_argument("--mask-name", default=None)
|
| 40 |
+
return p.parse_args()
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def dtype_from_name(name: str) -> torch.dtype:
|
| 44 |
+
return {
|
| 45 |
+
"float32": torch.float32,
|
| 46 |
+
"float16": torch.float16,
|
| 47 |
+
"bfloat16": torch.bfloat16,
|
| 48 |
+
}[name]
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def load_pairs(path: str | None, *, src_lang: str, tgt_lang: str,
|
| 52 |
+
max_examples: int | None) -> list[Pair]:
|
| 53 |
+
if path is None:
|
| 54 |
+
return load_flores_devtest_any(
|
| 55 |
+
src_lang=src_lang,
|
| 56 |
+
tgt_lang=tgt_lang,
|
| 57 |
+
max_examples=max_examples,
|
| 58 |
+
)
|
| 59 |
+
pairs: list[Pair] = []
|
| 60 |
+
with Path(path).open() as f:
|
| 61 |
+
for line in f:
|
| 62 |
+
if not line.strip():
|
| 63 |
+
continue
|
| 64 |
+
row = json.loads(line)
|
| 65 |
+
src = row.get("en") or row.get("src")
|
| 66 |
+
tgt = row.get("pt") or row.get("tgt")
|
| 67 |
+
if src and tgt:
|
| 68 |
+
pairs.append(Pair(src=src, tgt=tgt))
|
| 69 |
+
if max_examples is not None and len(pairs) >= max_examples:
|
| 70 |
+
break
|
| 71 |
+
return pairs
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def main() -> None:
|
| 75 |
+
args = parse_args()
|
| 76 |
+
dtype = dtype_from_name(args.dtype)
|
| 77 |
+
out_path = Path(args.out)
|
| 78 |
+
dump_path = Path(args.dump_hyps)
|
| 79 |
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
| 80 |
+
dump_path.parent.mkdir(parents=True, exist_ok=True)
|
| 81 |
+
|
| 82 |
+
tokenizer = AutoTokenizer.from_pretrained(args.model)
|
| 83 |
+
if tokenizer.pad_token_id is None:
|
| 84 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 85 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 86 |
+
args.model,
|
| 87 |
+
dtype=dtype,
|
| 88 |
+
attn_implementation="eager",
|
| 89 |
+
).to(args.device).eval()
|
| 90 |
+
model.config.use_cache = True
|
| 91 |
+
for param in model.parameters():
|
| 92 |
+
param.requires_grad_(False)
|
| 93 |
+
|
| 94 |
+
cfg = text_config(model)
|
| 95 |
+
n_layers = int(cfg.num_hidden_layers)
|
| 96 |
+
hidden_size = int(cfg.hidden_size)
|
| 97 |
+
d_ffn = int(cfg.intermediate_size)
|
| 98 |
+
mask = load_mask_npz(args.mask, n_layers, d_ffn)
|
| 99 |
+
kept = count_mask(mask)
|
| 100 |
+
means = torch.load(Path(args.student_dir) / "means.pt", map_location="cpu")
|
| 101 |
+
controller = load_native_region_delta(
|
| 102 |
+
args.student_dir,
|
| 103 |
+
mask=mask,
|
| 104 |
+
means=means,
|
| 105 |
+
hidden_size=hidden_size,
|
| 106 |
+
map_location="cpu",
|
| 107 |
+
).to(args.device).eval()
|
| 108 |
+
|
| 109 |
+
pairs = load_pairs(
|
| 110 |
+
args.input_jsonl,
|
| 111 |
+
src_lang=args.src_lang,
|
| 112 |
+
tgt_lang=args.tgt_lang,
|
| 113 |
+
max_examples=args.max_examples,
|
| 114 |
+
)
|
| 115 |
+
sources = [pair.src for pair in pairs]
|
| 116 |
+
refs = [pair.tgt for pair in pairs]
|
| 117 |
+
|
| 118 |
+
t0 = time.time()
|
| 119 |
+
hooks = controller.install(model)
|
| 120 |
+
try:
|
| 121 |
+
hyps = generate_translations(
|
| 122 |
+
model,
|
| 123 |
+
tokenizer,
|
| 124 |
+
sources,
|
| 125 |
+
target_language=args.target_language,
|
| 126 |
+
prompt_style=args.prompt_style,
|
| 127 |
+
batch_size=args.batch_size,
|
| 128 |
+
max_new_tokens=args.max_new_tokens,
|
| 129 |
+
do_sample=False,
|
| 130 |
+
device=args.device,
|
| 131 |
+
)
|
| 132 |
+
finally:
|
| 133 |
+
for hook in hooks:
|
| 134 |
+
hook.remove()
|
| 135 |
+
elapsed_s = time.time() - t0
|
| 136 |
+
|
| 137 |
+
with dump_path.open("w") as f:
|
| 138 |
+
for i, (src, ref, hyp) in enumerate(zip(sources, refs, hyps)):
|
| 139 |
+
f.write(json.dumps({
|
| 140 |
+
"id": i,
|
| 141 |
+
"en": src,
|
| 142 |
+
"pt": ref,
|
| 143 |
+
"model_hyp": hyp,
|
| 144 |
+
"category": args.category,
|
| 145 |
+
"tag": args.tag,
|
| 146 |
+
"mask_name": args.mask_name or Path(args.mask).stem,
|
| 147 |
+
"student_dir": args.student_dir,
|
| 148 |
+
"rank": int(controller.rank),
|
| 149 |
+
"kept": kept,
|
| 150 |
+
"method": "native_selected_region_delta",
|
| 151 |
+
}, ensure_ascii=False) + "\n")
|
| 152 |
+
|
| 153 |
+
scores = {
|
| 154 |
+
"chrFpp": sacrebleu.corpus_chrf(hyps, [refs], word_order=2).score,
|
| 155 |
+
"chrF": sacrebleu.corpus_chrf(hyps, [refs], word_order=0).score,
|
| 156 |
+
"BLEU": sacrebleu.corpus_bleu(hyps, [refs]).score,
|
| 157 |
+
"n": len(hyps),
|
| 158 |
+
}
|
| 159 |
+
payload = {
|
| 160 |
+
"model": args.model,
|
| 161 |
+
"student_dir": args.student_dir,
|
| 162 |
+
"mask": args.mask,
|
| 163 |
+
"mask_kept": kept,
|
| 164 |
+
"rank": int(controller.rank),
|
| 165 |
+
"n_layers": n_layers,
|
| 166 |
+
"d_ffn": d_ffn,
|
| 167 |
+
"scores": scores,
|
| 168 |
+
"dump_hyps": str(dump_path),
|
| 169 |
+
"elapsed_s": elapsed_s,
|
| 170 |
+
"method": "native_selected_region_delta",
|
| 171 |
+
}
|
| 172 |
+
out_path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n")
|
| 173 |
+
print(json.dumps(payload, indent=2, ensure_ascii=False), flush=True)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__":
|
| 177 |
+
main()
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/issue33_native_region_runner.sh
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Issue #33 native selected-region EN->PT student runner.
|
| 3 |
+
set -euo pipefail
|
| 4 |
+
|
| 5 |
+
export PATH="/root/.local/bin:$PATH"
|
| 6 |
+
REPO_DIR="${REPO_DIR:-/root/work/circuit-shotting}"
|
| 7 |
+
cd "$REPO_DIR"
|
| 8 |
+
source .venv/bin/activate
|
| 9 |
+
|
| 10 |
+
MODEL="${MODEL:-tencent/HY-MT1.5-1.8B}"
|
| 11 |
+
ARTIFACT_REPO="${ARTIFACT_REPO:-Occupying-Mars/hy-lora-conditions}"
|
| 12 |
+
RUN_ROOT="${RUN_ROOT:-/root/runs/issue33_native_region}"
|
| 13 |
+
ARTIFACT_DIR="${ARTIFACT_DIR:-$RUN_ROOT/hy_lora_conditions}"
|
| 14 |
+
FLORES_JSONL="${FLORES_JSONL:-/root/runs/flores_eval/flores_en2pt_devtest.jsonl}"
|
| 15 |
+
TRAIN_JSONL="${TRAIN_JSONL:-$RUN_ROOT/data/flores_teacher_train_hyps.jsonl}"
|
| 16 |
+
NTREX_JSONL="${NTREX_JSONL:-/root/runs/ntrex_eval/ntrex_en2pt.jsonl}"
|
| 17 |
+
K="${K:-160000}"
|
| 18 |
+
SHORT_K="${SHORT_K:-$((K / 1000))}"
|
| 19 |
+
MASK="${MASK:-$ARTIFACT_DIR/masks/base_attr/relp_k${K}.full.npz}"
|
| 20 |
+
RANKS="${RANKS:-8}"
|
| 21 |
+
GPU_LIST="${GPU_LIST:-0 1}"
|
| 22 |
+
XCOMET_MODE="${XCOMET_MODE:-service}" # service | direct | skip
|
| 23 |
+
XCOMET_MODEL="${XCOMET_MODEL:-Unbabel/XCOMET-XXL}"
|
| 24 |
+
SCORE_AFTER="${SCORE_AFTER:-1}"
|
| 25 |
+
UPLOAD_AFTER="${UPLOAD_AFTER:-1}"
|
| 26 |
+
ISSUE33_USE_PLAIN_PYTHON="${ISSUE33_USE_PLAIN_PYTHON:-0}"
|
| 27 |
+
|
| 28 |
+
mkdir -p "$RUN_ROOT"/{data,eval,dumps,xcomet,students,logs,summaries} "$ARTIFACT_DIR"
|
| 29 |
+
|
| 30 |
+
mark() {
|
| 31 |
+
echo "[$(date -Iseconds)] $*" | tee -a "$RUN_ROOT/logs/progress.log"
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
run_python() {
|
| 35 |
+
if [[ "$ISSUE33_USE_PLAIN_PYTHON" == "1" || "$ISSUE33_USE_PLAIN_PYTHON" == "true" ]]; then
|
| 36 |
+
python "$@"
|
| 37 |
+
else
|
| 38 |
+
uv run python "$@"
|
| 39 |
+
fi
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
pick_gpu() {
|
| 43 |
+
local idx="$1"
|
| 44 |
+
python - "$GPU_LIST" "$idx" <<'PY'
|
| 45 |
+
import sys
|
| 46 |
+
gpus=[g for g in sys.argv[1].replace(",", " ").split() if g]
|
| 47 |
+
if not gpus:
|
| 48 |
+
gpus=["0"]
|
| 49 |
+
print(gpus[int(sys.argv[2]) % len(gpus)])
|
| 50 |
+
PY
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
extra_train_args=()
|
| 54 |
+
if [[ -n "${MAX_ROWS:-}" ]]; then extra_train_args+=(--max-rows "$MAX_ROWS"); fi
|
| 55 |
+
if [[ -n "${MAX_STEPS:-}" ]]; then extra_train_args+=(--max-steps "$MAX_STEPS"); fi
|
| 56 |
+
|
| 57 |
+
score_jsonl() {
|
| 58 |
+
local hyps_jsonl="$1"
|
| 59 |
+
local out_json="$2"
|
| 60 |
+
local request_id="$3"
|
| 61 |
+
local system_name="$4"
|
| 62 |
+
local log_path="$5"
|
| 63 |
+
|
| 64 |
+
[[ -f "$hyps_jsonl" ]] || {
|
| 65 |
+
echo "[issue33] missing hyps jsonl: $hyps_jsonl" >&2
|
| 66 |
+
return 1
|
| 67 |
+
}
|
| 68 |
+
[[ -f "$out_json" ]] && return 0
|
| 69 |
+
if [[ "$XCOMET_MODE" == "skip" ]]; then
|
| 70 |
+
mark "skip XCOMET for $system_name"
|
| 71 |
+
return 0
|
| 72 |
+
fi
|
| 73 |
+
if [[ "$XCOMET_MODE" == "service" ]]; then
|
| 74 |
+
run_python score_xcomet_service_client.py \
|
| 75 |
+
--hyps-jsonl "$hyps_jsonl" \
|
| 76 |
+
--out-json "$out_json" \
|
| 77 |
+
--request-id "$request_id" \
|
| 78 |
+
--system-name "$system_name" \
|
| 79 |
+
--batch-size "${XCOMET_BATCH_SIZE:-8}" \
|
| 80 |
+
--chunk-size "${XCOMET_CHUNK_SIZE:-128}" \
|
| 81 |
+
--timeout-s "${XCOMET_TIMEOUT_S:-7200}" \
|
| 82 |
+
> "$log_path" 2>&1
|
| 83 |
+
return 0
|
| 84 |
+
fi
|
| 85 |
+
if [[ "$XCOMET_MODE" == "direct" ]]; then
|
| 86 |
+
run_python score_xcomet_pool.py \
|
| 87 |
+
--hyps-jsonl "$hyps_jsonl" \
|
| 88 |
+
--out-jsonl "${out_json%.json}.scored_pool.jsonl" \
|
| 89 |
+
--summary-json "$out_json" \
|
| 90 |
+
--comet-model "$XCOMET_MODEL" \
|
| 91 |
+
--system-name "$system_name" \
|
| 92 |
+
--batch-size "${XCOMET_BATCH_SIZE:-8}" \
|
| 93 |
+
--chunk-size "${XCOMET_CHUNK_SIZE:-128}" \
|
| 94 |
+
> "$log_path" 2>&1
|
| 95 |
+
return 0
|
| 96 |
+
fi
|
| 97 |
+
echo "[issue33] unknown XCOMET_MODE=$XCOMET_MODE" >&2
|
| 98 |
+
return 1
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
mark "issue33 start model=$MODEL k=$K ranks=$RANKS xcomet_mode=$XCOMET_MODE"
|
| 102 |
+
|
| 103 |
+
if [[ ! -f "$MASK" ]]; then
|
| 104 |
+
mark "download preserved mask/reference adapters from $ARTIFACT_REPO"
|
| 105 |
+
run_python - "$ARTIFACT_REPO" "$ARTIFACT_DIR" "$K" "$SHORT_K" <<'PY' \
|
| 106 |
+
2>&1 | tee "$RUN_ROOT/logs/download_hy_lora_conditions.log"
|
| 107 |
+
import sys
|
| 108 |
+
from huggingface_hub import snapshot_download
|
| 109 |
+
|
| 110 |
+
repo, local_dir, k, short_k = sys.argv[1:5]
|
| 111 |
+
patterns = [
|
| 112 |
+
"README.md",
|
| 113 |
+
"manifest.json",
|
| 114 |
+
f"low_rank_lens/k{short_k}_r8/adapter/*",
|
| 115 |
+
f"low_rank_lens/k{short_k}_r8/config.json",
|
| 116 |
+
f"low_rank_lens/k{short_k}_r8/train_summary.json",
|
| 117 |
+
f"masks/base_attr/relp_k{k}.full.npz",
|
| 118 |
+
]
|
| 119 |
+
print(snapshot_download(
|
| 120 |
+
repo_id=repo,
|
| 121 |
+
repo_type="model",
|
| 122 |
+
local_dir=local_dir,
|
| 123 |
+
allow_patterns=patterns,
|
| 124 |
+
))
|
| 125 |
+
PY
|
| 126 |
+
fi
|
| 127 |
+
|
| 128 |
+
if [[ ! -f "$MASK" ]]; then
|
| 129 |
+
echo "missing fixed mask: $MASK" >&2
|
| 130 |
+
exit 2
|
| 131 |
+
fi
|
| 132 |
+
|
| 133 |
+
if [[ ! -f "$FLORES_JSONL" ]]; then
|
| 134 |
+
mark "build FLORES EN->PT devtest jsonl"
|
| 135 |
+
run_python build_flores_en2pt_jsonl.py 2>&1 | tee "$RUN_ROOT/logs/build_flores.log"
|
| 136 |
+
fi
|
| 137 |
+
|
| 138 |
+
if [[ ! -f "$NTREX_JSONL" ]]; then
|
| 139 |
+
mark "build NTREX EN->PT held-out jsonl"
|
| 140 |
+
run_python build_ntrex_en2pt_jsonl.py 2>&1 | tee "$RUN_ROOT/logs/build_ntrex.log"
|
| 141 |
+
fi
|
| 142 |
+
|
| 143 |
+
if [[ ! -f "$TRAIN_JSONL" ]]; then
|
| 144 |
+
mark "generate FLORES teacher-hyp train data"
|
| 145 |
+
CUDA_VISIBLE_DEVICES="$(pick_gpu 0)" run_python gen_translations_only.py \
|
| 146 |
+
--jsonl "$FLORES_JSONL" \
|
| 147 |
+
--model "$MODEL" \
|
| 148 |
+
--out "$TRAIN_JSONL" \
|
| 149 |
+
--target-language Portuguese \
|
| 150 |
+
--batch-size "${TEACHER_BATCH_SIZE:-16}" \
|
| 151 |
+
--max-new-tokens "${MAX_NEW_TOKENS:-384}" \
|
| 152 |
+
2>&1 | tee "$RUN_ROOT/logs/generate_flores_teacher_hyps.log"
|
| 153 |
+
fi
|
| 154 |
+
|
| 155 |
+
if [[ ! -f "$RUN_ROOT/eval/base_k${K}_masks.json" ]]; then
|
| 156 |
+
mark "evaluate base selected-region anchor"
|
| 157 |
+
CUDA_VISIBLE_DEVICES="$(pick_gpu 0)" run_python evaluate_translation_adapter_masks.py \
|
| 158 |
+
--base-model "$MODEL" \
|
| 159 |
+
--input-jsonl "$NTREX_JSONL" \
|
| 160 |
+
--mask "fixed_k${K}:$MASK" \
|
| 161 |
+
--out "$RUN_ROOT/eval/base_k${K}_masks.json" \
|
| 162 |
+
--target-language Portuguese \
|
| 163 |
+
--include-no-mask \
|
| 164 |
+
--dump-hyps-dir "$RUN_ROOT/dumps/base_k${K}" \
|
| 165 |
+
--dump-category ntrex_test \
|
| 166 |
+
--dump-tag heldout \
|
| 167 |
+
--batch-size "${EVAL_BATCH_SIZE:-16}" \
|
| 168 |
+
--max-new-tokens "${MAX_NEW_TOKENS:-384}" \
|
| 169 |
+
2>&1 | tee "$RUN_ROOT/logs/eval_base_k${K}.log"
|
| 170 |
+
fi
|
| 171 |
+
|
| 172 |
+
if [[ ! -f "$RUN_ROOT/eval/r8_k${K}_masks.json" ]]; then
|
| 173 |
+
mark "evaluate best trained reference from issue #28 r8 for comparison"
|
| 174 |
+
ADAPTER="$ARTIFACT_DIR/low_rank_lens/k${SHORT_K}_r8/adapter"
|
| 175 |
+
[[ -f "$ADAPTER/adapter_model.safetensors" ]] || {
|
| 176 |
+
echo "missing reference adapter: $ADAPTER" >&2
|
| 177 |
+
exit 3
|
| 178 |
+
}
|
| 179 |
+
CUDA_VISIBLE_DEVICES="$(pick_gpu 1)" run_python evaluate_translation_adapter_masks.py \
|
| 180 |
+
--base-model "$MODEL" \
|
| 181 |
+
--adapter "$ADAPTER" \
|
| 182 |
+
--input-jsonl "$NTREX_JSONL" \
|
| 183 |
+
--mask "fixed_k${K}:$MASK" \
|
| 184 |
+
--out "$RUN_ROOT/eval/r8_k${K}_masks.json" \
|
| 185 |
+
--target-language Portuguese \
|
| 186 |
+
--include-no-mask \
|
| 187 |
+
--dump-hyps-dir "$RUN_ROOT/dumps/r8_k${K}" \
|
| 188 |
+
--dump-category ntrex_test \
|
| 189 |
+
--dump-tag heldout \
|
| 190 |
+
--batch-size "${EVAL_BATCH_SIZE:-16}" \
|
| 191 |
+
--max-new-tokens "${MAX_NEW_TOKENS:-384}" \
|
| 192 |
+
2>&1 | tee "$RUN_ROOT/logs/eval_r8_k${K}.log"
|
| 193 |
+
fi
|
| 194 |
+
|
| 195 |
+
for rank in $RANKS; do
|
| 196 |
+
student_dir="$RUN_ROOT/students/native_k${K}_r${rank}"
|
| 197 |
+
if [[ ! -f "$student_dir/train_summary.json" ]]; then
|
| 198 |
+
mark "train native selected-region student k=$K rank=$rank"
|
| 199 |
+
mkdir -p "$student_dir"
|
| 200 |
+
CUDA_VISIBLE_DEVICES="$(pick_gpu 0)" run_python train_native_region_delta_translation.py \
|
| 201 |
+
--model "$MODEL" \
|
| 202 |
+
--jsonl "$TRAIN_JSONL" \
|
| 203 |
+
--fixed-mask "$MASK" \
|
| 204 |
+
--out-dir "$student_dir" \
|
| 205 |
+
--target-field model_hyp \
|
| 206 |
+
--target-language Portuguese \
|
| 207 |
+
--rank "$rank" \
|
| 208 |
+
--batch-size "${BATCH_SIZE:-1}" \
|
| 209 |
+
--grad-accum "${GRAD_ACCUM:-8}" \
|
| 210 |
+
--epochs "${EPOCHS:-1.0}" \
|
| 211 |
+
--lr "${LR:-2e-4}" \
|
| 212 |
+
--masked-kl-beta "${MASKED_KL_BETA:-1.0}" \
|
| 213 |
+
--ce-beta "${CE_BETA:-0.2}" \
|
| 214 |
+
--n-calib "${N_CALIB:-128}" \
|
| 215 |
+
--eval-every "${EVAL_EVERY:-25}" \
|
| 216 |
+
"${extra_train_args[@]}" \
|
| 217 |
+
> "$RUN_ROOT/logs/train_native_region_k${K}_r${rank}.log" 2>&1
|
| 218 |
+
fi
|
| 219 |
+
|
| 220 |
+
eval_json="$RUN_ROOT/eval/native_region_k${K}_r${rank}.json"
|
| 221 |
+
dump_jsonl="$RUN_ROOT/dumps/native_region_k${K}_r${rank}.jsonl"
|
| 222 |
+
if [[ ! -f "$eval_json" ]]; then
|
| 223 |
+
mark "evaluate native selected-region student k=$K rank=$rank"
|
| 224 |
+
CUDA_VISIBLE_DEVICES="$(pick_gpu 1)" run_python evaluate_native_region_delta_translation.py \
|
| 225 |
+
--model "$MODEL" \
|
| 226 |
+
--student-dir "$student_dir" \
|
| 227 |
+
--mask "$MASK" \
|
| 228 |
+
--input-jsonl "$NTREX_JSONL" \
|
| 229 |
+
--out "$eval_json" \
|
| 230 |
+
--dump-hyps "$dump_jsonl" \
|
| 231 |
+
--target-language Portuguese \
|
| 232 |
+
--batch-size "${EVAL_BATCH_SIZE:-8}" \
|
| 233 |
+
--max-new-tokens "${MAX_NEW_TOKENS:-384}" \
|
| 234 |
+
--mask-name "native_region_k${K}_r${rank}" \
|
| 235 |
+
> "$RUN_ROOT/logs/eval_native_region_k${K}_r${rank}.log" 2>&1
|
| 236 |
+
fi
|
| 237 |
+
done
|
| 238 |
+
|
| 239 |
+
if [[ "$SCORE_AFTER" == "1" || "$SCORE_AFTER" == "true" ]]; then
|
| 240 |
+
mark "score base selected-region anchor"
|
| 241 |
+
score_jsonl \
|
| 242 |
+
"$RUN_ROOT/dumps/base_k${K}/fixed_k${K}.jsonl" \
|
| 243 |
+
"$RUN_ROOT/xcomet/base_fixed_k${K}.json" \
|
| 244 |
+
"issue33_base_fixed_k${K}" \
|
| 245 |
+
"issue33_base_fixed_k${K}" \
|
| 246 |
+
"$RUN_ROOT/logs/xcomet_base_fixed_k${K}.log"
|
| 247 |
+
|
| 248 |
+
mark "score best trained reference from issue #28 r8"
|
| 249 |
+
score_jsonl \
|
| 250 |
+
"$RUN_ROOT/dumps/r8_k${K}/fixed_k${K}.jsonl" \
|
| 251 |
+
"$RUN_ROOT/xcomet/r8_fixed_k${K}.json" \
|
| 252 |
+
"issue33_r8_fixed_k${K}" \
|
| 253 |
+
"issue33_r8_fixed_k${K}" \
|
| 254 |
+
"$RUN_ROOT/logs/xcomet_r8_fixed_k${K}.log"
|
| 255 |
+
|
| 256 |
+
for rank in $RANKS; do
|
| 257 |
+
mark "score native selected-region student k=$K rank=$rank"
|
| 258 |
+
score_jsonl \
|
| 259 |
+
"$RUN_ROOT/dumps/native_region_k${K}_r${rank}.jsonl" \
|
| 260 |
+
"$RUN_ROOT/xcomet/native_region_k${K}_r${rank}.json" \
|
| 261 |
+
"issue33_native_region_k${K}_r${rank}" \
|
| 262 |
+
"issue33_native_region_k${K}_r${rank}" \
|
| 263 |
+
"$RUN_ROOT/logs/xcomet_native_region_k${K}_r${rank}.log"
|
| 264 |
+
done
|
| 265 |
+
fi
|
| 266 |
+
|
| 267 |
+
for rank in $RANKS; do
|
| 268 |
+
mark "summarize issue33 k=$K rank=$rank"
|
| 269 |
+
run_python summarize_issue33_native_region.py \
|
| 270 |
+
--run-root "$RUN_ROOT" \
|
| 271 |
+
--k "$K" \
|
| 272 |
+
--rank "$rank" \
|
| 273 |
+
--out-json "$RUN_ROOT/summaries/issue33_native_region_k${K}_r${rank}.json" \
|
| 274 |
+
--out-md "$RUN_ROOT/summaries/issue33_native_region_k${K}_r${rank}.md" \
|
| 275 |
+
2>&1 | tee "$RUN_ROOT/logs/summarize_issue33_k${K}_r${rank}.log"
|
| 276 |
+
done
|
| 277 |
+
|
| 278 |
+
if [[ "$UPLOAD_AFTER" == "1" || "$UPLOAD_AFTER" == "true" ]]; then
|
| 279 |
+
mark "package and upload issue33 artifacts"
|
| 280 |
+
RUN_ROOT="$RUN_ROOT" REPO_DIR="$REPO_DIR" scripts/package_issue33_hf_upload.sh \
|
| 281 |
+
2>&1 | tee "$RUN_ROOT/logs/package_issue33_hf_upload.log"
|
| 282 |
+
fi
|
| 283 |
+
|
| 284 |
+
mark "issue33 done"
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/package_issue33_hf_upload.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Package and upload issue #33 native selected-region student artifacts.
|
| 3 |
+
set -euo pipefail
|
| 4 |
+
|
| 5 |
+
RUN_ROOT="${RUN_ROOT:-/root/runs/issue33_native_region}"
|
| 6 |
+
REPO_DIR="${REPO_DIR:-/root/work/circuit-shotting}"
|
| 7 |
+
HF_REPO="${HF_REPO:-TokenBender/synth-data-en-pt-circuit}"
|
| 8 |
+
CIRCUIT_HF_REPO="${CIRCUIT_HF_REPO:-TokenBender/circuit-discovery}"
|
| 9 |
+
UPLOAD_ROOT="${UPLOAD_ROOT:-$RUN_ROOT/hf_upload}"
|
| 10 |
+
STAMP="${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}"
|
| 11 |
+
UPLOAD_PREFIX="${UPLOAD_PREFIX:-issue33_native_region_$STAMP}"
|
| 12 |
+
UPLOAD_CHECKPOINTS="${UPLOAD_CHECKPOINTS:-1}"
|
| 13 |
+
UPLOAD_DIR="$UPLOAD_ROOT/$UPLOAD_PREFIX"
|
| 14 |
+
ISSUE33_USE_PLAIN_PYTHON="${ISSUE33_USE_PLAIN_PYTHON:-0}"
|
| 15 |
+
|
| 16 |
+
run_hf() {
|
| 17 |
+
if [[ "$ISSUE33_USE_PLAIN_PYTHON" == "1" || "$ISSUE33_USE_PLAIN_PYTHON" == "true" ]]; then
|
| 18 |
+
hf "$@"
|
| 19 |
+
else
|
| 20 |
+
uv run hf "$@"
|
| 21 |
+
fi
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
mkdir -p "$UPLOAD_DIR"/{spec,notes,scripts,data,eval,dumps,xcomet,summaries,logs,manifests}
|
| 25 |
+
|
| 26 |
+
cp "$REPO_DIR/configs/native_region_mvc_issue33.json" "$UPLOAD_DIR/spec/"
|
| 27 |
+
cp "$REPO_DIR/notes/issue33_native_region_mvc.md" "$UPLOAD_DIR/notes/"
|
| 28 |
+
cp "$REPO_DIR/issue33_native_region_runner.sh" "$UPLOAD_DIR/scripts/"
|
| 29 |
+
cp "$REPO_DIR/train_native_region_delta_translation.py" "$UPLOAD_DIR/scripts/"
|
| 30 |
+
cp "$REPO_DIR/evaluate_native_region_delta_translation.py" "$UPLOAD_DIR/scripts/"
|
| 31 |
+
cp "$REPO_DIR/translation_native_region.py" "$UPLOAD_DIR/scripts/"
|
| 32 |
+
cp "$REPO_DIR/summarize_issue33_native_region.py" "$UPLOAD_DIR/scripts/"
|
| 33 |
+
cp "$REPO_DIR/scripts/package_issue33_hf_upload.sh" "$UPLOAD_DIR/scripts/"
|
| 34 |
+
|
| 35 |
+
cp "$RUN_ROOT"/data/*.jsonl "$UPLOAD_DIR/data/" 2>/dev/null || true
|
| 36 |
+
cp "$RUN_ROOT"/eval/*.json "$UPLOAD_DIR/eval/" 2>/dev/null || true
|
| 37 |
+
find "$RUN_ROOT/dumps" -type f -name '*.jsonl' -exec cp {} "$UPLOAD_DIR/dumps/" \; 2>/dev/null || true
|
| 38 |
+
cp "$RUN_ROOT"/xcomet/*.json "$UPLOAD_DIR/xcomet/" 2>/dev/null || true
|
| 39 |
+
cp "$RUN_ROOT"/xcomet/*.jsonl "$UPLOAD_DIR/xcomet/" 2>/dev/null || true
|
| 40 |
+
cp "$RUN_ROOT"/summaries/* "$UPLOAD_DIR/summaries/" 2>/dev/null || true
|
| 41 |
+
cp "$RUN_ROOT"/logs/*.log "$UPLOAD_DIR/logs/" 2>/dev/null || true
|
| 42 |
+
|
| 43 |
+
if [[ -d "$RUN_ROOT/students" ]]; then
|
| 44 |
+
find "$RUN_ROOT/students" \( -name 'train_summary.json' -o -name 'config.json' -o -name 'native_region_delta_config.json' \) \
|
| 45 |
+
| while read -r path; do
|
| 46 |
+
rel="${path#$RUN_ROOT/}"
|
| 47 |
+
mkdir -p "$UPLOAD_DIR/manifests/$(dirname "$rel")"
|
| 48 |
+
cp "$path" "$UPLOAD_DIR/manifests/$rel"
|
| 49 |
+
done
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
+
if [[ "$UPLOAD_CHECKPOINTS" == "1" || "$UPLOAD_CHECKPOINTS" == "true" ]]; then
|
| 53 |
+
if [[ -d "$RUN_ROOT/students" ]]; then
|
| 54 |
+
find "$RUN_ROOT/students" -name 'native_region_delta.pt' \
|
| 55 |
+
| while read -r path; do
|
| 56 |
+
rel="${path#$RUN_ROOT/}"
|
| 57 |
+
mkdir -p "$UPLOAD_DIR/checkpoints/$(dirname "$rel")"
|
| 58 |
+
cp "$path" "$UPLOAD_DIR/checkpoints/$rel"
|
| 59 |
+
done
|
| 60 |
+
fi
|
| 61 |
+
fi
|
| 62 |
+
|
| 63 |
+
python - "$UPLOAD_DIR" "$RUN_ROOT" "$UPLOAD_PREFIX" <<'PY'
|
| 64 |
+
import json
|
| 65 |
+
import os
|
| 66 |
+
import sys
|
| 67 |
+
from pathlib import Path
|
| 68 |
+
|
| 69 |
+
upload = Path(sys.argv[1])
|
| 70 |
+
run_root = Path(sys.argv[2])
|
| 71 |
+
prefix = sys.argv[3]
|
| 72 |
+
|
| 73 |
+
def maybe_json(path: Path):
|
| 74 |
+
return json.loads(path.read_text()) if path.exists() else None
|
| 75 |
+
|
| 76 |
+
summaries = {
|
| 77 |
+
path.name: maybe_json(path)
|
| 78 |
+
for path in sorted((run_root / "summaries").glob("issue33_native_region_*.json"))
|
| 79 |
+
}
|
| 80 |
+
manifest = {
|
| 81 |
+
"issue": 33,
|
| 82 |
+
"task": "Native selected-region EN->PT student training",
|
| 83 |
+
"run_root": str(run_root),
|
| 84 |
+
"upload_prefix": prefix,
|
| 85 |
+
"summaries": summaries,
|
| 86 |
+
"file_count": sum(len(files) for _, _, files in os.walk(upload)),
|
| 87 |
+
"weights_policy": "Includes only experiment-native small checkpoints. Excludes upstream HY-MT/XCOMET weights, HF caches, API keys, and service tokens.",
|
| 88 |
+
}
|
| 89 |
+
(upload / "manifest.json").write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n")
|
| 90 |
+
(upload / "README.md").write_text(
|
| 91 |
+
"# Issue 33 Native Selected-Region Student Artifacts\n\n"
|
| 92 |
+
"This folder contains compact artifacts for the issue #33 EN->PT native "
|
| 93 |
+
"selected-region student run: spec, notes, reusable scripts, FLORES teacher "
|
| 94 |
+
"hypothesis data when packaged, NTREX eval summaries, generated hypotheses, "
|
| 95 |
+
"XCOMET summaries, logs, and the native region delta checkpoint when present.\n\n"
|
| 96 |
+
"The checkpoint is the experiment-owned selected-region slice edit only. "
|
| 97 |
+
"Upstream HY-MT weights, XCOMET weights, Hugging Face cache directories, API "
|
| 98 |
+
"keys, and service tokens are intentionally excluded.\n"
|
| 99 |
+
)
|
| 100 |
+
print(json.dumps({"upload_dir": str(upload), "prefix": prefix, "files": manifest["file_count"]}, indent=2))
|
| 101 |
+
PY
|
| 102 |
+
|
| 103 |
+
(cd "$UPLOAD_DIR" && find . -type f -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS)
|
| 104 |
+
run_hf upload "$HF_REPO" "$UPLOAD_DIR" "$UPLOAD_PREFIX" --repo-type dataset
|
| 105 |
+
run_hf upload "$CIRCUIT_HF_REPO" "$UPLOAD_DIR" "circuit-shotting/artifacts/issue33/$UPLOAD_PREFIX" --repo-type dataset
|
| 106 |
+
echo "$UPLOAD_PREFIX"
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/summarize_issue33_native_region.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Summarize issue #33 native selected-region student artifacts."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from typing import Any
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
REFERENCE = {
|
| 13 |
+
"base_fixed_k160000": 0.6278288431,
|
| 14 |
+
"best_trained_reference_issue28_r8": 0.8145537329,
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def parse_args() -> argparse.Namespace:
|
| 19 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 20 |
+
p.add_argument("--run-root", type=Path, required=True)
|
| 21 |
+
p.add_argument("--k", type=int, default=160000)
|
| 22 |
+
p.add_argument("--rank", type=int, default=8)
|
| 23 |
+
p.add_argument("--out-json", type=Path, required=True)
|
| 24 |
+
p.add_argument("--out-md", type=Path, required=True)
|
| 25 |
+
return p.parse_args()
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def load_json(path: Path) -> dict[str, Any] | None:
|
| 29 |
+
if not path.exists():
|
| 30 |
+
return None
|
| 31 |
+
return json.loads(path.read_text())
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def xcomet(path: Path) -> float | None:
|
| 35 |
+
payload = load_json(path)
|
| 36 |
+
if not payload:
|
| 37 |
+
return None
|
| 38 |
+
for key in ("system_score", "system_xcomet_xxl"):
|
| 39 |
+
val = payload.get(key)
|
| 40 |
+
if isinstance(val, (int, float)):
|
| 41 |
+
return float(val)
|
| 42 |
+
summary = payload.get("summary")
|
| 43 |
+
if isinstance(summary, dict):
|
| 44 |
+
val = summary.get("system_score")
|
| 45 |
+
if isinstance(val, (int, float)):
|
| 46 |
+
return float(val)
|
| 47 |
+
return None
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def eval_metric(path: Path, block: str, key: str) -> float | None:
|
| 51 |
+
payload = load_json(path)
|
| 52 |
+
if not payload:
|
| 53 |
+
return None
|
| 54 |
+
row = (payload.get("results") or {}).get(block) or {}
|
| 55 |
+
score = (row.get("scores") or {}).get(key)
|
| 56 |
+
return float(score) if isinstance(score, (int, float)) else None
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def native_metric(path: Path, key: str) -> float | None:
|
| 60 |
+
payload = load_json(path)
|
| 61 |
+
if not payload:
|
| 62 |
+
return None
|
| 63 |
+
score = (payload.get("scores") or {}).get(key)
|
| 64 |
+
return float(score) if isinstance(score, (int, float)) else None
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def fmt(value: float | None) -> str:
|
| 68 |
+
return "" if value is None else f"{value:.6f}"
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def main() -> None:
|
| 72 |
+
args = parse_args()
|
| 73 |
+
root = args.run_root
|
| 74 |
+
native_name = f"native_region_k{args.k}_r{args.rank}"
|
| 75 |
+
rows = [
|
| 76 |
+
{
|
| 77 |
+
"condition": f"base_selected_region_k{args.k}",
|
| 78 |
+
"role": "initial selected-region baseline",
|
| 79 |
+
"xcomet": xcomet(root / "xcomet" / f"base_fixed_k{args.k}.json"),
|
| 80 |
+
"reference_xcomet": REFERENCE.get(f"base_fixed_k{args.k}"),
|
| 81 |
+
"chrFpp": eval_metric(root / "eval" / f"base_k{args.k}_masks.json",
|
| 82 |
+
f"fixed_k{args.k}", "chrFpp"),
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"condition": "best_trained_reference_issue28_r8",
|
| 86 |
+
"role": "comparison reference, not teacher",
|
| 87 |
+
"xcomet": xcomet(root / "xcomet" / f"r8_fixed_k{args.k}.json"),
|
| 88 |
+
"reference_xcomet": REFERENCE["best_trained_reference_issue28_r8"],
|
| 89 |
+
"chrFpp": eval_metric(root / "eval" / f"r8_k{args.k}_masks.json",
|
| 90 |
+
f"fixed_k{args.k}", "chrFpp"),
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"condition": native_name,
|
| 94 |
+
"role": "issue33 trained native selected-region student",
|
| 95 |
+
"xcomet": xcomet(root / "xcomet" / f"{native_name}.json"),
|
| 96 |
+
"reference_xcomet": None,
|
| 97 |
+
"chrFpp": native_metric(root / "eval" / f"{native_name}.json", "chrFpp"),
|
| 98 |
+
},
|
| 99 |
+
]
|
| 100 |
+
base = rows[0]["xcomet"]
|
| 101 |
+
native = rows[-1]["xcomet"]
|
| 102 |
+
reference = rows[1]["xcomet"] or rows[1]["reference_xcomet"]
|
| 103 |
+
summary = {
|
| 104 |
+
"issue": 33,
|
| 105 |
+
"run_root": str(root),
|
| 106 |
+
"k": args.k,
|
| 107 |
+
"rank": args.rank,
|
| 108 |
+
"rows": rows,
|
| 109 |
+
"native_delta_vs_base_selected": None if base is None or native is None else native - base,
|
| 110 |
+
"native_delta_vs_best_trained_reference": (
|
| 111 |
+
None if reference is None or native is None else native - reference
|
| 112 |
+
),
|
| 113 |
+
"pass_floor_for_continuation": (
|
| 114 |
+
None if base is None or native is None else native >= base + 0.03
|
| 115 |
+
),
|
| 116 |
+
}
|
| 117 |
+
args.out_json.parent.mkdir(parents=True, exist_ok=True)
|
| 118 |
+
args.out_json.write_text(json.dumps(summary, indent=2, ensure_ascii=False) + "\n")
|
| 119 |
+
|
| 120 |
+
lines = [
|
| 121 |
+
"# Issue 33 Native Selected-Region Student Summary",
|
| 122 |
+
"",
|
| 123 |
+
f"- Run root: `{root}`",
|
| 124 |
+
f"- Budget: `k={args.k}`, rank `{args.rank}`",
|
| 125 |
+
"- Teacher for training: full unmasked base logits.",
|
| 126 |
+
"- Best trained reference from issue #28 r8 is comparison only.",
|
| 127 |
+
"",
|
| 128 |
+
"| condition | role | XCOMET | reference XCOMET | chrF++ |",
|
| 129 |
+
"|---|---|---:|---:|---:|",
|
| 130 |
+
]
|
| 131 |
+
for row in rows:
|
| 132 |
+
lines.append(
|
| 133 |
+
"| `{}` | {} | {} | {} | {} |".format(
|
| 134 |
+
row["condition"],
|
| 135 |
+
row["role"],
|
| 136 |
+
fmt(row["xcomet"]),
|
| 137 |
+
fmt(row["reference_xcomet"]),
|
| 138 |
+
fmt(row["chrFpp"]),
|
| 139 |
+
)
|
| 140 |
+
)
|
| 141 |
+
lines.extend([
|
| 142 |
+
"",
|
| 143 |
+
f"Native delta vs base selected region: `{fmt(summary['native_delta_vs_base_selected'])}`.",
|
| 144 |
+
"Continuation floor (+0.03 XCOMET over base selected region): "
|
| 145 |
+
f"`{summary['pass_floor_for_continuation']}`.",
|
| 146 |
+
])
|
| 147 |
+
args.out_md.parent.mkdir(parents=True, exist_ok=True)
|
| 148 |
+
args.out_md.write_text("\n".join(lines) + "\n")
|
| 149 |
+
print(json.dumps({"out_json": str(args.out_json), "out_md": str(args.out_md)}, indent=2))
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
if __name__ == "__main__":
|
| 153 |
+
main()
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/train_native_region_delta_translation.py
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Train selected native EN->PT MLP slices under a fixed region mask."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import json
|
| 8 |
+
import math
|
| 9 |
+
import random
|
| 10 |
+
import time
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
import torch
|
| 14 |
+
from torch.utils.data import DataLoader
|
| 15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, get_cosine_schedule_with_warmup
|
| 16 |
+
|
| 17 |
+
from translation_io import DEFAULT_PROMPT_STYLE
|
| 18 |
+
from translation_native_region import NativeRegionDeltaController, save_native_region_delta
|
| 19 |
+
from translation_region_student import (
|
| 20 |
+
TranslationJsonlDataset,
|
| 21 |
+
answer_ce_loss,
|
| 22 |
+
build_mean_cache,
|
| 23 |
+
collate_translation,
|
| 24 |
+
count_mask,
|
| 25 |
+
kl_loss,
|
| 26 |
+
load_mask_npz,
|
| 27 |
+
load_translation_rows,
|
| 28 |
+
move_batch,
|
| 29 |
+
text_config,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def parse_args() -> argparse.Namespace:
|
| 34 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 35 |
+
p.add_argument("--model", required=True)
|
| 36 |
+
p.add_argument("--jsonl", required=True)
|
| 37 |
+
p.add_argument("--fixed-mask", required=True)
|
| 38 |
+
p.add_argument("--out-dir", required=True)
|
| 39 |
+
p.add_argument("--target-field", default="model_hyp")
|
| 40 |
+
p.add_argument("--target-language", default="Portuguese")
|
| 41 |
+
p.add_argument("--prompt-style", default=DEFAULT_PROMPT_STYLE)
|
| 42 |
+
p.add_argument("--device", default="cuda")
|
| 43 |
+
p.add_argument("--dtype", default="bfloat16", choices=["float32", "float16", "bfloat16"])
|
| 44 |
+
p.add_argument("--seed", type=int, default=33)
|
| 45 |
+
p.add_argument("--max-rows", type=int, default=None)
|
| 46 |
+
p.add_argument("--max-seq-length", type=int, default=1024)
|
| 47 |
+
p.add_argument("--n-calib", type=int, default=128)
|
| 48 |
+
p.add_argument("--mean-on", default="full", choices=["prompt", "full"])
|
| 49 |
+
p.add_argument("--rank", type=int, required=True)
|
| 50 |
+
p.add_argument("--epochs", type=float, default=1.0)
|
| 51 |
+
p.add_argument("--max-steps", type=int, default=None)
|
| 52 |
+
p.add_argument("--batch-size", type=int, default=1)
|
| 53 |
+
p.add_argument("--grad-accum", type=int, default=8)
|
| 54 |
+
p.add_argument("--lr", type=float, default=2e-4)
|
| 55 |
+
p.add_argument("--weight-decay", type=float, default=0.0)
|
| 56 |
+
p.add_argument("--warmup-ratio", type=float, default=0.05)
|
| 57 |
+
p.add_argument("--max-grad-norm", type=float, default=1.0)
|
| 58 |
+
p.add_argument("--masked-kl-beta", type=float, default=1.0)
|
| 59 |
+
p.add_argument("--ce-beta", type=float, default=0.2)
|
| 60 |
+
p.add_argument("--kl-temperature", type=float, default=1.0)
|
| 61 |
+
p.add_argument("--kl-on", default="answer", choices=["prompt", "answer", "all"])
|
| 62 |
+
p.add_argument("--eval-every", type=int, default=25)
|
| 63 |
+
p.add_argument("--num-workers", type=int, default=0)
|
| 64 |
+
return p.parse_args()
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def dtype_from_name(name: str) -> torch.dtype:
|
| 68 |
+
return {
|
| 69 |
+
"float32": torch.float32,
|
| 70 |
+
"float16": torch.float16,
|
| 71 |
+
"bfloat16": torch.bfloat16,
|
| 72 |
+
}[name]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def main() -> None:
|
| 76 |
+
args = parse_args()
|
| 77 |
+
out_dir = Path(args.out_dir)
|
| 78 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 79 |
+
random.seed(args.seed)
|
| 80 |
+
torch.manual_seed(args.seed)
|
| 81 |
+
dtype = dtype_from_name(args.dtype)
|
| 82 |
+
|
| 83 |
+
tokenizer = AutoTokenizer.from_pretrained(args.model)
|
| 84 |
+
if tokenizer.pad_token_id is None:
|
| 85 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 86 |
+
|
| 87 |
+
rows = load_translation_rows(args.jsonl, target_field=args.target_field, max_rows=args.max_rows)
|
| 88 |
+
random.shuffle(rows)
|
| 89 |
+
dataset = TranslationJsonlDataset(
|
| 90 |
+
rows,
|
| 91 |
+
tokenizer,
|
| 92 |
+
target_language=args.target_language,
|
| 93 |
+
prompt_style=args.prompt_style,
|
| 94 |
+
max_seq_length=args.max_seq_length,
|
| 95 |
+
kl_on=args.kl_on,
|
| 96 |
+
)
|
| 97 |
+
if len(dataset) == 0:
|
| 98 |
+
raise ValueError("no usable training rows")
|
| 99 |
+
loader = DataLoader(
|
| 100 |
+
dataset,
|
| 101 |
+
batch_size=args.batch_size,
|
| 102 |
+
shuffle=True,
|
| 103 |
+
num_workers=args.num_workers,
|
| 104 |
+
collate_fn=lambda xs: collate_translation(xs, tokenizer.pad_token_id),
|
| 105 |
+
)
|
| 106 |
+
print(json.dumps({"data_rows": len(dataset), "dropped_rows": dataset.dropped}), flush=True)
|
| 107 |
+
|
| 108 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 109 |
+
args.model,
|
| 110 |
+
dtype=dtype,
|
| 111 |
+
attn_implementation="eager",
|
| 112 |
+
).to(args.device).eval()
|
| 113 |
+
model.config.use_cache = False
|
| 114 |
+
for param in model.parameters():
|
| 115 |
+
param.requires_grad_(False)
|
| 116 |
+
|
| 117 |
+
cfg = text_config(model)
|
| 118 |
+
n_layers = int(cfg.num_hidden_layers)
|
| 119 |
+
hidden_size = int(cfg.hidden_size)
|
| 120 |
+
d_ffn = int(cfg.intermediate_size)
|
| 121 |
+
mask = load_mask_npz(args.fixed_mask, n_layers, d_ffn)
|
| 122 |
+
kept = count_mask(mask)
|
| 123 |
+
print(json.dumps({"mask_kept": kept, "mask": args.fixed_mask}), flush=True)
|
| 124 |
+
|
| 125 |
+
means = build_mean_cache(
|
| 126 |
+
model,
|
| 127 |
+
dataset.rows,
|
| 128 |
+
n_calib=args.n_calib,
|
| 129 |
+
mean_on=args.mean_on,
|
| 130 |
+
device=args.device,
|
| 131 |
+
dtype=dtype,
|
| 132 |
+
n_layers=n_layers,
|
| 133 |
+
d_ffn=d_ffn,
|
| 134 |
+
)
|
| 135 |
+
means_path = out_dir / "means.pt"
|
| 136 |
+
torch.save(means, means_path)
|
| 137 |
+
|
| 138 |
+
controller = NativeRegionDeltaController(
|
| 139 |
+
mask=mask,
|
| 140 |
+
means=means,
|
| 141 |
+
hidden_size=hidden_size,
|
| 142 |
+
rank=args.rank,
|
| 143 |
+
).to(args.device)
|
| 144 |
+
controller.train()
|
| 145 |
+
trainable_params = controller.trainable_parameter_count()
|
| 146 |
+
print(json.dumps({
|
| 147 |
+
"rank": args.rank,
|
| 148 |
+
"trainable_parameters": trainable_params,
|
| 149 |
+
"zero_init_means_initial_eval_matches_base_selected_region": True,
|
| 150 |
+
}), flush=True)
|
| 151 |
+
|
| 152 |
+
total_batches = math.ceil(len(loader) * args.epochs)
|
| 153 |
+
if args.max_steps is not None:
|
| 154 |
+
total_batches = min(total_batches, args.max_steps * args.grad_accum)
|
| 155 |
+
total_steps = max(math.ceil(total_batches / args.grad_accum), 1)
|
| 156 |
+
warmup_steps = max(int(total_steps * args.warmup_ratio), 0)
|
| 157 |
+
optimizer = torch.optim.AdamW(
|
| 158 |
+
[p for p in controller.parameters() if p.requires_grad],
|
| 159 |
+
lr=args.lr,
|
| 160 |
+
weight_decay=args.weight_decay,
|
| 161 |
+
)
|
| 162 |
+
scheduler = get_cosine_schedule_with_warmup(
|
| 163 |
+
optimizer,
|
| 164 |
+
num_warmup_steps=warmup_steps,
|
| 165 |
+
num_training_steps=total_steps,
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
summary = {
|
| 169 |
+
"issue": 33,
|
| 170 |
+
"script": Path(__file__).name,
|
| 171 |
+
"args": vars(args),
|
| 172 |
+
"n_rows": len(dataset),
|
| 173 |
+
"dropped_rows": dataset.dropped,
|
| 174 |
+
"n_layers": n_layers,
|
| 175 |
+
"hidden_size": hidden_size,
|
| 176 |
+
"d_ffn": d_ffn,
|
| 177 |
+
"mask_kept": kept,
|
| 178 |
+
"rank": args.rank,
|
| 179 |
+
"trainable_parameters": trainable_params,
|
| 180 |
+
"total_steps": total_steps,
|
| 181 |
+
"warmup_steps": warmup_steps,
|
| 182 |
+
"logs": [],
|
| 183 |
+
"method": {
|
| 184 |
+
"student": "selected native MLP slices",
|
| 185 |
+
"selected_slice_edits": ["gate_proj rows", "up_proj rows", "down_proj columns"],
|
| 186 |
+
"nonselected_mlp_channels": "mean ablated at down_proj input",
|
| 187 |
+
"teacher_logits": "full unmasked base model",
|
| 188 |
+
"global_adapter": False,
|
| 189 |
+
"peft_lora": False,
|
| 190 |
+
"initial_state": "base selected-region masked circuit plus zero low-rank slice edits",
|
| 191 |
+
},
|
| 192 |
+
}
|
| 193 |
+
(out_dir / "config.json").write_text(json.dumps(summary, indent=2, ensure_ascii=False) + "\n")
|
| 194 |
+
|
| 195 |
+
start = time.time()
|
| 196 |
+
global_step = 0
|
| 197 |
+
seen_batches = 0
|
| 198 |
+
running = {"loss": 0.0, "masked_kl": 0.0, "ce": 0.0, "n": 0}
|
| 199 |
+
optimizer.zero_grad(set_to_none=True)
|
| 200 |
+
|
| 201 |
+
while global_step < total_steps:
|
| 202 |
+
for raw_batch in loader:
|
| 203 |
+
if global_step >= total_steps:
|
| 204 |
+
break
|
| 205 |
+
batch = move_batch(raw_batch, args.device)
|
| 206 |
+
|
| 207 |
+
with torch.no_grad():
|
| 208 |
+
teacher_logits = model(
|
| 209 |
+
input_ids=batch["input_ids"],
|
| 210 |
+
attention_mask=batch["attention_mask"],
|
| 211 |
+
use_cache=False,
|
| 212 |
+
).logits
|
| 213 |
+
|
| 214 |
+
hooks = controller.install(model)
|
| 215 |
+
try:
|
| 216 |
+
student_logits = model(
|
| 217 |
+
input_ids=batch["input_ids"],
|
| 218 |
+
attention_mask=batch["attention_mask"],
|
| 219 |
+
use_cache=False,
|
| 220 |
+
).logits
|
| 221 |
+
finally:
|
| 222 |
+
for hook in hooks:
|
| 223 |
+
hook.remove()
|
| 224 |
+
|
| 225 |
+
masked_kl = kl_loss(
|
| 226 |
+
student_logits,
|
| 227 |
+
teacher_logits,
|
| 228 |
+
batch["kl_logit_mask"],
|
| 229 |
+
temperature=args.kl_temperature,
|
| 230 |
+
)
|
| 231 |
+
ce = answer_ce_loss(student_logits, batch["labels"])
|
| 232 |
+
loss = args.masked_kl_beta * masked_kl + args.ce_beta * ce
|
| 233 |
+
(loss / args.grad_accum).backward()
|
| 234 |
+
|
| 235 |
+
seen_batches += 1
|
| 236 |
+
running["loss"] += float(loss.detach().cpu())
|
| 237 |
+
running["masked_kl"] += float(masked_kl.detach().cpu())
|
| 238 |
+
running["ce"] += float(ce.detach().cpu())
|
| 239 |
+
running["n"] += 1
|
| 240 |
+
if seen_batches % args.grad_accum != 0:
|
| 241 |
+
continue
|
| 242 |
+
|
| 243 |
+
torch.nn.utils.clip_grad_norm_(controller.parameters(), args.max_grad_norm)
|
| 244 |
+
optimizer.step()
|
| 245 |
+
scheduler.step()
|
| 246 |
+
optimizer.zero_grad(set_to_none=True)
|
| 247 |
+
global_step += 1
|
| 248 |
+
|
| 249 |
+
if global_step == 1 or global_step % args.eval_every == 0 or global_step == total_steps:
|
| 250 |
+
denom = max(running["n"], 1)
|
| 251 |
+
row = {
|
| 252 |
+
"step": global_step,
|
| 253 |
+
"loss": running["loss"] / denom,
|
| 254 |
+
"masked_kl": running["masked_kl"] / denom,
|
| 255 |
+
"ce": running["ce"] / denom,
|
| 256 |
+
"lr": scheduler.get_last_lr()[0],
|
| 257 |
+
"elapsed_s": time.time() - start,
|
| 258 |
+
}
|
| 259 |
+
summary["logs"].append(row)
|
| 260 |
+
(out_dir / "train_summary.json").write_text(
|
| 261 |
+
json.dumps(summary, indent=2, ensure_ascii=False) + "\n"
|
| 262 |
+
)
|
| 263 |
+
print(json.dumps(row), flush=True)
|
| 264 |
+
running = {"loss": 0.0, "masked_kl": 0.0, "ce": 0.0, "n": 0}
|
| 265 |
+
|
| 266 |
+
controller.eval()
|
| 267 |
+
summary["elapsed_s"] = time.time() - start
|
| 268 |
+
save_native_region_delta(
|
| 269 |
+
out_dir,
|
| 270 |
+
controller,
|
| 271 |
+
mask_path=str(args.fixed_mask),
|
| 272 |
+
means_path=str(means_path),
|
| 273 |
+
extra={
|
| 274 |
+
"model": args.model,
|
| 275 |
+
"target_language": args.target_language,
|
| 276 |
+
"prompt_style": args.prompt_style,
|
| 277 |
+
"mask_kept": kept,
|
| 278 |
+
"n_layers": n_layers,
|
| 279 |
+
"d_ffn": d_ffn,
|
| 280 |
+
},
|
| 281 |
+
)
|
| 282 |
+
(out_dir / "train_summary.json").write_text(
|
| 283 |
+
json.dumps(summary, indent=2, ensure_ascii=False) + "\n"
|
| 284 |
+
)
|
| 285 |
+
tokenizer.save_pretrained(out_dir / "tokenizer")
|
| 286 |
+
print(json.dumps({"done": True, "out_dir": str(out_dir), "elapsed_s": summary["elapsed_s"]}), flush=True)
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
if __name__ == "__main__":
|
| 290 |
+
main()
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/scripts/translation_native_region.py
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Native selected-MLP-region student helpers for EN->PT experiments.
|
| 3 |
+
|
| 4 |
+
This path starts from the live base selected-region circuit, not from a fresh
|
| 5 |
+
replacement writer. Non-selected MLP intermediate channels are mean-ablated at
|
| 6 |
+
the down_proj input. Selected channels stay live and receive trainable low-rank
|
| 7 |
+
slice edits to gate_proj rows, up_proj rows, and down_proj columns.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import json
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
from typing import Any
|
| 15 |
+
|
| 16 |
+
import torch
|
| 17 |
+
from torch import nn
|
| 18 |
+
|
| 19 |
+
from translation_region_student import decoder_root
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class LowRankLinearDelta(nn.Module):
|
| 23 |
+
"""Zero-initialized low-rank additive map."""
|
| 24 |
+
|
| 25 |
+
def __init__(self, in_features: int, out_features: int, rank: int):
|
| 26 |
+
super().__init__()
|
| 27 |
+
self.down = nn.Linear(in_features, rank, bias=False)
|
| 28 |
+
self.up = nn.Linear(rank, out_features, bias=False)
|
| 29 |
+
nn.init.normal_(self.down.weight, mean=0.0, std=0.02)
|
| 30 |
+
nn.init.zeros_(self.up.weight)
|
| 31 |
+
|
| 32 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 33 |
+
return self.up(self.down(x.to(torch.float32)))
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class NativeRegionDeltaController(nn.Module):
|
| 37 |
+
"""Low-rank edits constrained to selected native MLP slices."""
|
| 38 |
+
|
| 39 |
+
def __init__(self, *, mask: dict[int, torch.Tensor], means: dict[int, torch.Tensor],
|
| 40 |
+
hidden_size: int, rank: int):
|
| 41 |
+
super().__init__()
|
| 42 |
+
self.mask = {int(k): v.detach().cpu().bool() for k, v in mask.items()}
|
| 43 |
+
self.means = {int(k): v.detach().cpu() for k, v in means.items()}
|
| 44 |
+
self.hidden_size = int(hidden_size)
|
| 45 |
+
self.rank = int(rank)
|
| 46 |
+
self.selected_indices: dict[int, torch.Tensor] = {}
|
| 47 |
+
self.gate_deltas = nn.ModuleDict()
|
| 48 |
+
self.up_deltas = nn.ModuleDict()
|
| 49 |
+
self.down_deltas = nn.ModuleDict()
|
| 50 |
+
|
| 51 |
+
for layer_idx, layer_mask in sorted(self.mask.items()):
|
| 52 |
+
selected = torch.nonzero(layer_mask, as_tuple=False).flatten().cpu()
|
| 53 |
+
self.selected_indices[layer_idx] = selected
|
| 54 |
+
if selected.numel() == 0:
|
| 55 |
+
continue
|
| 56 |
+
key = str(layer_idx)
|
| 57 |
+
width = int(selected.numel())
|
| 58 |
+
self.gate_deltas[key] = LowRankLinearDelta(self.hidden_size, width, self.rank)
|
| 59 |
+
self.up_deltas[key] = LowRankLinearDelta(self.hidden_size, width, self.rank)
|
| 60 |
+
self.down_deltas[key] = LowRankLinearDelta(width, self.hidden_size, self.rank)
|
| 61 |
+
|
| 62 |
+
def trainable_parameter_count(self) -> int:
|
| 63 |
+
return sum(p.numel() for p in self.parameters() if p.requires_grad)
|
| 64 |
+
|
| 65 |
+
def install(self, model):
|
| 66 |
+
hooks = []
|
| 67 |
+
root = decoder_root(model)
|
| 68 |
+
selected_act_cache: dict[int, torch.Tensor] = {}
|
| 69 |
+
|
| 70 |
+
for layer_idx, layer in enumerate(root.layers):
|
| 71 |
+
selected_cpu = self.selected_indices[layer_idx]
|
| 72 |
+
if selected_cpu.numel() > 0:
|
| 73 |
+
hooks.append(layer.mlp.gate_proj.register_forward_hook(
|
| 74 |
+
self._make_gate_or_up_hook(layer_idx, selected_cpu, self.gate_deltas)
|
| 75 |
+
))
|
| 76 |
+
hooks.append(layer.mlp.up_proj.register_forward_hook(
|
| 77 |
+
self._make_gate_or_up_hook(layer_idx, selected_cpu, self.up_deltas)
|
| 78 |
+
))
|
| 79 |
+
|
| 80 |
+
hooks.append(layer.mlp.down_proj.register_forward_pre_hook(
|
| 81 |
+
self._make_down_pre_hook(layer_idx, selected_cpu, selected_act_cache)
|
| 82 |
+
))
|
| 83 |
+
if selected_cpu.numel() > 0:
|
| 84 |
+
hooks.append(layer.mlp.down_proj.register_forward_hook(
|
| 85 |
+
self._make_down_hook(layer_idx, selected_act_cache)
|
| 86 |
+
))
|
| 87 |
+
return hooks
|
| 88 |
+
|
| 89 |
+
def _make_gate_or_up_hook(self, layer_idx: int, selected_cpu: torch.Tensor,
|
| 90 |
+
modules: nn.ModuleDict):
|
| 91 |
+
def hook_fn(module, hook_args, output):
|
| 92 |
+
hidden = hook_args[0]
|
| 93 |
+
selected = selected_cpu.to(output.device)
|
| 94 |
+
delta = modules[str(layer_idx)](hidden).to(dtype=output.dtype)
|
| 95 |
+
patched = output.clone()
|
| 96 |
+
patched[..., selected] = patched[..., selected] + delta
|
| 97 |
+
return patched
|
| 98 |
+
return hook_fn
|
| 99 |
+
|
| 100 |
+
def _make_down_pre_hook(self, layer_idx: int, selected_cpu: torch.Tensor,
|
| 101 |
+
selected_act_cache: dict[int, torch.Tensor]):
|
| 102 |
+
def hook_fn(module, hook_args):
|
| 103 |
+
act = hook_args[0]
|
| 104 |
+
mean = self.means[layer_idx].to(device=act.device, dtype=act.dtype).view(1, 1, -1)
|
| 105 |
+
keep = self.mask[layer_idx].to(device=act.device, dtype=act.dtype).view(1, 1, -1)
|
| 106 |
+
patched = act * keep + mean * (1.0 - keep)
|
| 107 |
+
if selected_cpu.numel() > 0:
|
| 108 |
+
selected = selected_cpu.to(act.device)
|
| 109 |
+
selected_act_cache[layer_idx] = act[..., selected]
|
| 110 |
+
return (patched,) + hook_args[1:]
|
| 111 |
+
return hook_fn
|
| 112 |
+
|
| 113 |
+
def _make_down_hook(self, layer_idx: int, selected_act_cache: dict[int, torch.Tensor]):
|
| 114 |
+
def hook_fn(module, hook_args, output):
|
| 115 |
+
selected_act = selected_act_cache.pop(layer_idx, None)
|
| 116 |
+
if selected_act is None:
|
| 117 |
+
return output
|
| 118 |
+
delta = self.down_deltas[str(layer_idx)](selected_act).to(dtype=output.dtype)
|
| 119 |
+
return output + delta
|
| 120 |
+
return hook_fn
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def save_native_region_delta(out_dir: str | Path, controller: NativeRegionDeltaController,
|
| 124 |
+
*, mask_path: str, means_path: str,
|
| 125 |
+
extra: dict[str, Any]) -> None:
|
| 126 |
+
out = Path(out_dir)
|
| 127 |
+
out.mkdir(parents=True, exist_ok=True)
|
| 128 |
+
torch.save(controller.state_dict(), out / "native_region_delta.pt")
|
| 129 |
+
config = {
|
| 130 |
+
"rank": controller.rank,
|
| 131 |
+
"hidden_size": controller.hidden_size,
|
| 132 |
+
"mask_path": mask_path,
|
| 133 |
+
"means_path": means_path,
|
| 134 |
+
"trainable_parameters": controller.trainable_parameter_count(),
|
| 135 |
+
"parameterization": "selected native MLP gate/up/down low-rank slice edits",
|
| 136 |
+
**extra,
|
| 137 |
+
}
|
| 138 |
+
with (out / "native_region_delta_config.json").open("w") as f:
|
| 139 |
+
json.dump(config, f, indent=2, ensure_ascii=False)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def load_native_region_delta(student_dir: str | Path, *, mask: dict[int, torch.Tensor],
|
| 143 |
+
means: dict[int, torch.Tensor], hidden_size: int,
|
| 144 |
+
map_location: str = "cpu") -> NativeRegionDeltaController:
|
| 145 |
+
root = Path(student_dir)
|
| 146 |
+
cfg = json.loads((root / "native_region_delta_config.json").read_text())
|
| 147 |
+
controller = NativeRegionDeltaController(
|
| 148 |
+
mask=mask,
|
| 149 |
+
means=means,
|
| 150 |
+
hidden_size=hidden_size,
|
| 151 |
+
rank=int(cfg["rank"]),
|
| 152 |
+
)
|
| 153 |
+
state = torch.load(root / "native_region_delta.pt", map_location=map_location)
|
| 154 |
+
controller.load_state_dict(state)
|
| 155 |
+
return controller
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/spec/native_region_mvc_issue33.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"issue": 33,
|
| 3 |
+
"name": "native_selected_region_student_enpt",
|
| 4 |
+
"objective": "Improve the selected EN->PT MLP region itself, starting from its base masked-region recovery state, while keeping the rest of the model frozen and non-selected MLP channels mean-ablated.",
|
| 5 |
+
"model": {
|
| 6 |
+
"base_and_teacher": "tencent/HY-MT1.5-1.8B",
|
| 7 |
+
"teacher_for_training": "full unmasked base logits on FLORES teacher-hyp rows",
|
| 8 |
+
"comparison_reference": "best trained reference from issue #28 r8; comparison only, not the teacher"
|
| 9 |
+
},
|
| 10 |
+
"data": {
|
| 11 |
+
"train_source": "FLORES EN->PT devtest JSONL translated by unmasked HY-MT into model_hyp targets",
|
| 12 |
+
"eval_source": "NTREX EN->PT held-out JSONL",
|
| 13 |
+
"target_field": "model_hyp",
|
| 14 |
+
"judge": "XCOMET-XXL service when available"
|
| 15 |
+
},
|
| 16 |
+
"mask": {
|
| 17 |
+
"source": "preserved ReLP base attribution mask from Occupying-Mars/hy-lora-conditions",
|
| 18 |
+
"budget_mlp_channels": 160000,
|
| 19 |
+
"path_in_artifacts": "masks/base_attr/relp_k160000.full.npz"
|
| 20 |
+
},
|
| 21 |
+
"student": {
|
| 22 |
+
"initial_state": "base selected-region masked circuit with zero low-rank slice edits",
|
| 23 |
+
"trainable_region": "selected native MLP slices only",
|
| 24 |
+
"trainable_slices": [
|
| 25 |
+
"gate_proj selected output rows",
|
| 26 |
+
"up_proj selected output rows",
|
| 27 |
+
"down_proj selected input columns"
|
| 28 |
+
],
|
| 29 |
+
"nonselected_mlp_channels": "mean ablated at down_proj input during masked objective and evaluation",
|
| 30 |
+
"outside_region": "frozen base model carrier",
|
| 31 |
+
"global_adapter": false,
|
| 32 |
+
"peft_lora": false,
|
| 33 |
+
"first_rank": 8
|
| 34 |
+
},
|
| 35 |
+
"loss": {
|
| 36 |
+
"masked_kl_beta": 1.0,
|
| 37 |
+
"ce_beta": 0.2,
|
| 38 |
+
"kl_temperature": 1.0,
|
| 39 |
+
"kl_on": "answer"
|
| 40 |
+
},
|
| 41 |
+
"anchors": {
|
| 42 |
+
"base_selected_region_xcomet": 0.6278288431,
|
| 43 |
+
"best_trained_reference_issue28_r8_xcomet": 0.8145537329,
|
| 44 |
+
"continue_if_native_student_beats_base_selected_region_by_xcomet": 0.03
|
| 45 |
+
},
|
| 46 |
+
"run": {
|
| 47 |
+
"pod_class": "2x NVIDIA RTX PRO 6000 Blackwell Server Edition",
|
| 48 |
+
"runner": "issue33_native_region_runner.sh",
|
| 49 |
+
"artifact_dataset_repo": "TokenBender/synth-data-en-pt-circuit",
|
| 50 |
+
"artifact_backup_repo": "TokenBender/circuit-discovery/circuit-shotting/artifacts/issue33"
|
| 51 |
+
},
|
| 52 |
+
"stop_conditions": [
|
| 53 |
+
"fixed mask or preserved r8 artifacts cannot be restored",
|
| 54 |
+
"base selected-region anchor is not reproduced closely enough to trust the run",
|
| 55 |
+
"native rank-8 student does not beat the selected-region baseline by at least 0.03 XCOMET",
|
| 56 |
+
"artifact upload fails after a completed run"
|
| 57 |
+
]
|
| 58 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/summaries/issue33_native_region_k160000_r8.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"issue": 33,
|
| 3 |
+
"run_root": "/root/runs/issue33_native_region",
|
| 4 |
+
"k": 160000,
|
| 5 |
+
"rank": 8,
|
| 6 |
+
"rows": [
|
| 7 |
+
{
|
| 8 |
+
"condition": "base_selected_region_k160000",
|
| 9 |
+
"role": "initial selected-region baseline",
|
| 10 |
+
"xcomet": 0.6259405999205152,
|
| 11 |
+
"reference_xcomet": 0.6278288431,
|
| 12 |
+
"chrFpp": 46.99461052474228
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"condition": "best_trained_reference_issue28_r8",
|
| 16 |
+
"role": "comparison reference, not teacher",
|
| 17 |
+
"xcomet": 0.8103810173308426,
|
| 18 |
+
"reference_xcomet": 0.8145537329,
|
| 19 |
+
"chrFpp": 51.21928365554815
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"condition": "native_region_k160000_r8",
|
| 23 |
+
"role": "issue33 trained native selected-region student",
|
| 24 |
+
"xcomet": 0.7950550597565977,
|
| 25 |
+
"reference_xcomet": null,
|
| 26 |
+
"chrFpp": 50.97431297760433
|
| 27 |
+
}
|
| 28 |
+
],
|
| 29 |
+
"native_delta_vs_base_selected": 0.16911445983608253,
|
| 30 |
+
"native_delta_vs_best_trained_reference": -0.01532595757424482,
|
| 31 |
+
"pass_floor_for_continuation": true
|
| 32 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/summaries/issue33_native_region_k160000_r8.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue 33 Native Selected-Region Student Summary
|
| 2 |
+
|
| 3 |
+
- Run root: `/root/runs/issue33_native_region`
|
| 4 |
+
- Budget: `k=160000`, rank `8`
|
| 5 |
+
- Teacher for training: full unmasked base logits.
|
| 6 |
+
- Best trained reference from issue #28 r8 is comparison only.
|
| 7 |
+
|
| 8 |
+
| condition | role | XCOMET | reference XCOMET | chrF++ |
|
| 9 |
+
|---|---|---:|---:|---:|
|
| 10 |
+
| `base_selected_region_k160000` | initial selected-region baseline | 0.625941 | 0.627829 | 46.994611 |
|
| 11 |
+
| `best_trained_reference_issue28_r8` | comparison reference, not teacher | 0.810381 | 0.814554 | 51.219284 |
|
| 12 |
+
| `native_region_k160000_r8` | issue33 trained native selected-region student | 0.795055 | | 50.974313 |
|
| 13 |
+
|
| 14 |
+
Native delta vs base selected region: `0.169114`.
|
| 15 |
+
Continuation floor (+0.03 XCOMET over base selected region): `True`.
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/base_fixed_k160000.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"hyps_jsonl": "/root/runs/issue33_native_region/dumps/base_k160000/fixed_k160000.jsonl",
|
| 3 |
+
"out_jsonl": "/root/runs/issue33_native_region/xcomet/base_fixed_k160000.scored_pool.jsonl",
|
| 4 |
+
"comet_model": "Unbabel/XCOMET-XXL",
|
| 5 |
+
"checkpoint_path": "/root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt",
|
| 6 |
+
"n": 1012,
|
| 7 |
+
"threshold": 0.99,
|
| 8 |
+
"system_score": 0.6259405999205152,
|
| 9 |
+
"passed": 38,
|
| 10 |
+
"elapsed_seconds": 339.8826160430908,
|
| 11 |
+
"batch_size": 8,
|
| 12 |
+
"chunk_size": 128,
|
| 13 |
+
"by_category_tag": [
|
| 14 |
+
{
|
| 15 |
+
"category": "ntrex_test",
|
| 16 |
+
"tag": "heldout",
|
| 17 |
+
"n": 1012,
|
| 18 |
+
"mean": 0.6259405999205152,
|
| 19 |
+
"passed": 38
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"input_categories": {
|
| 23 |
+
"ntrex_test": 1012
|
| 24 |
+
}
|
| 25 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/base_fixed_k160000.scored_pool.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/native_region_k160000_r8.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"hyps_jsonl": "/root/runs/issue33_native_region/dumps/native_region_k160000_r8.jsonl",
|
| 3 |
+
"out_jsonl": "/root/runs/issue33_native_region/xcomet/native_region_k160000_r8.scored_pool.jsonl",
|
| 4 |
+
"comet_model": "Unbabel/XCOMET-XXL",
|
| 5 |
+
"checkpoint_path": "/root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt",
|
| 6 |
+
"n": 1012,
|
| 7 |
+
"threshold": 0.99,
|
| 8 |
+
"system_score": 0.7950550597565977,
|
| 9 |
+
"passed": 162,
|
| 10 |
+
"elapsed_seconds": 332.72063279151917,
|
| 11 |
+
"batch_size": 8,
|
| 12 |
+
"chunk_size": 128,
|
| 13 |
+
"by_category_tag": [
|
| 14 |
+
{
|
| 15 |
+
"category": "ntrex_test",
|
| 16 |
+
"tag": "heldout",
|
| 17 |
+
"n": 1012,
|
| 18 |
+
"mean": 0.7950550597565977,
|
| 19 |
+
"passed": 162
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"input_categories": {
|
| 23 |
+
"ntrex_test": 1012
|
| 24 |
+
}
|
| 25 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/native_region_k160000_r8.scored_pool.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/r8_fixed_k160000.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"hyps_jsonl": "/root/runs/issue33_native_region/dumps/r8_k160000/fixed_k160000.jsonl",
|
| 3 |
+
"out_jsonl": "/root/runs/issue33_native_region/xcomet/r8_fixed_k160000.scored_pool.jsonl",
|
| 4 |
+
"comet_model": "Unbabel/XCOMET-XXL",
|
| 5 |
+
"checkpoint_path": "/root/.cache/huggingface/hub/models--Unbabel--XCOMET-XXL/snapshots/873bac1b1c461e410c4a6e379f6790d3d1c7c214/checkpoints/model.ckpt",
|
| 6 |
+
"n": 1012,
|
| 7 |
+
"threshold": 0.99,
|
| 8 |
+
"system_score": 0.8103810173308426,
|
| 9 |
+
"passed": 161,
|
| 10 |
+
"elapsed_seconds": 340.4577021598816,
|
| 11 |
+
"batch_size": 8,
|
| 12 |
+
"chunk_size": 128,
|
| 13 |
+
"by_category_tag": [
|
| 14 |
+
{
|
| 15 |
+
"category": "ntrex_test",
|
| 16 |
+
"tag": "heldout",
|
| 17 |
+
"n": 1012,
|
| 18 |
+
"mean": 0.8103810173308426,
|
| 19 |
+
"passed": 161
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"input_categories": {
|
| 23 |
+
"ntrex_test": 1012
|
| 24 |
+
}
|
| 25 |
+
}
|
circuit-shotting/artifacts/issue33/issue33_native_region_20260513T171458Z/xcomet/r8_fixed_k160000.scored_pool.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|