第六、七轮:离线 ort/WebGPU、R9 查看器整周期、安全层截止下沉、enc_once 前瞻 bug(feat 动态轴)、UTF-8、断点 RNG 续跑与 --stop-at、R2 池无关性自检、R8 出题缓存、本机自检 selftest、冒烟 smoke;遗留清单并入审查文档第六节
This commit is contained in:
+19
-1
@@ -6,7 +6,7 @@
|
||||
训练循环据此先存 last.pt 再以 143 退出。Windows 上 taskkill /F 是硬杀、收不到信号,
|
||||
所以控制台「停止」先写 STOP 文件、等进程自己存档退出,超时才硬杀(见 monitor.Job.stop)。
|
||||
"""
|
||||
import os, signal, time
|
||||
import os, random, signal, time
|
||||
import torch
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
@@ -42,3 +42,21 @@ class Saver:
|
||||
return False
|
||||
|
||||
def mark(self): self.last = time.time()
|
||||
|
||||
|
||||
def rng_state():
|
||||
"""2026-10-18 第七轮(遗留:续跑后数值轨迹与不断点不一致):随机数状态一起存档。
|
||||
训练取 batch 用 torch.randint(全局生成器,CUDA 上取 CUDA 生成器)、噪声用 torch.randn、APG 选题用 random.choices,
|
||||
三者状态都恢复后,续跑的 batch 顺序与噪声与一口气跑完一致(同一设备、同一版本;cuDNN 非确定算子另计)。"""
|
||||
d = {'torch': torch.get_rng_state(), 'py': random.getstate()}
|
||||
if torch.cuda.is_available(): d['cuda'] = torch.cuda.get_rng_state_all()
|
||||
return d # 不存 numpy 状态:训练不用 np.random,且 ndarray 过不了 torch.load 的 weights_only 默认
|
||||
|
||||
|
||||
def set_rng_state(d):
|
||||
if not d: return False
|
||||
torch.set_rng_state(d['torch'].cpu() if hasattr(d['torch'], 'cpu') else d['torch']); random.setstate(d['py'])
|
||||
if 'cuda' in d and torch.cuda.is_available():
|
||||
try: torch.cuda.set_rng_state_all([t.cpu() for t in d['cuda']])
|
||||
except Exception: pass
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user