fix(gen-seat): hash bf16 tensors via uint8 reinterpret, not numpy
numpy has no bfloat16, so .numpy().tobytes() raised 'TypeError: Got unsupported ScalarType BFloat16' on real checkpoints. Flatten then view(torch.uint8) before hashing. Result on the heresy candidate: VERDICT IDENTICAL -- all 15 mtp.* tensors byte-identical to the incumbent's verbatim base graft, the head already measured at 47.7% acceptance in production. The ~56 GB bf16 acceptance gate is redundant, so no second seat comes down.
This commit is contained in:
@@ -74,8 +74,16 @@ def load_mtp(model_dir: Path) -> dict:
|
|||||||
|
|
||||||
def digest(tensor) -> str:
|
def digest(tensor) -> str:
|
||||||
"""SHA-256 over the raw tensor bytes. Dtype-sensitive by design — a head
|
"""SHA-256 over the raw tensor bytes. Dtype-sensitive by design — a head
|
||||||
stored at a different precision is not the same head for our purposes."""
|
stored at a different precision is not the same head for our purposes.
|
||||||
return hashlib.sha256(tensor.contiguous().view(-1).numpy().tobytes()).hexdigest()
|
|
||||||
|
Goes through a uint8 reinterpret rather than `.numpy()`: numpy has no
|
||||||
|
bfloat16, and these checkpoints are bf16, so the direct route raises
|
||||||
|
`TypeError: Got unsupported ScalarType BFloat16`.
|
||||||
|
"""
|
||||||
|
import torch
|
||||||
|
|
||||||
|
flat = tensor.contiguous().flatten()
|
||||||
|
return hashlib.sha256(flat.view(torch.uint8).numpy().tobytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user