From c09bd7f574a9ee536f0b48024cf10e8fe78f31ae Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Fri, 24 Jan 2025 21:22:49 -0800 Subject: [PATCH 01/11] Add tensorizer --- recipes/tensorizer/recipe.yaml | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 recipes/tensorizer/recipe.yaml diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml new file mode 100644 index 0000000000000..4818f67798f55 --- /dev/null +++ b/recipes/tensorizer/recipe.yaml @@ -0,0 +1,51 @@ +context: + version: 2.9.1 + +package: + name: tensorizer + version: ${{ version }} + +source: +- url: https://pypi.org/packages/source/t/tensorizer/tensorizer-${{ version }}.tar.gz + sha256: f79ac50d0a3bc328e3ee8cdf838ba04ddb5b9fa1d72be69f6ae618533d349e8e + +build: + script: ${{ PYTHON }} -m pip install . + +requirements: + host: + - python + - setuptools + - pip + - cmake + - ${{ stdlib('c') }} + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + run: + - python + - pytorch >=1.9.0 + - numpy >=1.19.5 + - protobuf >=3.19.5 + - psutil >=5.9.4 + - boto3 >=1.26.0 + - redis-py >=4.5.5 + - hiredis >=2.2.0 + - libnacl-python-bindings >=2.1.0 + +tests: +- python: + imports: + - tensorizer + pip_check: true + +about: + homepage: https://github.com/coreweave/tensorizer + repository: https://github.com/coreweave/tensorizer + summary: A tool for fast PyTorch module, model, and tensor serialization + deserialization. + description: Module, Model, and Tensor Serialization/Deserialization + license: MIT + license_file: LICENSE + +extra: + recipe-maintainers: + - maresb From b8b090e5fd65c4a8433874c7abbe0f25339e097f Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Fri, 24 Jan 2025 21:27:28 -0800 Subject: [PATCH 02/11] Add missing build number --- recipes/tensorizer/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 4818f67798f55..eba3cd1f462bd 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -10,6 +10,7 @@ source: sha256: f79ac50d0a3bc328e3ee8cdf838ba04ddb5b9fa1d72be69f6ae618533d349e8e build: + number: 0 script: ${{ PYTHON }} -m pip install . requirements: From 53e150665bf31610c5efe6abb6b2a4a200f6a2ba Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 07:13:49 -0800 Subject: [PATCH 03/11] Add tests --- recipes/tensorizer/recipe.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index eba3cd1f462bd..79a8abfed11db 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -38,6 +38,18 @@ tests: imports: - tensorizer pip_check: true +- files: + source: + - tests/ + requirements: + run: + - transformers >=4.27.1 + - moto >=4.1.4,<5.0.0 + - redis-py >=5.0.0 + - redis-server + - boto3 + script: + - python -m unittest discover --start-directory tests -v about: homepage: https://github.com/coreweave/tensorizer From 856004b3b7c2f056f495658e0b755c4df0162521 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 07:30:20 -0800 Subject: [PATCH 04/11] Pin numpy in test --- recipes/tensorizer/recipe.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 79a8abfed11db..73aba48f41abc 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -48,6 +48,9 @@ tests: - redis-py >=5.0.0 - redis-server - boto3 + # Opened + # to fix the underlying issue. + - numpy <2 script: - python -m unittest discover --start-directory tests -v From e2d6edf22fb6021f581030196218f801b8a119e8 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 08:03:33 -0800 Subject: [PATCH 05/11] Skip failing test on macos --- recipes/tensorizer/recipe.yaml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 73aba48f41abc..aa5947a5d5c4c 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -10,6 +10,7 @@ source: sha256: f79ac50d0a3bc328e3ee8cdf838ba04ddb5b9fa1d72be69f6ae618533d349e8e build: + noarch: python number: 0 script: ${{ PYTHON }} -m pip install . @@ -18,10 +19,6 @@ requirements: - python - setuptools - pip - - cmake - - ${{ stdlib('c') }} - - ${{ compiler('c') }} - - ${{ compiler('cxx') }} run: - python - pytorch >=1.9.0 @@ -43,16 +40,32 @@ tests: - tests/ requirements: run: + - pytest - transformers >=4.27.1 - moto >=4.1.4,<5.0.0 - redis-py >=5.0.0 - - redis-server + - if: not win + then: + - redis-server - boto3 # Opened # to fix the underlying issue. - numpy <2 script: - - python -m unittest discover --start-directory tests -v + # Fails on macOS in test_cpu_multiple_readers + # (test_serialization.TestDeserialization) with: + # ValueError: Cannot reopen this type of file to enable parallel reading with + # num_readers > 1. File paths, URIs, and HTTP(S) or S3 streams returned from + # tensorizer.stream_io.open_stream, plus some open files are capable of being + # reopened. Other file-like objects and special files (e.g. BytesIO, pipes, + # sockets) are not supported. + # Unfortunately I don't know which type of file is being opened, but this doesn't + # seem serious, so I'm skipping it. + - if: osx + then: + - pytest tests -vv -k "not test_cpu_multiple_readers" + - else: + - pytest tests -vv about: homepage: https://github.com/coreweave/tensorizer From fd238c6a0ff8bc3d643cafa045aa2e12ee922f4f Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 08:09:46 -0800 Subject: [PATCH 06/11] lint --- recipes/tensorizer/recipe.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index aa5947a5d5c4c..8d8bf7943fbdf 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -16,11 +16,11 @@ build: requirements: host: - - python + - python ${{ python_min }}.* - setuptools - pip run: - - python + - python >=${{ python_min }} - pytorch >=1.9.0 - numpy >=1.19.5 - protobuf >=3.19.5 @@ -35,6 +35,7 @@ tests: imports: - tensorizer pip_check: true + python_version: ${{ python_min }}.* - files: source: - tests/ From d65d3fbcdffca642afeb03db0ca66aff9ca21208 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 08:10:02 -0800 Subject: [PATCH 07/11] Fix script conditional --- recipes/tensorizer/recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 8d8bf7943fbdf..e029d9360a73e 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -65,7 +65,7 @@ tests: - if: osx then: - pytest tests -vv -k "not test_cpu_multiple_readers" - - else: + else: - pytest tests -vv about: From 5e82bbc9da14208c94d22efb8eb7974df7e9eea6 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 08:41:57 -0800 Subject: [PATCH 08/11] Refine test selection on Windows --- recipes/tensorizer/recipe.yaml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index e029d9360a73e..4e6844c0f14c1 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -53,7 +53,10 @@ tests: # to fix the underlying issue. - numpy <2 script: - # Fails on macOS in test_cpu_multiple_readers + - if: linux + then: + - pytest tests -vvv + # Fails on macOS and Windows in test_cpu_multiple_readers # (test_serialization.TestDeserialization) with: # ValueError: Cannot reopen this type of file to enable parallel reading with # num_readers > 1. File paths, URIs, and HTTP(S) or S3 streams returned from @@ -64,9 +67,21 @@ tests: # seem serious, so I'm skipping it. - if: osx then: - - pytest tests -vv -k "not test_cpu_multiple_readers" - else: - - pytest tests -vv + - pytest tests -vvv \ + --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers + # In addition to the above, we don't have a Redis server on Windows. + # Also, test_bfloat16 and test_structure fail with: + # PermissionError: [WinError 32] The process cannot access the file because it + # is being used by another process: + # 'C:\\Users\\VSSADM~1\\AppData\\Local\\Temp\\tensorizer-testu78j78id' + - if: win + then: + - pytest tests -vvv \ + --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers \ + --deselect tests/test_serialization.py::TestDeserialization::test_redis \ + --deselect tests/test_stream_io.py::TestRedis::test_redis_stream \ + --deselect tests/test_serialization.py::TestSerialization::test_bfloat16 \ + --deselect tests/test_serialization.py::TestSerialization::test_structure about: homepage: https://github.com/coreweave/tensorizer From 91bbbe6b2ba76c42c7c3a87204839b0b6b5690c9 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 09:03:35 -0800 Subject: [PATCH 09/11] Try to figure out line breaks in scripts --- recipes/tensorizer/recipe.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 4e6844c0f14c1..baace836c8c34 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -67,7 +67,8 @@ tests: # seem serious, so I'm skipping it. - if: osx then: - - pytest tests -vvv \ + - | + pytest tests -vvv \ --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers # In addition to the above, we don't have a Redis server on Windows. # Also, test_bfloat16 and test_structure fail with: @@ -76,7 +77,8 @@ tests: # 'C:\\Users\\VSSADM~1\\AppData\\Local\\Temp\\tensorizer-testu78j78id' - if: win then: - - pytest tests -vvv \ + - | + pytest tests -vvv \ --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers \ --deselect tests/test_serialization.py::TestDeserialization::test_redis \ --deselect tests/test_stream_io.py::TestRedis::test_redis_stream \ From c6d09c2158d2e9991de37eb289d588b4c810dc4c Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 09:23:02 -0800 Subject: [PATCH 10/11] Fix continuation character on Windows --- recipes/tensorizer/recipe.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index baace836c8c34..6f90b61e577ae 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -78,11 +78,11 @@ tests: - if: win then: - | - pytest tests -vvv \ - --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers \ - --deselect tests/test_serialization.py::TestDeserialization::test_redis \ - --deselect tests/test_stream_io.py::TestRedis::test_redis_stream \ - --deselect tests/test_serialization.py::TestSerialization::test_bfloat16 \ + pytest tests -vvv ^ + --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers ^ + --deselect tests/test_serialization.py::TestDeserialization::test_redis ^ + --deselect tests/test_stream_io.py::TestRedis::test_redis_stream ^ + --deselect tests/test_serialization.py::TestSerialization::test_bfloat16 ^ --deselect tests/test_serialization.py::TestSerialization::test_structure about: From 5794483293b58c7d2d4fbff2ff604a6b3dd84d38 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sat, 25 Jan 2025 09:30:11 -0800 Subject: [PATCH 11/11] Add retries to hopefully fix redis failures --- recipes/tensorizer/recipe.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/recipes/tensorizer/recipe.yaml b/recipes/tensorizer/recipe.yaml index 6f90b61e577ae..034a0a79756d0 100644 --- a/recipes/tensorizer/recipe.yaml +++ b/recipes/tensorizer/recipe.yaml @@ -42,6 +42,7 @@ tests: requirements: run: - pytest + - pytest-rerunfailures - transformers >=4.27.1 - moto >=4.1.4,<5.0.0 - redis-py >=5.0.0 @@ -53,9 +54,13 @@ tests: # to fix the underlying issue. - numpy <2 script: + # Redis tests are flaky, sometimes failing with: + # redis.exceptions.ConnectionError: Error 111 connecting to localhost:6381. + # Connection refused. + # I suspect that there's not enough startup time, so we retry a few times. - if: linux then: - - pytest tests -vvv + - pytest tests -vvv --reruns 2 # Fails on macOS and Windows in test_cpu_multiple_readers # (test_serialization.TestDeserialization) with: # ValueError: Cannot reopen this type of file to enable parallel reading with @@ -68,7 +73,7 @@ tests: - if: osx then: - | - pytest tests -vvv \ + pytest tests -vvv --reruns 2 \ --deselect tests/test_serialization.py::TestDeserialization::test_cpu_multiple_readers # In addition to the above, we don't have a Redis server on Windows. # Also, test_bfloat16 and test_structure fail with: