From d2e4e628ac12a40dbe2bf51f4a311b55900fe74e Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Thu, 14 May 2026 12:54:28 -0400 Subject: [PATCH 1/6] CI: Update to test with torch 2.12 on CPU --- .github/workflows/tests-nightly.yml | 2 +- .github/workflows/tests-pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index 85959682d..db8a1d6d2 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -20,7 +20,7 @@ jobs: platform: [linux-x64, linux-aarch64, macos, windows] # default runners don't have AVX-512 support, but icelake does cpu_type: ["", icelake] - torch_version: ["2.4.1", "2.10.0", "2.11.0"] + torch_version: ["2.4.1", "2.12.0", "nightly"] exclude: # aarch64 minimum torch version is 2.5.1 diff --git a/.github/workflows/tests-pr.yml b/.github/workflows/tests-pr.yml index e75cccfcc..f04631a87 100644 --- a/.github/workflows/tests-pr.yml +++ b/.github/workflows/tests-pr.yml @@ -31,7 +31,7 @@ jobs: platform: [linux-x64, linux-aarch64, macos] # default runners don't have AVX-512 support, but icelake does cpu_type: ["", icelake] - torch_version: ["2.4.1", "2.11.0"] + torch_version: ["2.4.1", "2.12.0"] exclude: # aarch64 minimum torch version is 2.5.1 From 4f66176844f0b641f590fc4cae4b403ba7630da7 Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Thu, 14 May 2026 15:17:57 -0400 Subject: [PATCH 2/6] Additional CI fixes --- .github/workflows/test-runner.yml | 8 ++++++++ bitsandbytes/backends/cpu/ops.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index 7750646c1..dc32f1a55 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -224,5 +224,13 @@ jobs: - name: Show environment information run: python -m torch.utils.collect_env + # Windows + torch < 2.5: inductor embeds temp paths in generated code without escaping + # backslashes, causing SyntaxError on \Users\ -> \U unicode escape. Fixed in torch 2.5 + # via https://github.com/pytorch/pytorch/pull/134365. Remove when torch < 2.5 is dropped. + - name: Set inductor cache dir (Windows) + if: inputs.platform == 'windows' + shell: bash + run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $GITHUB_ENV + - name: Run tests run: pytest --durations=100 diff --git a/bitsandbytes/backends/cpu/ops.py b/bitsandbytes/backends/cpu/ops.py index 6b82c2421..a6277e5cf 100755 --- a/bitsandbytes/backends/cpu/ops.py +++ b/bitsandbytes/backends/cpu/ops.py @@ -153,9 +153,9 @@ def _( lambda: f"Blockwise 4bit dequantization only supports 16/32-bit floats, but got {dtype}", ) - # Fallback as AVX512 implementation has accuracy issues with fp16/fp32 and blocksize >= 2048 + # Fallback as AVX512 implementation has accuracy issues with blocksize >= 2048. # Note: this is not a common use case. - avx512_fallback = _has_avx512 and blocksize >= 2048 and dtype != torch.bfloat16 + avx512_fallback = _has_avx512 and blocksize >= 2048 # Odd shape is not supported by this kernel; fallback to generic implementation shape_fallback = shape[-1] % 2 != 0 From ce74322ec7a01c43e32841973d48d6a708b84acb Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Thu, 14 May 2026 15:41:10 -0400 Subject: [PATCH 3/6] Fix? --- .github/workflows/test-runner.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index dc32f1a55..1a1ea93ad 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -229,8 +229,8 @@ jobs: # via https://github.com/pytorch/pytorch/pull/134365. Remove when torch < 2.5 is dropped. - name: Set inductor cache dir (Windows) if: inputs.platform == 'windows' - shell: bash - run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $GITHUB_ENV + shell: pwsh + run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $env:GITHUB_ENV - name: Run tests run: pytest --durations=100 From 14dcabbc0f473fc34978258f00d32b84d53b5f8d Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Thu, 14 May 2026 16:02:01 -0400 Subject: [PATCH 4/6] Fix? --- .github/workflows/test-runner.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index 1a1ea93ad..fd6891564 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -228,9 +228,9 @@ jobs: # backslashes, causing SyntaxError on \Users\ -> \U unicode escape. Fixed in torch 2.5 # via https://github.com/pytorch/pytorch/pull/134365. Remove when torch < 2.5 is dropped. - name: Set inductor cache dir (Windows) - if: inputs.platform == 'windows' - shell: pwsh - run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $env:GITHUB_ENV + if: inputs.platform == 'windows' && inputs.backend == 'cpu' + shell: bash + run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $GITHUB_ENV - name: Run tests run: pytest --durations=100 From 59d79edb2535556cb832614da2c19b3fc8302aac Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Thu, 14 May 2026 17:01:10 -0400 Subject: [PATCH 5/6] Windows is no fun. --- .github/workflows/test-runner.yml | 8 -------- tests/test_linear4bit.py | 9 +++++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index fd6891564..7750646c1 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -224,13 +224,5 @@ jobs: - name: Show environment information run: python -m torch.utils.collect_env - # Windows + torch < 2.5: inductor embeds temp paths in generated code without escaping - # backslashes, causing SyntaxError on \Users\ -> \U unicode escape. Fixed in torch 2.5 - # via https://github.com/pytorch/pytorch/pull/134365. Remove when torch < 2.5 is dropped. - - name: Set inductor cache dir (Windows) - if: inputs.platform == 'windows' && inputs.backend == 'cpu' - shell: bash - run: echo "TORCHINDUCTOR_CACHE_DIR=C:/torchinductor_cache" >> $GITHUB_ENV - - name: Run tests run: pytest --durations=100 diff --git a/tests/test_linear4bit.py b/tests/test_linear4bit.py index 8be220139..ee1433641 100644 --- a/tests/test_linear4bit.py +++ b/tests/test_linear4bit.py @@ -365,8 +365,13 @@ def test_linear4bit_torch_compile(device, quant_type, compute_dtype, compress_st if fullgraph and torch.__version__ < (2, 8, 0, "dev"): pytest.skip("fullgraph mode requires torch 2.8 or higher") - if device == "cuda" and platform.system() == "Windows": - pytest.skip("Triton is not officially supported on Windows") + if platform.system() == "Windows": + if device == "cuda": + pytest.skip("Triton is not officially supported on Windows") + if device == "cpu" and torch.__version__ < (2, 7): + # torch.compile inductor on Windows CPU has include path bugs fixed in torch 2.7 + # https://github.com/pytorch/pytorch/pull/148271 + pytest.skip("torch.compile inductor on Windows CPU requires torch >= 2.7") # Has a strange regression on Linux aarch64 CPU in torch==2.6.0 when fullgraph=False. if ( From 0a910fab5bd5be1747f97229b43baff7c48d80ec Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Fri, 15 May 2026 10:54:48 -0400 Subject: [PATCH 6/6] additional windows cpu test guard --- tests/test_linear8bitlt.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_linear8bitlt.py b/tests/test_linear8bitlt.py index 43d4a4942..b078e82b7 100644 --- a/tests/test_linear8bitlt.py +++ b/tests/test_linear8bitlt.py @@ -261,8 +261,13 @@ def test_linear8bitlt_torch_compile(device, threshold, bias, fullgraph, mode): if fullgraph and torch.__version__ < (2, 5): pytest.skip("fullgraph tracing of MatmulLtState requires torch >= 2.5") - if device == "cuda" and platform.system() == "Windows": - pytest.skip("Triton is not officially supported on Windows") + if platform.system() == "Windows": + if device == "cuda": + pytest.skip("Triton is not officially supported on Windows") + if device == "cpu" and torch.__version__ < (2, 7): + # torch.compile inductor on Windows CPU has include path bugs fixed in torch 2.7 + # https://github.com/pytorch/pytorch/pull/148271 + pytest.skip("torch.compile inductor on Windows CPU requires torch >= 2.7") if device == "cuda" and mode == "reduce-overhead" and fullgraph and threshold > 0 and torch.__version__ >= (2, 10): pytest.xfail("Failure due to regression in torch 2.10 related to reduced overhead mode and CUDA.")