Handle recompute and verify closeness in dumper (#19564)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user