fix+exp: 轮次35(补)——gaps/gm_groups 拒绝行数不符的 xf;撤回两次不存在的"合并调用"收益

- 探测脚本把认证点当成与特征无关的已知量,据此测出的 共享cum_xf −4.3ms / 合并一次调用 −8.1ms
  都不成立:真实顺序是 特征(q)→推理→候选→认证点,同一次规划内既不能共享 xf 也不能合并 gaps
  只有轮次34 已落地的 gm_groups 复用同姿态 xf(−3.4ms,22项指标逐位不变)是真的
- 守卫:xf 行数与 q 不符时抛错(之前会静默按别的行做宽相位,实测触发 CUDA device-side assert)
- 测试 34→35 项;check_parity 仍 PASS(2000样本,间隙差 2.52e-13 mm、碰撞布尔差 0、特征差 5.96e-08)
This commit is contained in:
cbb
2026-10-20 21:06:35 +08:00
parent 296cd17f98
commit ee7fe829ac
3 changed files with 28 additions and 2 deletions
+11 -2
View File
@@ -107,6 +107,15 @@ class Kin:
for a in range(7) for b in range(a + 2, 7)])
# ---------------- 运动学 ----------------
def _checked_xf(self, q, xf):
"""xf 是按行对应 q 的位姿数组,行数不匹配会静默广播出错(宽相位筛到别的行 ⇒ device assert 或错间隙)。"""
if xf is None:
return self.cum_xf(q)
Rs, Ts = xf
if Rs.shape[0] != q.shape[0] or Ts.shape[0] != q.shape[0]:
raise ValueError('xf 的行数 %d 与 q 的行数 %d 不符' % (Rs.shape[0], q.shape[0]))
return xf
def cum_xf(self, q):
"""q: [B,6] 度 → Rs [B,7,3,3], Ts [B,7,3]"""
B = q.shape[0]
@@ -176,7 +185,7 @@ class Kin:
2026-10-19(用户实测 4096 点 cap 40 峰值 4.46 GiB 全在拼接 8.6e7 对的 b/i/j/gap):
默认只返回 gm,每块算完就丢掉胶囊对,峰值只剩单块。
"""
xf = xf if xf is not None else self.cum_xf(q)
xf = self._checked_xf(q, xf)
Rs, Ts = xf
B = q.shape[0]
step = max(1, self.COARSE_ENTRIES // int(self.cp_a.shape[0]))
@@ -248,7 +257,7 @@ class Kin:
sel = torch.isin(cg, torch.tensor([min(a, b) * 7 + max(a, b) for a, b in gp], device=q.device))
self._gp = (m, sel, sel.nonzero(as_tuple=True)[0]); self._gp_key = key
self._gp49, sel, idx = self._gp
xf = xf if xf is not None else self.cum_xf(q); Rs, Ts = xf; B = q.shape[0]
xf = self._checked_xf(q, xf); Rs, Ts = xf; B = q.shape[0]
with torch.no_grad():
cc = torch.einsum('bkij,kj->bki', Rs[:, self.cl_g], self.cl_c.to(q.dtype)) + Ts[:, self.cl_g]
d2 = (cc[:, self.cp_a[idx]] - cc[:, self.cp_b[idx]]).pow(2).sum(-1)