Handle recompute and verify closeness in dumper (#19564)

This commit is contained in:
fzyzcjy
2026-02-28 18:07:44 +08:00
committed by GitHub
parent 63a4778542
commit 40facdb28c
11 changed files with 557 additions and 13 deletions
+10 -5
View File
@@ -2,12 +2,12 @@ import functools
import os
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Optional, Tuple
from typing import Any, Callable, Dict, Optional, Tuple
import polars as pl
import torch
_TYPED_FIELDS: list[tuple[str, type]] = [("rank", int)]
LOAD_FAILED: object = object()
LOAD_FAILED: object = object()
@@ -19,9 +19,9 @@ def parse_meta_from_filename(path: Path) -> Dict[str, Any]:
if "=" in kv:
k, v = kv.split("=", 1)
result[k] = v
for field, converter in _TYPED_FIELDS:
if field in result:
result[field] = converter(result[field])
for field_name, converter in _TYPED_FIELDS:
if field_name in result:
result[field_name] = converter(result[field_name])
return result
@@ -177,4 +177,9 @@ def read_tokenizer_path(directory: Path) -> Optional[str]:
return None
_TYPED_FIELDS: list[tuple[str, Callable[[str], Any]]] = [
("rank", int),
]
dump_loader = DumpLoader()