fix: 闭环失败定位与显存修复——新增 ml/eval/diag_cl.py(Python/JS 特征口径、同噪声动作差、碰撞时刻/组对、开安全层到达率);kin.gaps 按幸存胶囊对数(PAIR_BUDGET=2e6)自动分块(实测原 4096 点 cap 40 峰值约 30 GB);dagger/collect.py cap=gap_min+1 分块;新增 docs/本机执行清单.md(本机计算唯一要求清单)

This commit is contained in:
Hark
2026-10-18 18:02:14 +00:00
parent 0b47905a1c
commit 573082df26
5 changed files with 216 additions and 1 deletions
+11 -1
View File
@@ -16,6 +16,8 @@ from ml.data import load_tasks
from ml.model.policy import build
from ml.sim.closed_loop import rollout, goal_err, tasks_to_tensors, DT
GAP_CHUNK = 1024 # 每次 kin.gaps 的查询点数上限
def main():
ap = argparse.ArgumentParser()
@@ -41,8 +43,14 @@ def main():
tr = per['traj'].to(a.device) # [B,T,6]
B, Tn, _ = tr.shape
_, T, R, _, _ = tasks_to_tensors(tb, a.device)
# 2026-10-19 修(用户实测):原来一次喂 64 题 × 64 步 = 4096 点、cap=40 mm 给 kin.gaps,40 mm 内幸存的胶囊对太多,
# 峰值把显存 / 内存吃满。这里只需判断"≤0(碰撞)"和"> gap_min(起点地板)",cap 取 gap_min+1 即可,
# 且按 GAP_CHUNK 个点分块,用完即释放。
cap = gap_min + 1.0
flat = tr.reshape(-1, 6)
with torch.no_grad():
g = torch.cat([kin.gaps(tr[:, s:s + 64].reshape(-1, 6), 40.0)['gm'].min(-1).values.view(B, -1) for s in range(0, Tn, 64)], 1)
g = torch.cat([kin.gaps(flat[s:s + GAP_CHUNK], cap)['gm'].min(-1).values for s in range(0, flat.shape[0], GAP_CHUNK)]).view(B, Tn)
del flat
for b, t in enumerate(tb):
hit = (g[b] <= 0).nonzero()
c = int(hit[0]) if hit.numel() else Tn
@@ -58,6 +66,8 @@ def main():
if e.item() < 5 and (not t.get('R') or oe.item() < 5): stat['rej_near'] += 1; continue
out.append({'q0': [round(v, 3) for v in q[0].tolist()], 'T': t['T'], 'R': t.get('R'), 'cat': t.get('cat', 'A'),
'src': {'tid': t['tid'], 'k': k, 'col': bool(hit.numel())}})
del tr, g, per
if a.device.startswith('cuda'): torch.cuda.empty_cache()
print(f'[dagger] {min(i + a.bs, len(tasks))}/{len(tasks)} 题,起点 {len(out)}', flush=True)
stat['states'] = len(out)
rng.shuffle(out)