test(harness): 补 _ladder_units 直测 + 澄清 gate 观测表 unit_id 口径注释
M1:quadrant_pair / gate_evidence 的 question_id 列注释与 write_* docstring 更正为承载 unit_id(single=question_id、pair=pair_id),提示逐题明细在 predictions 表溯源、按 pair_id join 真实 question 表会 join 不上。 M2:给 _ladder_units 补直接单测——纯非 AR 恒等(unit 序==原题序、 unit_id==question_id)、混格交错保持信息阶梯序(按单元最早出现下标重排、 pair 整锁)、且与 build_units 的 single-first 默认序显式区分(防阶梯序被污染)。
This commit is contained in:
@@ -87,6 +87,8 @@ _HOLDOUT_COLS: dict[str, str] = {
|
||||
_QUADRANT_COLS: dict[str, str] = {
|
||||
"epoch": "INTEGER",
|
||||
"step": "INTEGER",
|
||||
# question_id 列承载 unit_id(single=question_id,pair=pair_id);
|
||||
# 逐题明细在 predictions 表溯源,按 pair_id join 真实 question 表会 join 不上。
|
||||
"question_id": "TEXT",
|
||||
"task_type": "TEXT",
|
||||
"prev_correct": "INTEGER",
|
||||
@@ -98,6 +100,8 @@ _GATE_EVIDENCE_COLS: dict[str, str] = {
|
||||
"epoch": "INTEGER",
|
||||
"step": "INTEGER",
|
||||
"task_type": "TEXT",
|
||||
# question_id 列承载 unit_id(single=question_id,pair=pair_id);
|
||||
# 逐题明细在 predictions 表溯源,按 pair_id join 真实 question 表会 join 不上。
|
||||
"question_id": "TEXT",
|
||||
"block_idx": "INTEGER",
|
||||
"baseline_correct": "INTEGER",
|
||||
@@ -275,7 +279,7 @@ def write_quadrant_pairs(
|
||||
step: int,
|
||||
pairs: list[dict[str, Any]],
|
||||
) -> None:
|
||||
"""落 quadrant_pair 多行:fast gate 后逐题四象限(prev/curr 翻转 + category)落库。
|
||||
"""落 quadrant_pair 多行:fast gate 后按 **unit** 四象限(prev/curr 翻转 + category)落库。
|
||||
|
||||
参数:
|
||||
db_path: SQLite 路径。
|
||||
@@ -283,7 +287,10 @@ def write_quadrant_pairs(
|
||||
epoch: 轮次(1-based)。
|
||||
step: epoch 内 step 序号(0-based)。
|
||||
pairs: 每条含 question_id/task_type/prev_correct/curr_correct/category;
|
||||
prev_correct/curr_correct 为 bool,写库前转 0/1。
|
||||
question_id 字段承载 **unit_id**(single=question_id,pair=pair_id,
|
||||
与 gate e-process 同粒度)——逐题明细在 predictions 表溯源,按 pair_id
|
||||
join 真实 question 表会 join 不上;prev_correct/curr_correct 为 bool,
|
||||
写库前转 0/1。
|
||||
|
||||
关键实现:
|
||||
用 insert_many 批量落库;pairs 为空时只建表不插入(fast gate 无翻转的极端情况)。
|
||||
@@ -326,16 +333,18 @@ def write_gate_evidence(
|
||||
step: int,
|
||||
rows: list[dict[str, Any]],
|
||||
) -> None:
|
||||
"""落 gate_evidence 逐题行:CE-Gate 每次决策的可回放审计记录。
|
||||
"""落 gate_evidence 单元行:CE-Gate 每次决策的可回放审计记录(unit 口径)。
|
||||
|
||||
参数:
|
||||
db_path: SQLite 路径。
|
||||
run_id: 训练 run ID。
|
||||
epoch: 该 gate 所属的轮次(1-based)。
|
||||
step: epoch 内 step 序号(0-based)。
|
||||
rows: 每题一行,含 question_id/task_type/block_idx/baseline_correct/
|
||||
candidate_correct/e_value(该题所在块判定后的累计 e 值)/
|
||||
stop_reason(仅最后一题携带最终 stop_reason,其余空串)。
|
||||
rows: 每 **单元** 一行,含 question_id/task_type/block_idx/baseline_correct/
|
||||
candidate_correct/e_value(该单元所在块判定后的累计 e 值)/
|
||||
stop_reason(仅最后一单元携带最终 stop_reason,其余空串)。
|
||||
question_id 字段承载 **unit_id**(single=question_id,pair=pair_id)——
|
||||
逐题明细在 predictions 表溯源,按 pair_id join 真实 question 表会 join 不上。
|
||||
|
||||
关键实现:
|
||||
逐行 insert(非 insert_many),保证每行独立事务。
|
||||
|
||||
Reference in New Issue
Block a user