Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
test: Update to_safetensors test to compare bytes with digest
Browse files Browse the repository at this point in the history
  • Loading branch information
lsetiawan committed Jan 11, 2024
1 parent e18a93b commit abb4b6c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/sims/test_state_dict.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import hashlib
from typing import Dict
import pytest
import torch
Expand Down Expand Up @@ -74,5 +75,7 @@ def test_to_params(self, simple_state_dict):

def test__to_safetensors(self, simple_state_dict):
tensors_bytes = simple_state_dict._to_safetensors()
digest = hashlib.sha256(tensors_bytes).hexdigest()
expected_bytes = save(simple_state_dict, metadata=simple_state_dict._metadata)
assert tensors_bytes == expected_bytes
expected_digest = hashlib.sha256(expected_bytes).hexdigest()
assert digest == expected_digest

Check failure on line 81 in tests/sims/test_state_dict.py

View workflow job for this annotation

GitHub Actions / build (3.10, macOS-latest)

TestStateDict.test__to_safetensors AssertionError: assert '4ad4e83b1e7719ed674353fe6aee2b72605b4266d53613daec87d7c0121010f4' == '8c726985dda85237fe44049d46f8ba4d665e61e86892e68797b96b51a1719852' - 8c726985dda85237fe44049d46f8ba4d665e61e86892e68797b96b51a1719852 + 4ad4e83b1e7719ed674353fe6aee2b72605b4266d53613daec87d7c0121010f4

0 comments on commit abb4b6c

Please sign in to comment.