webbrain-one's picture
download
raw
928 Bytes
import unittest
try:
import torch
except ImportError: # pragma: no cover - local lightweight environment
torch = None
@unittest.skipUnless(torch is not None, "requires torch")
class DequantizeTests(unittest.TestCase):
def test_block_scales_are_folded_into_bfloat16_weight(self):
from deepseek_vision.dequantize import dequantize_block_weight
weight = torch.ones((3, 5), dtype=torch.float8_e4m3fn)
scale = torch.tensor([[2.0, 4.0], [8.0, 16.0]])
result = dequantize_block_weight(weight, scale, block_size=(2, 3))
expected = torch.tensor(
[
[2, 2, 2, 4, 4],
[2, 2, 2, 4, 4],
[8, 8, 8, 16, 16],
],
dtype=torch.bfloat16,
)
self.assertEqual(result.dtype, torch.bfloat16)
self.assertTrue(torch.equal(result, expected))
if __name__ == "__main__":
unittest.main()

Xet Storage Details

Size:
928 Bytes
·
Xet hash:
3ce65ccb752e6a1ad3c22f03943f534d294e446351af7cef2cd38d77e0d8db09

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.