docs: freeze B1 residual contract and exact learning clock weights for review
This commit is contained in:
1 parent
7cb1f1c146
commit
e751e5b261
10 files changed
+39097
-12
No files matched your search
@@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"version": "B1-H1-RES-review-v1",
|
||||||
|
"status": "FIXED_FOR_SINGLE_CLAUDE_REVIEW_NOT_APPROVED_OR_LAUNCHED",
|
||||||
|
"authorizing_direction": [
|
||||||
|
"1794886306.593149",
|
||||||
|
"1794886866.775119",
|
||||||
|
"1794887072.921849",
|
||||||
|
"1794887818.030459"
|
||||||
|
],
|
||||||
|
"mold_spec_sha256": "91ecc62fb821e9fee31d9166df5263fac663cc22c5ff18549b103aea35c59333",
|
||||||
|
"files": {
|
||||||
|
"docs/phase2-h1-residual-contract-2026-11-17.md": "d5823accea3d41de07fd4aa9214701d383eca5b4ca46d71fe4a6308170fbbb62",
|
||||||
|
"artifacts/phase2-ml-planning-2026-11-17/mold-h1-spec-readback.md": "91ecc62fb821e9fee31d9166df5263fac663cc22c5ff18549b103aea35c59333",
|
||||||
|
"artifacts/phase2-h1-planning-2026-11-17/clock-freeze-v1/clock-weights.csv": "013bdd8f8596610542ea97e43bf00fb6cba697cbf030153e74224f8864247ae5",
|
||||||
|
"artifacts/phase2-h1-planning-2026-11-17/clock-freeze-v1/membership-and-sources.json": "4d30b85d371a95f6c19f10a2388d88c274d82309ad90a4aa11f68cde27738d99",
|
||||||
|
"artifacts/phase2-h1-planning-2026-11-17/clock-freeze-v1/receipt.json": "37fcb1ef48dccabef6cf952e283ff356b84af24d4bb331af471f2927bf167b1f",
|
||||||
|
"tools/phase2_h1_clock_manifest.py": "b67d21cf1854f57b1508c87f6f05d5e5ff4b58284b758a7549e9946f7dce13b4",
|
||||||
|
"tools/phase2_h1_worker.py": "8c4bab8f9e8e99f069ca37ed5748d49d07858815260e326c4c581e3b1e3ca836",
|
||||||
|
"tools/phase2_residual_math.py": "ffbd9624dec79bdaabf95244fe87209055908f31a977e73ea4377045d6f8fe62",
|
||||||
|
"tools/test_phase2_residual_math.py": "bdaa9133a4d2159be5c1c1c5ba930d2c6adeac22c03c53583ffdcba941db13c1",
|
||||||
|
"artifacts/phase2-h1-planning-2026-11-17/residual-clock-check.json": "44c22f43c743499404a2fa98445a8da3e0265e69bd3e56e443eebe6a786807f9",
|
||||||
|
"artifacts/phase2-h1-planning-2026-11-17/residual-interface-check.json": "f90f0105a31992876e96fa618cf9e0665a93273285b7764ecd0d18f9917a1662"
|
||||||
|
},
|
||||||
|
"preserved_historical_code_hashes_match": true,
|
||||||
|
"legacy_source_sha256": {
|
||||||
|
"tools/gre24_prepare_v2.py": "7637e55009005f6a8c77114159d7ac0d3c024c7add3e320afc486927537b78bc",
|
||||||
|
"tools/gre24_features_v2.py": "7dcd5ac218ffdc1ca149edcd87e8658fb3c59e18c0fb9ce47985c7f1357d2cdf",
|
||||||
|
"tools/gre24_models.py": "53b6fee8b700b9b982b06d29908ce2ce23e0c57512c46dbf74b2aade79e3ac3a",
|
||||||
|
"tools/gre24_fit.py": "63af0305a2c22b524d95ffee50e972848decdd042b1d24f0b3b946d9152f7688",
|
||||||
|
"tools/r4bc_common.py": "27543fff987975ece767167f9771e6621c825035a053805604e4a696794dfcbd",
|
||||||
|
"tools/r4bc_postfit.py": "02df42bc8cc9ce553db5dfbc047cf80955ceee5348faa306c37cab05933d9623",
|
||||||
|
"tools/s2_custody_statistics.py": "188565801f6901d0192f79aec0889e632501e672a4149d76d1835efbb9b45447",
|
||||||
|
"tools/s2_custody_common.py": "588c646101be0d50f505f9a12a1c98361aa3437c8c594eecb7321831f717a741",
|
||||||
|
"artifacts/gre24-v4-reproduction-2026-11-16/protocol/contract.json": "8ea9bdb9f1aa542a044b383e7191696e6ac8b3ed1aedd9b2b34e7571cd7e2c1e",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-protocol/contract.json": "9f8f87cb36108d51a7bdf90f006b709fd2483a9c4d9cc6658ee8d722f634a248"
|
||||||
|
},
|
||||||
|
"archive_metadata": {
|
||||||
|
"v4": {
|
||||||
|
"path": "/home/frank14f/optane/MeltMind/artifacts/gre24-v4-reproduction-2026-11-16/data/data.zip",
|
||||||
|
"original_archive_stat": {
|
||||||
|
"status": "VERIFIED",
|
||||||
|
"archive": "/home/frank14f/optane/MeltMind/artifacts/gre24-v4-reproduction-2026-11-16/data/data.zip",
|
||||||
|
"bytes": 35925187752,
|
||||||
|
"mtime_ns": 1794815107123564479,
|
||||||
|
"inode": 13797925,
|
||||||
|
"md5": "4973f24e12a38c87c31cf129be1a3e3b",
|
||||||
|
"sha256": "5b0fbd7a6f41272813c48bedaa490100fa27dbda46c23adeb902f734860f163c",
|
||||||
|
"unix": 1794816521.5639184,
|
||||||
|
"elapsed_seconds": 100.75043417402776,
|
||||||
|
"intake_cpu_seconds": 100.402575333,
|
||||||
|
"source": "Manual receive by Yanqi; independently verified by MeltAstra",
|
||||||
|
"original_manual_filename": "/home/frank14f/optane/MeltMind/artifacts/gre24-v4-reproduction-2026-11-16/data/data.zip.partial",
|
||||||
|
"user_report_separate_from_independent_hash": true,
|
||||||
|
"authorizing_ruling": "1794815915.570349",
|
||||||
|
"science_started": false,
|
||||||
|
"original_receiver_remains_user_stopped": true
|
||||||
|
},
|
||||||
|
"source_contract_sha256": "8ea9bdb9f1aa542a044b383e7191696e6ac8b3ed1aedd9b2b34e7571cd7e2c1e"
|
||||||
|
},
|
||||||
|
"v5": {
|
||||||
|
"path": "/home/frank14f/optane/MeltMind/data.zip",
|
||||||
|
"original_archive_stat": {
|
||||||
|
"status": "official_size_and_md5_pass",
|
||||||
|
"source": "/home/frank14f/optane/MeltMind/data.zip",
|
||||||
|
"source_url": "https://zenodo.org/records/18598121",
|
||||||
|
"bytes": 32757812726,
|
||||||
|
"md5": "75ec15002234c2cdcdf4c751bdefab85",
|
||||||
|
"sha256": "d151f018294832fd80fbd23e865642cb16c860da150f245033d010c388fa0241",
|
||||||
|
"mtime_ns": 1794548962944204621,
|
||||||
|
"inode": 12582980,
|
||||||
|
"members": 1872,
|
||||||
|
"triplets": 624,
|
||||||
|
"source_tokens": 249,
|
||||||
|
"max_group": 34,
|
||||||
|
"total_uncompressed_bytes": 43966308383,
|
||||||
|
"finished_utc": "2026-11-13T08:04:57.180660+00:00",
|
||||||
|
"wall_seconds": 97.27923265600111,
|
||||||
|
"peak_rss_kib": 32056,
|
||||||
|
"crc_scope": "ZIP stored CRC inventory only; selected members checked on read; no full decompression",
|
||||||
|
"grouping_scope": "Filename source tokens, not verified independent CAD families"
|
||||||
|
},
|
||||||
|
"source_contract_sha256": "9f8f87cb36108d51a7bdf90f006b709fd2483a9c4d9cc6658ee8d722f634a248"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"h1_worker_status": "historical draft preserved; endpoint/F checks, orchestration, topology and scoring implementation acceptance still required",
|
||||||
|
"clock_values_computed": false,
|
||||||
|
"project_arrays_read_in_this_preparation": false,
|
||||||
|
"new_fits": 0,
|
||||||
|
"new_gpu_work": false,
|
||||||
|
"known_preparation_cpu_seconds": 0.570199085,
|
||||||
|
"cpu_total_cap_seconds": 72000,
|
||||||
|
"cpu_preparation_cap_seconds": 3600,
|
||||||
|
"cpu_fit_cap_seconds": 43200,
|
||||||
|
"cpu_postfit_cap_seconds": 25200
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
+34126
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"status": "PASS_METADATA_INVARIANTS",
|
||||||
|
"cells": 20,
|
||||||
|
"weight_rows": 4463,
|
||||||
|
"grouped_parts": 552,
|
||||||
|
"grouped_components": 204,
|
||||||
|
"v4_successful_parts": 615,
|
||||||
|
"exact_weight_sums": true,
|
||||||
|
"original_access_order_match": true,
|
||||||
|
"learning_test_disjoint": true,
|
||||||
|
"grouped_component_role_isolation": true,
|
||||||
|
"target_arrays_read": false,
|
||||||
|
"feature_arrays_read": false,
|
||||||
|
"cpu_seconds": 0.225320085,
|
||||||
|
"files": {
|
||||||
|
"membership-and-sources.json": "4d30b85d371a95f6c19f10a2388d88c274d82309ad90a4aa11f68cde27738d99",
|
||||||
|
"clock-weights.csv": "013bdd8f8596610542ea97e43bf00fb6cba697cbf030153e74224f8864247ae5"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"status": "PASS",
|
||||||
|
"tests": 6,
|
||||||
|
"cpu_seconds": 0.17471799999999998,
|
||||||
|
"wall_seconds": 0.14109541999641806,
|
||||||
|
"scope": "Pure synthetic clock/residual math; worker syntax only, no project arrays/model load/fit",
|
||||||
|
"code_sha256": {
|
||||||
|
"tools/phase2_residual_math.py": "ffbd9624dec79bdaabf95244fe87209055908f31a977e73ea4377045d6f8fe62",
|
||||||
|
"tools/test_phase2_residual_math.py": "bdaa9133a4d2159be5c1c1c5ba930d2c6adeac22c03c53583ffdcba941db13c1",
|
||||||
|
"tools/phase2_h1_worker.py": "8c4bab8f9e8e99f069ca37ed5748d49d07858815260e326c4c581e3b1e3ca836"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,36 @@
|
|||||||
# H1-RES:固定EIK跳连残差学习(合同草稿)
|
# B1 / H1-RES:固定EIK跳连残差学习(主审合同v1)
|
||||||
|
|
||||||
用户已通过TRON明确同意H1/H2尝试;Claude `1794886306.593149`分工:Mold数学规格,Melt合同/实现/唯一执行,Assist事后审计。**当前开始合同和实现准备,无训练启动;等待Mold短规格并完成Claude一次合同主审,不是再次请求用户go。** 本任务使用H1-RES命名,与R4旧H1消融区别。
|
用户已通过TRON明确同意H1/H2尝试;Claude `1794886306.593149`分工:Mold数学规格,Melt合同/实现/唯一执行,Assist事后审计。**本版固定供Claude一次主审,尚未获本版主审、没有训练启动。** 已实读Claude1794886866、1794887072、1794887818;不是再次请求用户go。本任务使用H1-RES命名,与R4旧H1消融区别。
|
||||||
|
|
||||||
后续已实际读到Claude唯一[研究树bf0a6c0f](https://gitea.frank14f.online/Frank14f/MeltMind/src/commit/bf0a6c0f/docs/claude/research-tree.md):B1/B2为当前两个PROMOTED分支,其他OPEN分支先规格/cheap gate,至多两枝同时正式推进。执行顺序沿TRON转达B1合同→B3/B4/B7门→B6/B5;新枝不自动派队列,研究树只由Claude维护。每个终态记录认知、保留反例、剪枝理由和再开条件。旧O1覆盖不足、O2固定配方无增益与图solver资源/数值失败不泛化为数学方向无效。
|
Mold完整规格SHA256 `91ecc62fb821e9fee31d9166df5263fac663cc22c5ff18549b103aea35c59333`已实读核hash,原文`artifacts/phase2-ml-planning-2026-11-17/mold-h1-spec-readback.md`为本合同**完整规范性附件**,四节全部纳入,不仅引用摘要。以下补齐实际身份、权重、资源和实现边界;旧版等待Mold状态失效。
|
||||||
|
|
||||||
|
Claude维护唯一研究树。最新已实读1794887072和1794887818:B1固定合同优先,B3/B4/B5按已批Mold规格在合同冻结后空核各≤2 worker CPU-h、独立账;H2后续。B6/B7沿1794887342在B3/B4后。每个终态记录认知、反例、剪枝理由和再开条件;旧O1覆盖不足、O2固定配方无增益与solver资源/数值失败不泛化为整个方向无效。
|
||||||
|
|
||||||
## 研究问题与固定对照
|
## 研究问题与固定对照
|
||||||
|
|
||||||
在不增加A的19输入列、不改变同协议训练数据、权重、XGB容量/超参数或测试评分的前提下,把训练目标改为 `r=t_star-c*F`,解码 `t_hat_star=c*F+r_hat`,是否同时改善全场误差、最后位置与顺序?`F`为既存全tet域strict volume CDF,`c`只能来自对应学习池。无因果惩罚、无后处理修正或事后剪裁。不把收益必然归因于新增物理信息:F已在A首列,改变的是固定跳连与学习目标。
|
在不增加A的19输入列、不改变同协议训练数据、权重、XGB容量/超参数或测试评分的前提下,把训练目标改为 `r=t_star-c*F`,解码 `t_hat_star=c*F+r_hat`,是否同时改善全场误差、最后位置与顺序?`F`为既存全tet域strict volume CDF,`c`只能来自对应学习池。无因果惩罚、无后处理修正或事后剪裁。不把收益必然归因于新增物理信息:F已在A首列,改变的是固定跳连与学习目标。
|
||||||
|
|
||||||
Mold须在同一合同最终版明确:c的具体估计量及全VTU/tet端点口径、各池使用哪些训练角色、F浮点精度与t_star一致性、拓扑指标的定义。未决定部分不静默用默认值;其余接口和冻结规则可先准备。
|
Claude `1794886866.775119 / h-ae5d869c`与Mold91ecc62f已固定:每fold×pool的c是该格learning件的 `max(T_on_retained_tet)/t_set` 先组件内等件、再组件等权均值。取已冻结`seconds.npy`的物理T最大值,再以FP64除t_set;不取query或全VTU最大值,不先转FP32。原`gre24_prepare_v2.py`以`y=yall[raw]`存seconds,运行时核hash、raw IDs、节点数和dtype。逐件记录角色、端点/精度/来源hash,拒绝非有限或非正端点比。原outside_tet字段保留但不参与。
|
||||||
|
|
||||||
|
残差用原`target.npy=T/t_set`同域缓存,以FP64减原FP64 F乘c,再转FP32交估计器;启动时核target与seconds/t_set一致。F需原`Vf.npy`及raw ID,检查`float32(F_raw)==float32(features[:,0])`,不能用FP32首列升精度替代。缺失/hash/身份不符停下,不静默重建或降精度。skip保存FP64而A首列FP32,因此不能声称全部运算只有目标改变。c按固定成员顺序作FP64组件内均值、再组件均值,并保存全部端点和权重。
|
||||||
|
|
||||||
|
命名分开:无量纲先验为`c*F (learning clock)`,还原秒数为`t_set*c*F`;原R4(a) EIK秒场是`t_set*F`。新预测保存这两种先验作为同次诊断基线,不增加模型或重新求解EIK。
|
||||||
|
|
||||||
## 数据与拟合单元
|
## 数据与拟合单元
|
||||||
|
|
||||||
|
固定实际权重表为`artifacts/phase2-h1-planning-2026-11-17/clock-freeze-v1/clock-weights.csv`,SHA256 `013bdd8f8596610542ea97e43bf00fb6cba697cbf030153e74224f8864247ae5`,4,463条格×学习件记录含组件键、组件件数、分子/分母和数值权重。完整20格learning/test顺序、逐件缓存hash、节点数、t_set与原A检查点见同根`membership-and-sources.json`,SHA256 `4d30b85d371a95f6c19f10a2388d88c274d82309ad90a4aa11f68cde27738d99`。两文件只读旧元数据生成,未读目标/特征数组、未计算c值。
|
||||||
|
|
||||||
|
grouped沿原`component_id`全部204个实际键,例如`component-ab740d6b82ac47d8`,完整清单见上述固定文件。格内G个学习组件、组件g内n_g个学习件,每件权重严格`1/(G*n_g)`;不按体积/节点数加权。v4原split、成功准备及GBRT访问记录无冻结组件键,采用Mold允许的`part:<完整case>`单件组,成功原train件等权;不借v5键重分组。
|
||||||
|
|
||||||
|
| 协议/池 | fold或split0 学习件/组 | 1 | 2 | 3 | 4 |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| grouped100 | 320/132 | 374/130 | 366/129 | 291/128 | 350/128 |
|
||||||
|
| grouped50 | 190/65 | 178/67 | 166/66 | 173/63 | 116/64 |
|
||||||
|
| grouped25 | 111/34 | 83/34 | 56/33 | 93/31 | 58/34 |
|
||||||
|
| v4 random | 311/311 | 304/304 | 307/307 | 306/306 | 310/310 |
|
||||||
|
|
||||||
|
v4各split件权重依次1/311、1/304、1/307、1/306、1/310。grouped测试件依折121/91/99/119/122;v4成功测试304/311/308/309/305。原FNN validation而属GBRT train的实际成员及准备失败排除名单都列在JSON中。20格训练访问顺序和节点数均与原A/GBRT实际记录逐项相同,grouped组件角色隔离、learning/test不交、每格有理权重和严格为1,见`receipt.json`。c数值仅在主审后按以上已固定名单读取learning端点计算。
|
||||||
|
|
||||||
- 分组主协议:复用 `artifacts/r4bc-execution-2026-11-16/contract.json` 的552件/204组件、五折、25/50/100%三个固定嵌套学习池和原角色。每格一个新H1-RES XGB,合计15。训练支持域全tet节点、单位权、float32、100树/深度8/学习率0.1/平方损失/seed0,沿A。验证/测试不用于新选参;原A检查点与原A/EIK评分保留。
|
- 分组主协议:复用 `artifacts/r4bc-execution-2026-11-16/contract.json` 的552件/204组件、五折、25/50/100%三个固定嵌套学习池和原角色。每格一个新H1-RES XGB,合计15。训练支持域全tet节点、单位权、float32、100树/深度8/学习率0.1/平方损失/seed0,沿A。验证/测试不用于新选参;原A检查点与原A/EIK评分保留。
|
||||||
- v4论文随机协议:复用 `artifacts/gre24-v4-reproduction-2026-11-16/protocol/splits.json` 五个315test/314train原划分及615成功/14原失败准备清单;这是五个独立随机split,非五折CV。每split新H1-RES一个,合计5;原GBRT使用train角色(包含其FNN验证子集),此处沿原GBRT而非擅用FNN学习角色。seed沿原split,原全部失败不补抽。
|
- v4论文随机协议:复用 `artifacts/gre24-v4-reproduction-2026-11-16/protocol/splits.json` 五个315test/314train原划分及615成功/14原失败准备清单;这是五个独立随机split,非五折CV。每split新H1-RES一个,合计5;原GBRT使用train角色(包含其FNN验证子集),此处沿原GBRT而非擅用FNN学习角色。seed沿原split,原全部失败不补抽。
|
||||||
- 总计20次新固定配置拟合,无HPO、无旧模型重训、无新v2下载或留验筛查。两协议数字分开,grouped域是探索后复用,不称全新盲测。
|
- 总计20次新固定配置拟合,无HPO、无旧模型重训、无新v2下载或留验筛查。两协议数字分开,grouped域是探索后复用,不称全新盲测。
|
||||||
@@ -21,22 +40,40 @@ Mold须在同一合同最终版明确:c的具体估计量及全VTU/tet端点
|
|||||||
|
|
||||||
训练/时钟只读当前格允许的训练侧缓存目标,逐件记录访问角色及来源hash;不重新解码原始标签。参数固定,无验证驱动择优。负残差合法,不套用“目标非负”检查到残差;还原到达场后保留负值等物理异常并单列,不悄悄裁剪。
|
训练/时钟只读当前格允许的训练侧缓存目标,逐件记录访问角色及来源hash;不重新解码原始标签。参数固定,无验证驱动择优。负残差合法,不套用“目标非负”检查到残差;还原到达场后保留负值等物理异常并单列,不悄悄裁剪。
|
||||||
|
|
||||||
20次拟合全部终态、模型hash和NA先Git冻结,之后预测;预测完整清单及评分代码再Git冻结,最后统一评分。测试预测函数不得读目标字段,旧A/EIK输出能复用时按hash复用。若新增拓扑指标需要全tet场而旧A只有查询预测,须在主审前列明既有模型的额外预测成本与身份,不偷用查询子图冒充真实tet连通。
|
20次拟合全部终态、模型hash和NA先Git冻结,之后预测;预测完整清单及评分代码再Git冻结,最后统一评分。测试预测函数不得读目标字段。按Claude1794886866,A与H1均生成全tet节点预测,A只加载旧固定模型,不重新训练;原query预测保留,并核全节点预测回取query的一致性。额外A预测计入后处理账。新拓扑指标用fulltet邻接,绝不以query子图代替。
|
||||||
|
|
||||||
## 评分与待核拓扑项
|
新fit严格沿原A访问顺序;numpy1.26.4/xgboost2.1.4及完整库配置固定。20格失败NA和未尝试分别列出;global stop不得伪造全终态或绕过预测屏障。同件曾在另一fold作learning不解除本fold角色限制。无新VTU目标解码。几何仅读Points/Cells并在PointData/CellData前停止,grouped复用原准备geometry.npz及原Rg;v4从其原核验包读取retained-tet几何,与冻结raw_ids/mass核对。v4新增位置诊断的Rg按集总质量质心及`sqrt(sum m_i*||x_i−center||²/sum m_i)`计算并在读评分真场前冻结,明确为v4新增归一化,不冒称原论文指标。
|
||||||
|
|
||||||
|
## 评分与固定拓扑诊断
|
||||||
|
|
||||||
既有分组主指标:组件等权relative L2;同时保留既定最后位置距离/Rg、Kendall tau-b及其失败/未定义分母。固定query IDs和multiplicity只计一次,原同域比较与组件配对描述性区间沿用。v4先报告原全tet三分母RRMSE、<0.1比例和逐split统计;新增顺序/末端指标不得与grouped混汇。
|
既有分组主指标:组件等权relative L2;同时保留既定最后位置距离/Rg、Kendall tau-b及其失败/未定义分母。固定query IDs和multiplicity只计一次,原同域比较与组件配对描述性区间沿用。v4先报告原全tet三分母RRMSE、<0.1比例和逐split统计;新增顺序/末端指标不得与grouped混汇。
|
||||||
|
|
||||||
Claude提出的拓扑项尚待Mold核正:单浇口分流再会合不一定是湿区H0合并;不能称焊线真值。规格需明确原tet图/复形、子或超水平集、并列值、持久性阈值、空间匹配距离、无事件的分母和计算费用。该项最终定义及primary/secondary定位须在运行前一次主审冻结;不因测试效果改变指标。
|
grouped原指标沿固定`s2_custody_statistics.py`:每件5000对tau-b,seed由[2026111410,case数字前缀]派生,零分母未定义;末端平台取最小raw ID。组件配对区间沿`r4bc_common.paired_difference`,2000次组件重采样、seed2026111408、95%percentile/linear分位,差值A误差−H1误差;条件于既有fold/模型。v4新增同域relative L2、同固定抽样tau-b/原ID末点规则及上述Rg,原全tet三分母RRMSE和汇总沿`gre24_features_v2.per_geometry_metrics/appendix_summary`。两协议分表,五次相关随机split不当五个独立数据集。每比较列完整共同件/组件、原失败和未定义分母,不按结果删件。
|
||||||
|
|
||||||
## 工程预算建议(交同一次主审)
|
新增全tet干域H0(-T)为**独立辅助诊断**,Mold附件§3全部强制:每场S独立以`v_i=sum m_j*1[S_j>S_i]/sum m_j`逆时扫描,从S大到小激活顶点及原tet边。按原冻结输出精度读值再转FP64,零并列容差,原值相等整层激活,不加jitter,不以分位舍入改变S的并列。
|
||||||
|
|
||||||
总≤20 worker CPU-h=72000秒,初拟准备/合成/接口3600秒、拟合43200秒、预测/拓扑/评分25200秒,共享累计账,失败CPU计一次;不得自动扩预算。最多4单线程worker,每fit CPU/墙钟各1800秒、RSS8GiB,总RSS36GiB,新增磁盘20GiB,0重试。先grouped fold0/pool100和v4 split0作实际成本检查,成功且余量可容纳全部计划及后处理预留后自动继续,不额外用户go。
|
每层建立“新点平台块—此前旧连通分量”的二部关联图,逐关联连通块处理。无旧分量为区域极大平台出生;k≥2旧分量首次接通为一个复合事件,消亡k−1类。最早出生存活,同龄取出生平台最小raw ID。位置支撑为该复合事件内直接接触≥2不同旧分量的新平台块并集;代表取离支撑质量重心最近的支撑点,同距最小raw ID;保存支撑点数、最大到代表欧氏距离、消亡重数。
|
||||||
|
|
||||||
只读历史费用依据:15个旧A worker合计1474.244179 CPU秒;五个v4 GBRT合计2127.492874 CPU秒(旧v4线程数8,worker CPU不是墙钟)。这是参考,不保证残差拟合成本相同。真实第一格成本与端点/拓扑准备新增费必须另报。CPU布局拟worker8/10/12/14、协调30/31,留0–7给后续GPU feeders;启动前复核主机占用。
|
去无限条和零长度条;至少一条消亡类满足`v_death−v_birth≥0.01`则复合事件只保留一次,0.01是全件排名质量跨度而非干袋体积。候选配对同时满足原tet边长最短路`d≤0.10Rg`及死亡分位差`≤0.05`;Rg须有限正。先最大匹配数、再最小总d/Rg、同解按排序后代表ID对字典序。使用有界最短路,不用欧氏近邻或query补边代替。
|
||||||
|
|
||||||
|
逐fold/pool/arm报告TP/FP/FN、事件precision/recall、匹配d/Rg中位数及数目;零分母undefined。真/预测均空、仅真空、仅预测空、两者非空四类件数、稀有事件计数、平台不确定性、共同可比覆盖和费用全部列出。事件多的件在事件汇总中权重大,不冒称组件等权。无限类不进入有限事件匹配,原末填位置另保留。不能产完整tet预测的臂标缺测,不插值冒充完整场。
|
||||||
|
|
||||||
|
B3先按已批规格在learning真场检查稳定性及是否能定位;不通过则保留原计数/失败并限制指标解释,不按外测效果改阈值,也不否决H1主场指标。逆时合并对应正时干区分裂;光滑3D非退化内点T指数2、2D为1,边界/非光滑仅报图事件。湿H0不等于单浇口绕孔后汇合,无工业焊线或困气真值推断。
|
||||||
|
|
||||||
|
## 固定工程预算与停止(交本次主审)
|
||||||
|
|
||||||
|
总≤20 worker CPU-h=72000秒,准备/合成/几何3600秒、拟合43200秒、全节点A/H1预测/拓扑/评分25200秒,共享累计账且各分账限额,失败CPU计一次;0重试、无GPU,不自动扩预算。每fit CPU/墙钟各1800秒/RSS8GiB,每预测cell CPU/墙钟各1800秒/RSS8GiB,每件拓扑CPU/墙钟各300秒/RSS8GiB;总RSS36GiB,新增磁盘20GiB。诊断超帽该件NA,后处理分账达到停止剩余诊断并报覆盖,不修改阈值。guard读取失败路径peak,采样超量如实记;不得只核成功result。
|
||||||
|
|
||||||
|
保留原线程:grouped最多4单线程worker用8/10/12/14;v4最多2个8线程worker用8–15及16–23,两类不同时派发,协调30/31,0–7留GPU feeder。先grouped fold0/pool100再v4 split0,两首格算入20次;分别以1.25×按学习节点数外推该协议剩余fit费,需容纳余下fit及全部后处理预留才继续。失败或成本不过留证停下。通过后剩余grouped按100→50→25、池内fold0..4,随后v4 split1..4,不重复首格。单格数值/资源失败保留NA不重试;hash/角色/身份不符、总账不完整或累计帽触发global stop,不能伪造完成。实现验收和源码固定通过后唯一启动,不另开用户go循环。
|
||||||
|
|
||||||
|
只读历史费用:15个旧A合计1474.244179 CPU秒,5个v4 GBRT合计2127.492874 CPU秒(不是墙钟);仅作参考,不重复记入新账。真实首格与几何/端点/拓扑成本另报,启动前复核主机占用。
|
||||||
|
|
||||||
H2与H1同一目标的接口在本合同冻结后供Assist架构稿引用。H2先≤2 GPU-h pilot成本门、全部≤16 GPU-h另列唯一合同/一次Claude主审;本合同不启动H2或任何第三实验。
|
H2与H1同一目标的接口在本合同冻结后供Assist架构稿引用。H2先≤2 GPU-h pilot成本门、全部≤16 GPU-h另列唯一合同/一次Claude主审;本合同不启动H2或任何第三实验。
|
||||||
|
|
||||||
## 当前实际准备回执
|
## 当前实际准备回执
|
||||||
|
|
||||||
`artifacts/phase2-h1-planning-2026-11-17/input-and-cost-inventory.json`保存原合同/角色元数据/代码哈希及旧费用来源;没有读取项目目标或特征数组。独立`phase2_residual_math.py`只接受调用方已经固定的c与F,不私设时钟估计器。五项合成检查(负残差/还原、零残差先验、不裁剪、非法输入、置换一致)通过,CPU0.170161秒,纳入本轮准备账;无模型拟合或项目数据访问。Mold规格、拓扑门定义和最终主审尚未收到,因此这里不冒称已冻结可运行科学合同。
|
原`input-and-cost-inventory.json`、五项接口PASS/0.170161秒、六项时钟PASS/0.174718秒原回执保留,无重复运行。此次`clock-freeze-v1/receipt.json`元数据断言PASS/0.225320085秒;已知准备CPU小计0.570199085秒计入3600分账,不称全部未来费用。未读目标/特征数组、未算c数值、未拟合。
|
||||||
|
|
||||||
|
`phase2_h1_worker.py`保留旧初稿字节,尚非全系统验收。按本合同后续须将clock读target改为物理seconds最大值后除t_set,F首列核对改为FP32一致,并完成队列/guard/图/拓扑/冻结/评分实现和必要合成验收。数学6项PASS不扩大为worker或整队列PASS。新版实现及验收随后另固定来源,不能把本次合同固定写成实际启动。
|
||||||
|
|
||||||
|
Claude本次主审对象为完整Mold规格、实际c键/权重、v4单件组、新增Rg和预算/执行条件。主审后沿固定规格实施与验收再唯一启动;实现失败保留并修复,不重复用户授权;科学规格变化回原协作审议。B3/B4/B5各≤2CPUh独立账依已批门接续,H2仍纸面,不因本次文档发布重启任何旧队列。
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
"""Freeze H1 clock membership/weights from metadata only; never load arrays."""
|
||||||
|
import csv
|
||||||
|
from fractions import Fraction
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
OUT = ROOT / 'artifacts/phase2-h1-planning-2026-11-17/clock-freeze-v1'
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.process_time()
|
||||||
|
sources = {}
|
||||||
|
|
||||||
|
def read(relative):
|
||||||
|
p = ROOT / relative
|
||||||
|
raw = p.read_bytes()
|
||||||
|
sources[str(relative)] = hashlib.sha256(raw).hexdigest()
|
||||||
|
return json.loads(raw)
|
||||||
|
|
||||||
|
grouped = read('artifacts/r4bc-execution-2026-11-16/contract.json')
|
||||||
|
oldmodels = read('artifacts/r4bc-execution-2026-11-16/models-terminal.json')
|
||||||
|
vr = Path('artifacts/gre24-v4-reproduction-2026-11-16/protocol')
|
||||||
|
splits = read(vr/'splits.json')
|
||||||
|
prep = read(vr/'preparation-freeze.json')
|
||||||
|
training = read(vr/'training-contract.json')
|
||||||
|
assert training['xgb_threads'] == 8
|
||||||
|
assert len(grouped['parts']) == 552
|
||||||
|
assert len({r['component_id'] for r in grouped['parts']}) == 204
|
||||||
|
assert len(prep['successful']) == 615
|
||||||
|
parts = {'grouped': {}, 'v4_random': {}}
|
||||||
|
cells = []; weights = []
|
||||||
|
|
||||||
|
def register(protocol, case, cache, group):
|
||||||
|
hashes = cache['output_sha256']
|
||||||
|
required = ('seconds.npy', 'target.npy', 'raw_ids.npy', 'Vf.npy', 'features.npy', 'mass.npy', 'Df.npy')
|
||||||
|
assert all(name in hashes for name in required)
|
||||||
|
parts[protocol][case] = dict(case=case, output=cache['output'], nodes=cache['nodes'],
|
||||||
|
t_set=cache['t_scale_seconds'], clock_group=group, output_sha256=hashes,
|
||||||
|
endpoint='max(seconds.npy on retained-tet raw_ids) / t_set')
|
||||||
|
|
||||||
|
for r in grouped['parts']:
|
||||||
|
assert r['nodes'] == r['v5_cache']['nodes']
|
||||||
|
assert r['preparation']['t_set'] == r['v5_cache']['t_scale_seconds']
|
||||||
|
register('grouped', r['case'], r['v5_cache'], r['component_id'])
|
||||||
|
for case, cache in prep['successful'].items():
|
||||||
|
# The frozen original random protocol has no component membership.
|
||||||
|
assert not any(k in cache for k in ('component_id', 'component_key', 'clock_group'))
|
||||||
|
register('v4_random', case, cache, 'part:'+case)
|
||||||
|
|
||||||
|
def cell(protocol, fold, pool, learning, test, seed, threads, baseline, original_access):
|
||||||
|
assert learning and len(learning) == len(set(learning))
|
||||||
|
assert len(test) == len(set(test)) and not set(learning).intersection(test)
|
||||||
|
assert [r['case'] for r in original_access] == learning
|
||||||
|
groups = {}
|
||||||
|
for case in learning:
|
||||||
|
group = parts[protocol][case]['clock_group']
|
||||||
|
groups.setdefault(group, []).append(case)
|
||||||
|
G = len(groups); total = Fraction(0)
|
||||||
|
key = f'{protocol}-fold{fold}-pool{pool}'
|
||||||
|
for group in sorted(groups):
|
||||||
|
n = len(groups[group]); weight = Fraction(1, G*n)
|
||||||
|
for case in groups[group]:
|
||||||
|
total += weight
|
||||||
|
weights.append(dict(cell=key, protocol=protocol, fold=fold, pool=pool,
|
||||||
|
case=case, clock_group=group, group_count=G, parts_in_group=n,
|
||||||
|
numerator=weight.numerator, denominator=weight.denominator,
|
||||||
|
weight_float=float(weight), original_role='learning' if protocol=='grouped' else 'train'))
|
||||||
|
assert total == 1
|
||||||
|
cells.append(dict(index=len(cells), cell=key, protocol=protocol, fold=fold, pool=pool,
|
||||||
|
seed=seed, threads=threads, learning=learning, test=test,
|
||||||
|
learning_parts=len(learning), test_parts=len(test), clock_groups=G,
|
||||||
|
learning_nodes=sum(parts[protocol][case]['nodes'] for case in learning),
|
||||||
|
baseline_model=baseline, clock_value=None, clock_status='NOT_EVALUATED_METADATA_ONLY',
|
||||||
|
exact_weight_sum='1/1', original_fit_access_order_match=True))
|
||||||
|
|
||||||
|
for pool in (100, 50, 25):
|
||||||
|
for fold in range(5):
|
||||||
|
roles = {r['case']: next(a for a in r['assignments'] if a['fold']==fold) for r in grouped['parts']}
|
||||||
|
learning = sorted(case for case,a in roles.items() if a['role']=='learning' and str(pool) in a['learning_pools'])
|
||||||
|
test = sorted(case for case,a in roles.items() if a['role']=='test')
|
||||||
|
# Clock groups cannot leak across held-out roles in this protocol.
|
||||||
|
seen = {}
|
||||||
|
for case,a in roles.items():
|
||||||
|
group = parts['grouped'][case]['clock_group']
|
||||||
|
seen.setdefault(group,set()).add(a['role'])
|
||||||
|
assert all(len(v)==1 for v in seen.values())
|
||||||
|
model = next(m for m in oldmodels['models'] if m['arm']=='A' and m['fold']==fold and m['pool']==pool)
|
||||||
|
assert model['status']=='PASS'
|
||||||
|
oldout = Path(model['model_path']).parent.relative_to(ROOT)
|
||||||
|
access = read(oldout/'access.json'); result = read(oldout/'result.json')
|
||||||
|
assert all(r['role']=='learning' and r['full'] for r in access)
|
||||||
|
assert result['learning_parts']==len(learning)
|
||||||
|
assert result['learning_nodes']==sum(parts['grouped'][case]['nodes'] for case in learning)
|
||||||
|
cell('grouped',fold,pool,learning,test,0,1,
|
||||||
|
dict(path=model['model_path'],sha256=model['model_sha256'],format='joblib'),access)
|
||||||
|
|
||||||
|
for split in splits:
|
||||||
|
fold=split['index']; learning=[x for x in split['train'] if x in prep['successful']]
|
||||||
|
test=[x for x in split['test'] if x in prep['successful']]
|
||||||
|
result=read(vr/f'fits/split-{fold}/GBRT/result.json')
|
||||||
|
access=read(vr/f'fits/split-{fold}/GBRT/training-target-access.json')
|
||||||
|
assert all(r['role']=='train' for r in access)
|
||||||
|
assert result['train_geometries']==len(learning)
|
||||||
|
assert result['train_nodes']==sum(parts['v4_random'][case]['nodes'] for case in learning)
|
||||||
|
assert set(split['fnn_validation']).issubset(split['train'])
|
||||||
|
assert result['parameters']['n_jobs']==8
|
||||||
|
cell('v4_random',fold,100,learning,test,split['seed'],8,
|
||||||
|
dict(path=result['checkpoint'],sha256=result['checkpoint_sha256'],format='ubj'),access)
|
||||||
|
cells[-1]['included_original_fnn_validation']=sorted(set(split['fnn_validation']) & set(learning))
|
||||||
|
cells[-1]['excluded_original_train_preparation_failures']=[x for x in split['train'] if x not in prep['successful']]
|
||||||
|
|
||||||
|
# No overwrite of an existing fixed review packet.
|
||||||
|
OUT.mkdir(parents=True, exist_ok=False)
|
||||||
|
fields=list(weights[0])
|
||||||
|
with (OUT/'clock-weights.csv').open('w',newline='') as stream:
|
||||||
|
writer=csv.DictWriter(stream,fieldnames=fields);writer.writeheader();writer.writerows(weights)
|
||||||
|
payload=dict(version='phase2-h1-clock-membership-v1', status='FROZEN_FOR_MAIN_REVIEW_NOT_EXECUTION_APPROVAL',
|
||||||
|
c_policy=dict(grouped='original component_id; 1/(learning component count * learning parts in component)',
|
||||||
|
v4_random='no component key in original protocol; part:<original case>, equal successful original GBRT train parts'),
|
||||||
|
cells=cells, parts=parts, source_sha256=sources,
|
||||||
|
target_arrays_read=False, feature_arrays_read=False, clock_values_computed=False,
|
||||||
|
fit_started=False, new_decodes=0)
|
||||||
|
(OUT/'membership-and-sources.json').write_text(json.dumps(payload,indent=2)+'\n')
|
||||||
|
receipt=dict(status='PASS_METADATA_INVARIANTS', cells=len(cells), weight_rows=len(weights),
|
||||||
|
grouped_parts=552, grouped_components=204, v4_successful_parts=615,
|
||||||
|
exact_weight_sums=True, original_access_order_match=True, learning_test_disjoint=True,
|
||||||
|
grouped_component_role_isolation=True, target_arrays_read=False, feature_arrays_read=False,
|
||||||
|
cpu_seconds=time.process_time()-start,
|
||||||
|
files={p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in OUT.iterdir()})
|
||||||
|
(OUT/'receipt.json').write_text(json.dumps(receipt,indent=2)+'\n')
|
||||||
|
print(json.dumps(receipt))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
"""H1-RES fixed-XGB worker. No queue or implicit execution approval.
|
||||||
|
|
||||||
|
The reviewed contract binds training/test roles, source metadata, precision,
|
||||||
|
clock weighting and source hashes. Test predictions never load target arrays.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from threadpoolctl import threadpool_limits
|
||||||
|
from gre24_models import xgb_model
|
||||||
|
from phase2_residual_math import learning_clock, residual_target, decode_seconds
|
||||||
|
|
||||||
|
|
||||||
|
def sha(path):
|
||||||
|
h = hashlib.sha256()
|
||||||
|
with Path(path).open('rb') as source:
|
||||||
|
for block in iter(lambda: source.read(4*1024**2), b''): h.update(block)
|
||||||
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def save(path, value):
|
||||||
|
path = Path(path); tmp = path.with_suffix(path.suffix+'.tmp')
|
||||||
|
tmp.write_text(json.dumps(value, indent=2, allow_nan=False)+'\n'); tmp.replace(path)
|
||||||
|
|
||||||
|
|
||||||
|
def checked(path, digest):
|
||||||
|
if sha(path) != digest: raise ValueError('Pinned file mismatch: '+str(path))
|
||||||
|
return Path(path)
|
||||||
|
|
||||||
|
|
||||||
|
def contract(root):
|
||||||
|
import xgboost
|
||||||
|
if np.__version__ != '1.26.4' or xgboost.__version__ != '2.1.4':
|
||||||
|
raise ValueError('Frozen library version differs')
|
||||||
|
c = json.loads((root/'contract.json').read_text())
|
||||||
|
if c.get('version') != 'phase2-h1-res-v1' or not c.get('main_review'):
|
||||||
|
raise PermissionError('No fixed reviewed H1 contract')
|
||||||
|
for p, h in c['code_sha256'].items(): checked(p, h)
|
||||||
|
for p, h in c['source_sha256'].items(): checked(p, h)
|
||||||
|
return c
|
||||||
|
|
||||||
|
|
||||||
|
def role_rows(c, job, role):
|
||||||
|
if role not in ('learning', 'test'): raise ValueError('Unknown role')
|
||||||
|
if set(job['learning']) & set(job['test']): raise PermissionError('Training/test overlap')
|
||||||
|
if len(job[role]) != len(set(job[role])): raise ValueError('Repeated case')
|
||||||
|
# Contract builder must cross-check these frozen roles against original
|
||||||
|
# source contracts. Here a role cannot be expanded through row metadata.
|
||||||
|
return [c['parts'][job['protocol']][case] for case in job[role]]
|
||||||
|
|
||||||
|
|
||||||
|
def load_features(row):
|
||||||
|
source = Path(row['output']); hashes = row['output_sha256']
|
||||||
|
f = np.load(checked(source/'Vf.npy', hashes['Vf.npy']), allow_pickle=False)
|
||||||
|
x = np.load(checked(source/'features.npy', hashes['features.npy']), mmap_mode='r', allow_pickle=False)
|
||||||
|
ids = np.load(checked(source/'raw_ids.npy', hashes['raw_ids.npy']), allow_pickle=False)
|
||||||
|
if x.shape != (row['nodes'], 19) or f.shape != (row['nodes'],) or ids.shape != f.shape:
|
||||||
|
raise ValueError('Feature/node identity shape mismatch')
|
||||||
|
if f.dtype != np.dtype('float64') or not np.array_equal(x[:, 0], f):
|
||||||
|
raise ValueError('Original float64 F differs from frozen first column')
|
||||||
|
if np.any(np.diff(ids) <= 0) or not np.isfinite(x).all(): raise ValueError('Bad IDs/features')
|
||||||
|
return np.asarray(x, dtype=np.float32), f, ids
|
||||||
|
|
||||||
|
|
||||||
|
def fit(root, c, job):
|
||||||
|
out = root/'fits'/f"job-{job['index']:02d}"; out.mkdir(parents=True, exist_ok=False)
|
||||||
|
save(out/'started.json', {'unix': time.time(), 'job': job, 'contract_sha256': sha(root/'contract.json')})
|
||||||
|
cpu = time.process_time(); access = []; rows = role_rows(c, job, 'learning')
|
||||||
|
end_ratios, groups = [], []
|
||||||
|
# First pass: only learning-role retained-tet targets for this cell's clock.
|
||||||
|
for row in rows:
|
||||||
|
path = Path(row['output'])/'target.npy'
|
||||||
|
access.append({'case': row['case'], 'role': 'learning', 'purpose': 'clock', 'path': str(path)})
|
||||||
|
save(out/'target-access.json', access)
|
||||||
|
y = np.load(checked(path, row['output_sha256']['target.npy']), mmap_mode='r', allow_pickle=False)
|
||||||
|
if y.shape != (row['nodes'],) or not np.isfinite(y).all() or np.any(y < 0): raise ValueError('Invalid learning target')
|
||||||
|
end_ratios.append(float(y.max())); groups.append(row['clock_group'])
|
||||||
|
clock = learning_clock(end_ratios, groups)
|
||||||
|
save(out/'clock.json', {'c': clock, 'source': 'learning retained-tet max(T/t_set), component-equal then part-equal',
|
||||||
|
'parts': [row['case'] for row in rows], 'end_ratios': end_ratios, 'groups': groups})
|
||||||
|
n = sum(row['nodes'] for row in rows); x = np.empty((n, 19), np.float32); y = np.empty(n, np.float32); cursor = 0
|
||||||
|
for row in rows:
|
||||||
|
xx, f, ids = load_features(row)
|
||||||
|
path = checked(Path(row['output'])/'target.npy', row['output_sha256']['target.npy'])
|
||||||
|
target = np.load(path, mmap_mode='r', allow_pickle=False)
|
||||||
|
count = len(f); x[cursor:cursor+count] = xx
|
||||||
|
y[cursor:cursor+count] = residual_target(target, f, clock, fit_dtype='float32'); cursor += count
|
||||||
|
access.append({'case': row['case'], 'role': 'learning', 'purpose': 'residual_fit', 'path': str(path)})
|
||||||
|
save(out/'target-access.json', access)
|
||||||
|
with threadpool_limits(job['threads']):
|
||||||
|
model = xgb_model(job['seed'], job['threads'])
|
||||||
|
save(out/'progress.json', {'stage': 'FIT', 'nodes': n, 'clock': clock})
|
||||||
|
model.fit(x, y, verbose=False)
|
||||||
|
checkpoint = out/'model.ubj'; model.save_model(checkpoint)
|
||||||
|
(out/'xgboost-config.json').write_text(model.get_booster().save_config())
|
||||||
|
save(out/'result.json', {'status': 'FIT_COMPLETE_NO_TEST_SCORES', 'checkpoint': str(checkpoint),
|
||||||
|
'checkpoint_sha256': sha(checkpoint), 'clock_sha256': sha(out/'clock.json'), 'c': clock,
|
||||||
|
'learning_nodes': n, 'learning_parts': len(rows), 'cpu_seconds': time.process_time()-cpu,
|
||||||
|
'test_labels_read': False, 'new_decodes': 0, 'retry': False})
|
||||||
|
|
||||||
|
|
||||||
|
def predict(root, c, job):
|
||||||
|
import joblib
|
||||||
|
import xgboost
|
||||||
|
proof = json.loads((root/'models-git-freeze.json').read_text())
|
||||||
|
if not proof.get('commit') or not proof.get('checkout'):
|
||||||
|
raise PermissionError('All-terminal model Git freeze missing or mismatched')
|
||||||
|
for rel in ['contract.json', 'batch-complete.json', 'models-terminal.json']:
|
||||||
|
path = root/rel; expected = proof['sha256'][rel]; checked(path, expected)
|
||||||
|
repository_path = str(path.resolve().relative_to(Path.cwd()))
|
||||||
|
raw = subprocess.check_output(['git', 'show', proof['commit']+':'+repository_path], cwd=proof['checkout'])
|
||||||
|
if hashlib.sha256(raw).hexdigest() != expected: raise PermissionError('Git freeze differs from local files')
|
||||||
|
terminal = json.loads((root/'batch-complete.json').read_text())
|
||||||
|
if terminal['global_stop'] or not terminal['accounting_complete'] or terminal['attempted'] != len(c['jobs']):
|
||||||
|
raise PermissionError('Fit queue not complete')
|
||||||
|
freeze = json.loads((root/'models-terminal.json').read_text())
|
||||||
|
if len(freeze['models']) != len(c['jobs']): raise PermissionError('Incomplete model manifest')
|
||||||
|
entry = next(r for r in freeze['models'] if r['index'] == job['index'])
|
||||||
|
if entry['status'] != 'PASS': raise ValueError('No checkpoint for failed cell')
|
||||||
|
out = root/'predictions'/f"job-{job['index']:02d}"; out.mkdir(parents=True, exist_ok=False)
|
||||||
|
model = xgboost.XGBRegressor(); model.load_model(checked(entry['checkpoint'], entry['checkpoint_sha256']))
|
||||||
|
old = job['baseline_model']; checked(old['path'], old['sha256'])
|
||||||
|
if old['format'] == 'joblib':
|
||||||
|
baseline = joblib.load(old['path'])
|
||||||
|
elif old['format'] == 'ubj':
|
||||||
|
baseline = xgboost.XGBRegressor(); baseline.load_model(old['path'])
|
||||||
|
else:
|
||||||
|
raise ValueError('Unsupported frozen A checkpoint format')
|
||||||
|
clock = json.loads(checked(entry['clock_path'], entry['clock_sha256']).read_text())['c']
|
||||||
|
index = []; cpu = time.process_time()
|
||||||
|
with threadpool_limits(job['threads']):
|
||||||
|
for row in role_rows(c, job, 'test'):
|
||||||
|
x, f, ids = load_features(row) # No target.npy load on this path.
|
||||||
|
seconds = decode_seconds(model.predict(x), f, clock, row['t_set'])
|
||||||
|
old_seconds = np.asarray(baseline.predict(x), dtype=np.float64)*row['t_set']
|
||||||
|
if old_seconds.shape != seconds.shape or not np.isfinite(old_seconds).all(): raise ValueError('Invalid A prediction')
|
||||||
|
path = out/(row['case']+'.npz')
|
||||||
|
np.savez_compressed(path, seconds=seconds, A_seconds=old_seconds, cF_seconds=clock*f*row['t_set'],
|
||||||
|
EIK_seconds=f*row['t_set'], raw_ids=ids)
|
||||||
|
index.append({'case': row['case'], 'path': str(path), 'sha256': sha(path),
|
||||||
|
'negative_predictions': int(np.sum(seconds < 0)), 'nodes': len(ids)})
|
||||||
|
save(out/'progress.json', {'parts': len(index), 'cpu_seconds': time.process_time()-cpu})
|
||||||
|
save(out/'index.json', index)
|
||||||
|
save(out/'result.json', {'status': 'PREDICTIONS_COMPLETE_NO_SCORES', 'index_sha256': sha(out/'index.json'),
|
||||||
|
'cpu_seconds': time.process_time()-cpu, 'target_values_read': False})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(); parser.add_argument('root', type=Path)
|
||||||
|
parser.add_argument('mode', choices=['fit', 'predict']); parser.add_argument('index', type=int)
|
||||||
|
args = parser.parse_args(); start = time.process_time()
|
||||||
|
try:
|
||||||
|
config = contract(args.root); selected = config['jobs'][args.index]
|
||||||
|
if selected['index'] != args.index: raise ValueError('Job index mismatch')
|
||||||
|
(fit if args.mode == 'fit' else predict)(args.root, config, selected)
|
||||||
|
except Exception as exc:
|
||||||
|
dest = args.root/'failures'; dest.mkdir(exist_ok=True)
|
||||||
|
save(dest/f'{args.mode}-{args.index:02d}.json', {'type': type(exc).__name__, 'message': str(exc),
|
||||||
|
'traceback': traceback.format_exc(), 'pid': os.getpid(), 'cpu_seconds': time.process_time()-start,
|
||||||
|
'retry': False})
|
||||||
|
raise
|
||||||
@@ -6,6 +6,25 @@ in the reviewed contract. Passing F explicitly avoids a hidden extra feature.
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def learning_clock(end_ratios, component_ids):
|
||||||
|
"""Mean over components of mean retained-tet-end/t_set per learning part.
|
||||||
|
|
||||||
|
For the random v4 protocol each part can be its own unit, if the final
|
||||||
|
specification chooses part weighting. Caller enforces training roles.
|
||||||
|
"""
|
||||||
|
ratios = np.asarray(end_ratios, dtype=np.float64)
|
||||||
|
if ratios.ndim != 1 or not len(ratios) or len(component_ids) != len(ratios):
|
||||||
|
raise ValueError('Clock row count mismatch')
|
||||||
|
if not np.isfinite(ratios).all() or np.any(ratios <= 0):
|
||||||
|
raise ValueError('Invalid retained-tet endpoint ratio')
|
||||||
|
groups = {}
|
||||||
|
for group, ratio in zip(component_ids, ratios):
|
||||||
|
if not isinstance(group, str) or not group:
|
||||||
|
raise ValueError('Missing clock group identity')
|
||||||
|
groups.setdefault(group, []).append(float(ratio))
|
||||||
|
return float(np.mean([np.mean(v) for v in groups.values()]))
|
||||||
|
|
||||||
|
|
||||||
def prior(cdf, clock):
|
def prior(cdf, clock):
|
||||||
f = np.asarray(cdf)
|
f = np.asarray(cdf)
|
||||||
if f.ndim != 1 or f.dtype.kind != 'f' or not len(f):
|
if f.ndim != 1 or f.dtype.kind != 'f' or not len(f):
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
"""Synthetic interface checks only; no model fit or project data access."""
|
"""Synthetic interface checks only; no model fit or project data access."""
|
||||||
import unittest
|
import unittest
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from phase2_residual_math import prior, residual_target, decode_seconds
|
from phase2_residual_math import prior, residual_target, decode_seconds, learning_clock
|
||||||
|
|
||||||
|
|
||||||
class ResidualInterfaceTests(unittest.TestCase):
|
class ResidualInterfaceTests(unittest.TestCase):
|
||||||
|
def test_component_equal_clock_not_node_or_part_weighted(self):
|
||||||
|
self.assertEqual(learning_clock([1., 3., 10.], ['a', 'a', 'b']), 6.)
|
||||||
|
self.assertAlmostEqual(learning_clock([1., 3., 10.], ['a', 'b', 'c']), 14./3)
|
||||||
|
with self.assertRaises(ValueError): learning_clock([], [])
|
||||||
|
with self.assertRaises(ValueError): learning_clock([0.], ['a'])
|
||||||
|
|
||||||
def test_negative_residual_and_exact_reconstruction(self):
|
def test_negative_residual_and_exact_reconstruction(self):
|
||||||
f = np.array([0., .25, .75]); y = np.array([0., .125, .5])
|
f = np.array([0., .25, .75]); y = np.array([0., .125, .5])
|
||||||
r = residual_target(y, f, 2., fit_dtype='float64')
|
r = residual_target(y, f, 2., fit_dtype='float64')
|
||||||
|
|||||||
Reference in new issue
Block a user