Skip to content

Commit

Permalink
Merge pull request #181 from coreweave/eta/1d-multibyte-slicing
Browse files Browse the repository at this point in the history
fix(serialization): Slice 1-D multibyte data as bytes for `pwrite`
  • Loading branch information
wbrown authored Nov 28, 2024
2 parents 61bab18 + b1c7873 commit 2cee68a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [2.9.1] - 2024-11-27

### Fixed

- `TensorSerializer` no longer sometimes fails to serialize very large
1-dimensional tensors with multibyte `dtype`s
- `RedisStreamFile.readable()` and `RedisStreamFile.seekable()` now correctly
return `True`

Expand Down Expand Up @@ -407,7 +409,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `get_gpu_name`
- `no_init_or_tensor`

[Unreleased]: https://github.com/coreweave/tensorizer/compare/v2.9.0...HEAD
[2.9.1]: https://github.com/coreweave/tensorizer/compare/v2.9.0...v2.9.1
[2.9.0]: https://github.com/coreweave/tensorizer/compare/v2.8.1...v2.9.0
[2.8.1]: https://github.com/coreweave/tensorizer/compare/v2.8.0...v2.8.1
[2.8.0]: https://github.com/coreweave/tensorizer/compare/v2.7.2...v2.8.0
Expand Down
2 changes: 1 addition & 1 deletion tensorizer/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.9.0"
__version__ = "2.9.1"
8 changes: 5 additions & 3 deletions tensorizer/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,7 @@ def _mv_suffix(data: "collections.abc.Buffer", start: int):
if not isinstance(data, memoryview):
data = memoryview(data)
try:
if data.ndim != 1:
if data.ndim != 1 or data.format != "B":
data = data.cast("B")
return data[start:]
finally:
Expand All @@ -3526,13 +3526,15 @@ def _pwrite_syscall(
verify if isinstance(verify, int) else self._buffer_size(data)
)
bytes_just_written: int = os.pwrite(self._fd, data, offset)
bytes_written += bytes_just_written
if bytes_just_written > 0:
bytes_written += bytes_just_written
while bytes_written < expected_bytes_written and bytes_just_written > 0:
# Writes larger than ~2 GiB may not complete in a single pwrite call
offset += bytes_just_written
with self._mv_suffix(data, bytes_written) as mv:
bytes_just_written = os.pwrite(self._fd, mv, offset)
bytes_written += bytes_just_written
if bytes_just_written > 0:
bytes_written += bytes_just_written
if isinstance(verify, int) or verify:
self._verify_bytes_written(bytes_written, expected_bytes_written)
return bytes_written
Expand Down

0 comments on commit 2cee68a

Please sign in to comment.