convert : use writeable buffer for remote lazy tensors

This commit is contained in:
Francis Couture-Harpin
2025-04-08 11:40:12 -04:00
parent b584e3979d
commit 78094fc4a7
2 changed files with 5 additions and 3 deletions

View File

@@ -5416,7 +5416,8 @@ class LazyTorchTensor(gguf.LazyBase):
dtype = cls._dtype_str_map[remote_tensor.dtype]
shape = remote_tensor.shape
meta = cls.meta_with_dtype_and_shape(dtype, shape)
lazy = cls(meta=meta, args=(remote_tensor,), func=lambda r: torch.frombuffer(r.data(), dtype=dtype).reshape(shape))
func = lambda r: torch.frombuffer(r.data(), dtype=dtype).reshape(shape)
lazy = cls(meta=meta, args=(remote_tensor,), func=func)
return cast(torch.Tensor, lazy)
@classmethod