]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Minor improvements for README (#201)
authornickkolok <nickkolok@mail.ru>
Tue, 28 Mar 2023 08:20:42 +0000 (11:20 +0300)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 08:20:42 +0000 (10:20 +0200)
* Use `s for code

* Fix typos in README

* All readmes.

* Adding Rust cache and latest ubuntu for python tests.

---------

Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
.github/workflows/python.yml
.github/workflows/rust.yml
README.md
safetensors/README.md
safetensors/src/lib.rs

index 24a6a79c5c8cad344a0c7655ef2d273c3689be78..10a99c2d593d1572b603563d4887a7c29ff84b24 100644 (file)
@@ -9,7 +9,7 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        os: [ubuntu-18.04, macos-latest, windows-latest]
+        os: [ubuntu-latest, macos-latest, windows-latest]
         # Lowest and highest, no version specified so that 
         # new releases get automatically tested against
         torch_version: [torch==1.10, torch]
index 464dd1460598f1c1018e7b26b6727a3fe0539baa..7ff80b54b2a8c428a2d42620fa1ed7c3e43005ec 100644 (file)
@@ -20,6 +20,8 @@ jobs:
           components: rustfmt, clippy
           override: true
 
+      - uses: Swatinem/rust-cache@v2
+
       - name: Install cargo-readme for Ubuntu
         if: matrix.os == 'ubuntu-latest'
         uses: actions-rs/cargo@v1
index ee719604120d999558344008a7136ba39bc2b6fd..73a8516c4f7633459a7d52d8d82779389168b31e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ with safe_open("model.safetensors", framework="pt", device="cpu") as f:
 
 - 8 bytes: `N`, a u64 int, containing the size of the header
 - N bytes: a JSON utf-8 string representing the header.
-  - The header is a dict like {"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}, where offsets point to the tensor data relative to the beginning of the byte buffer, with BEGIN as the starting offset and END as the one-past offset (so total tensor byte size = END - BEGIN).
+  - The header is a dict like `{"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
   - A special key `__metadata__` is allowed to contain free form text map.
 - Rest of the file: byte-buffer.
 
@@ -108,10 +108,10 @@ necessary)? This is becoming increasingly important in the ML world.
 ### Notes
 
 - Zero-copy: No format is really zero-copy in ML, it needs to go from disk to RAM/GPU RAM (that takes time). Also
-   In PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
+   in PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
    SafeTensors is not zero-copy for the header. The choice of JSON is pretty arbitrary, but since deserialization is <<< of the time required to load the actual tensor data and is readable I went that way, (also space is <<< to the tensor data).
 
-- Endianness: Little-endian. This can be modified later, but it feels really unecessary at the
+- Endianness: Little-endian. This can be modified later, but it feels really unnecessary at the
 moment.
 - Order: 'C' or row-major. This seems to have won. We can add that information later if needed.
 - Stride: No striding, all tensors need to be packed before being serialized. I have yet to see a case where it seems useful to have a strided tensor stored in serialized format.
index ee719604120d999558344008a7136ba39bc2b6fd..73a8516c4f7633459a7d52d8d82779389168b31e 100644 (file)
@@ -54,7 +54,7 @@ with safe_open("model.safetensors", framework="pt", device="cpu") as f:
 
 - 8 bytes: `N`, a u64 int, containing the size of the header
 - N bytes: a JSON utf-8 string representing the header.
-  - The header is a dict like {"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}, where offsets point to the tensor data relative to the beginning of the byte buffer, with BEGIN as the starting offset and END as the one-past offset (so total tensor byte size = END - BEGIN).
+  - The header is a dict like `{"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
   - A special key `__metadata__` is allowed to contain free form text map.
 - Rest of the file: byte-buffer.
 
@@ -108,10 +108,10 @@ necessary)? This is becoming increasingly important in the ML world.
 ### Notes
 
 - Zero-copy: No format is really zero-copy in ML, it needs to go from disk to RAM/GPU RAM (that takes time). Also
-   In PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
+   in PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
    SafeTensors is not zero-copy for the header. The choice of JSON is pretty arbitrary, but since deserialization is <<< of the time required to load the actual tensor data and is readable I went that way, (also space is <<< to the tensor data).
 
-- Endianness: Little-endian. This can be modified later, but it feels really unecessary at the
+- Endianness: Little-endian. This can be modified later, but it feels really unnecessary at the
 moment.
 - Order: 'C' or row-major. This seems to have won. We can add that information later if needed.
 - Stride: No striding, all tensors need to be packed before being serialized. I have yet to see a case where it seems useful to have a strided tensor stored in serialized format.
index 7dcbdc10a85409f89760c72afb76bb56581efeaf..0913e89a5849a36e22f678b6d2d3a315ed3e8aba 100644 (file)
@@ -53,7 +53,7 @@
 //!
 //! - 8 bytes: `N`, a u64 int, containing the size of the header
 //! - N bytes: a JSON utf-8 string representing the header.
-//!   - The header is a dict like {"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}, where offsets point to the tensor data relative to the beginning of the byte buffer, with BEGIN as the starting offset and END as the one-past offset (so total tensor byte size = END - BEGIN).
+//!   - The header is a dict like `{"TENSOR_NAME": {"dtype": "float16", "shape": [1, 16, 256], "offsets": [BEGIN, END]}, "NEXT_TENSOR_NAME": {...}, ...}`, where offsets point to the tensor data relative to the beginning of the byte buffer, with `BEGIN` as the starting offset and `END` as the one-past offset (so total tensor byte size = `END - BEGIN`).
 //!   - A special key `__metadata__` is allowed to contain free form text map.
 //! - Rest of the file: byte-buffer.
 //!
 //!## Notes
 //!
 //!- Zero-copy: No format is really zero-copy in ML, it needs to go from disk to RAM/GPU RAM (that takes time). Also
-//!    In PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
+//!    in PyTorch/numpy, you need a mutable buffer, and we don't really want to mutate a mmaped file, so 1 copy is really necessary to use the thing freely in user code. That being said, zero-copy is achievable in Rust if it's wanted and safety can be guaranteed by some other means.
 //!    SafeTensors is not zero-copy for the header. The choice of JSON is pretty arbitrary, but since deserialization is <<< of the time required to load the actual tensor data and is readable I went that way, (also space is <<< to the tensor data).
 //!
-//!- Endianness: Little-endian. This can be modified later, but it feels really unecessary at the
+//!- Endianness: Little-endian. This can be modified later, but it feels really unnecessary at the
 //!moment.
 //!- Order: 'C' or row-major. This seems to have won. We can add that information later if needed.
 //!- Stride: No striding, all tensors need to be packed before being serialized. I have yet to see a case where it seems useful to have a strided tensor stored in serialized format.