第五轮:锁/续跑/超时/自动分支/R4 探针与 encode-once/控制台加固;阶段内断点续跑(gen 按条、prep 按 shard、训练与 APG 定时原子存档+体面停止);分歧以实现方意见为准
This commit is contained in:
+15
-3
@@ -7,8 +7,19 @@ import torch
|
||||
from ml.common.features import wrap180
|
||||
|
||||
|
||||
def min_gap_chunked(kin, q, cap=0.5, chunk=512):
|
||||
"""分块算最小间隙:随机位形每个约 2800 个幸存胶囊对、峰值约 1.5 MB/位形,一次 4 万位形会爆内存/显存(2026-10-18 实测出题 OOM),每块 512"""
|
||||
def auto_chunk(kin, mb_per_q, lo=256, hi=8192):
|
||||
"""2026-10-18 第五轮(审查 N-6):分块大小按设备空闲显存定,用掉其 1/4。
|
||||
两处每位形峰值不同不是矛盾:kin.gaps 按 (胶囊对下限 + cap)² 筛候选对,cap=0.5 mm 时幸存约 2800 对(≈1.5 MB/位形),
|
||||
column_gap 用 cap=40 mm,40 mm 内幸存的对多一个量级(≈20 MB/位形)。CPU 上取下限 256。"""
|
||||
if kin.lo.device.type == 'cuda':
|
||||
free = torch.cuda.mem_get_info(kin.lo.device)[0]
|
||||
return int(max(lo, min(hi, free * 0.25 / (mb_per_q * 1e6))))
|
||||
return lo
|
||||
|
||||
|
||||
def min_gap_chunked(kin, q, cap=0.5, chunk=None):
|
||||
"""分块算最小间隙:一次 4 万位形会爆内存/显存(2026-10-18 实测出题 OOM);块大小见 auto_chunk(≈1.5 MB/位形)"""
|
||||
chunk = chunk or auto_chunk(kin, 1.5)
|
||||
return torch.cat([kin.gaps(q[i:i + chunk], cap)['gm'].min(-1).values for i in range(0, q.shape[0], chunk)])
|
||||
|
||||
|
||||
@@ -33,7 +44,8 @@ def straight_blocked(kin, a, b, n=24):
|
||||
return (min_gap_chunked(kin, pts) <= 0).view(a.shape[0], n).any(-1)
|
||||
|
||||
|
||||
def column_gap(kin, q, chunk=256):
|
||||
def column_gap(kin, q, chunk=None):
|
||||
chunk = chunk or auto_chunk(kin, 20.0) # cap=40 → ≈20 MB/位形
|
||||
out = []
|
||||
for s in range(0, q.shape[0], chunk): # 与 min_gap_chunked 一样分块防 OOM
|
||||
gm = kin.gaps(q[s:s + chunk], 40)['gm']
|
||||
|
||||
Reference in New Issue
Block a user