Skip to content

Commit 405b484

Browse files
committed
Fix trailing whitespace
1 parent af6561a commit 405b484

16 files changed

Lines changed: 506 additions & 113 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -102,49 +102,49 @@ jobs:
102102
path: output/*
103103
retention-days: 7
104104

105-
build-shared-libs-rocm:
106-
strategy:
107-
matrix:
108-
os: [ubuntu-22.04]
109-
arch: [x86_64]
110-
rocm_version:
111-
["6.1.2", "6.2.4", "6.3.2"]
112-
runs-on: ${{ matrix.os }}
113-
steps:
114-
- uses: actions/checkout@v4
115-
- name: Set up Docker multiarch
116-
uses: docker/setup-qemu-action@v3
117-
- name: Clean up disk space
118-
run: |
119-
sudo rm -rf \
120-
/usr/share/dotnet \
121-
/opt/ghc \
122-
"/usr/local/share/boost" \
123-
"$AGENT_TOOLSDIRECTORY" \
124-
/opt/hostedtoolcache \
125-
/opt/google/chrome \
126-
/opt/microsoft/msedge \
127-
/opt/microsoft/powershell \
128-
/opt/pipx \
129-
/usr/lib/mono \
130-
/usr/local/julia* \
131-
/usr/local/lib/android \
132-
/usr/local/lib/node_modules \
133-
/usr/local/share/chromium \
134-
/usr/local/share/powershell \
135-
/usr/share/swift
136-
- name: Build C++
137-
run: bash .github/scripts/build-rocm.sh
138-
env:
139-
build_os: ${{ matrix.os }}
140-
build_arch: ${{ matrix.arch }}
141-
rocm_version: ${{ matrix.rocm_version }}
142-
- name: Upload build artifact
143-
uses: actions/upload-artifact@v4
144-
with:
145-
name: shared_library_rocm_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.rocm_version }}
146-
path: output/*
147-
retention-days: 7
105+
build-shared-libs-rocm:
106+
strategy:
107+
matrix:
108+
os: [ubuntu-22.04]
109+
arch: [x86_64]
110+
rocm_version:
111+
["6.1.2", "6.2.4", "6.3.2"]
112+
runs-on: ${{ matrix.os }}
113+
steps:
114+
- uses: actions/checkout@v4
115+
- name: Set up Docker multiarch
116+
uses: docker/setup-qemu-action@v3
117+
- name: Clean up disk space
118+
run: |
119+
sudo rm -rf \
120+
/usr/share/dotnet \
121+
/opt/ghc \
122+
"/usr/local/share/boost" \
123+
"$AGENT_TOOLSDIRECTORY" \
124+
/opt/hostedtoolcache \
125+
/opt/google/chrome \
126+
/opt/microsoft/msedge \
127+
/opt/microsoft/powershell \
128+
/opt/pipx \
129+
/usr/lib/mono \
130+
/usr/local/julia* \
131+
/usr/local/lib/android \
132+
/usr/local/lib/node_modules \
133+
/usr/local/share/chromium \
134+
/usr/local/share/powershell \
135+
/usr/share/swift
136+
- name: Build C++
137+
run: bash .github/scripts/build-rocm.sh
138+
env:
139+
build_os: ${{ matrix.os }}
140+
build_arch: ${{ matrix.arch }}
141+
rocm_version: ${{ matrix.rocm_version }}
142+
- name: Upload build artifact
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: shared_library_rocm_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.rocm_version }}
146+
path: output/*
147+
retention-days: 7
148148

149149
build-wheels:
150150
needs:
@@ -216,10 +216,10 @@ jobs:
216216
path: tmp/
217217
pattern: "bdist_wheel_*"
218218
merge-multiple: true
219-
219+
220220
- name: Inspect tmp directory after downloading artifacts
221221
run: ls -alFR tmp/
222-
222+
223223
- name: Move and rename wheel files with pattern replacement
224224
run: |
225225
mkdir -p wheels/
@@ -244,7 +244,7 @@ jobs:
244244
245245
- name: Inspect wheels directory after renaming files
246246
run: ls -alFR wheels/
247-
247+
248248
- name: Delete old pre-release (if exists)
249249
run: |
250250
gh release delete continuous-release_main --cleanup-tag -y || true
@@ -258,7 +258,7 @@ jobs:
258258
259259
This pre-release contains the latest development wheels for all supported platforms, rebuilt automatically on every commit to the `main` branch.
260260
261-
**How to install:**
261+
**How to install:**
262262
Pick the correct command for your platform and run it in your terminal:
263263
264264
ENDOFMARKDOWN
@@ -273,7 +273,7 @@ jobs:
273273
done
274274
275275
cat >> body.md << 'ENDOFMARKDOWN'
276-
> **Note:**
276+
> **Note:**
277277
> These wheels are updated automatically with every commit to `main` and become available as soon as the [python-package.yml](.github/workflows/python-package.yml) workflow finishes.
278278
ENDOFMARKDOWN
279279

bitsandbytes/backends/cuda/ops.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from bitsandbytes.functional import CUBLAS_Context, _cuda_device_of, _get_tensor_stream, get_ptr
99

1010
from ..._ops import register_kernel
11-
from ...cextension import lib, HIP_ENVIRONMENT
11+
from ...cextension import HIP_ENVIRONMENT, lib
1212

1313

1414
@register_kernel("bitsandbytes::int8_linear_matmul", "cuda")
@@ -210,12 +210,12 @@ def _get_col_absmax(
210210
@register_kernel("bitsandbytes::quantize_blockwise", "cuda")
211211
def _(A: torch.Tensor, code: torch.Tensor, blocksize: int) -> tuple[torch.Tensor, torch.Tensor]:
212212
torch._check_is_size(blocksize)
213-
214-
if HIP_ENVIRONMENT:
215-
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
216-
else:
213+
214+
if HIP_ENVIRONMENT:
215+
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
216+
else:
217217
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128, 64])
218-
218+
219219
torch._check(code.dtype == torch.float32, lambda: f"code must be float32, got {code.dtype}")
220220

221221
n = A.numel()
@@ -269,11 +269,11 @@ def _(
269269
def _dequantize_blockwise_impl(
270270
A: torch.Tensor, absmax: torch.Tensor, code: torch.Tensor, blocksize: int, dtype: torch.dtype, out: torch.Tensor
271271
) -> None:
272-
if HIP_ENVIRONMENT:
273-
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
274-
else:
272+
if HIP_ENVIRONMENT:
273+
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
274+
else:
275275
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128, 64])
276-
276+
277277
torch._check(A.dtype == torch.uint8, lambda: f"A must be uint8, got {A.dtype}")
278278
torch._check(
279279
dtype in [torch.float16, torch.bfloat16, torch.float32],
@@ -303,11 +303,11 @@ def _dequantize_blockwise_impl(
303303
def _(
304304
A: torch.Tensor, blocksize: int, quant_type: str, quant_storage: torch.dtype
305305
) -> tuple[torch.Tensor, torch.Tensor]:
306-
if HIP_ENVIRONMENT:
307-
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
308-
else:
306+
if HIP_ENVIRONMENT:
307+
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
308+
else:
309309
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128, 64])
310-
310+
311311
torch._check(quant_type in ["fp4", "nf4"])
312312
torch._check(
313313
A.dtype in [torch.bfloat16, torch.float16, torch.float32],
@@ -385,11 +385,11 @@ def _dequantize_4bit_impl(
385385
dtype: torch.dtype,
386386
out: torch.Tensor,
387387
) -> None:
388-
if HIP_ENVIRONMENT:
389-
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
390-
else:
388+
if HIP_ENVIRONMENT:
389+
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128])
390+
else:
391391
torch._check(blocksize in [4096, 2048, 1024, 512, 256, 128, 64])
392-
392+
393393
torch._check(quant_type in ["fp4", "nf4"])
394394
torch._check(
395395
dtype in [torch.bfloat16, torch.float16, torch.float32],

bitsandbytes/cextension.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_available_cuda_binary_versions() -> list[str]:
8181
lib_pattern = f"libbitsandbytes_{BNB_BACKEND.lower()}*{DYNAMIC_LIBRARY_SUFFIX}"
8282
versions = []
8383
for lib in Path(__file__).parent.glob(lib_pattern):
84-
pattern = r"{}(\d+)".format(BNB_BACKEND.lower())
84+
pattern = rf"{BNB_BACKEND.lower()}(\d+)"
8585
match = re.search(pattern, lib.name)
8686
if match:
8787
ver_code = int(match.group(1))
@@ -199,18 +199,16 @@ def _format_lib_error_message(
199199
)
200200

201201
compile_instructions = (
202-
(
203-
"COMPILE FROM SOURCE for CPU-only:\n `cmake -DCOMPUTE_BACKEND=cpu -S . && make`\n\n"
204-
) if not no_cuda_lib_found
205-
else
206-
(
202+
("COMPILE FROM SOURCE for CPU-only:\n `cmake -DCOMPUTE_BACKEND=cpu -S . && make`\n\n")
203+
if not no_cuda_lib_found
204+
else (
207205
"You have two options:\n"
208206
"1. COMPILE FROM SOURCE (required if no binary exists):\n"
209207
" https://huggingface.co/docs/bitsandbytes/main/en/installation#cuda-compile\n"
210208
"2. Use BNB_CUDA_VERSION to specify a DIFFERENT CUDA version from the detected one, which is installed on your machine and matching an available pre-compiled version listed above\n\n"
211-
) if not HIP_ENVIRONMENT
212-
else
213-
(
209+
)
210+
if not HIP_ENVIRONMENT
211+
else (
214212
"You can COMPILE FROM SOURCE as mentioned here:\n"
215213
" https://huggingface.co/docs/bitsandbytes/main/en/installation?backend=AMD+ROCm#amd-gpu\n"
216214
)

bitsandbytes/cuda_specs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import dataclasses
2+
from functools import lru_cache
23
import logging
34
import re
45
import subprocess
5-
from functools import lru_cache
66
from typing import Optional
77

88
import torch

bitsandbytes/diagnostics/cuda.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
}
3434

3535
CUDA_RUNTIME_LIB_PATTERNS = (
36-
"libamdhip64.so*",
37-
) if HIP_ENVIRONMENT else (
38-
"cudart64*.dll", # Windows
39-
"libcudart*.so*", # libcudart.so, libcudart.so.11.0, libcudart.so.12.0, libcudart.so.12.1, libcudart.so.12.2 etc.
40-
"nvcuda*.dll", # Windows
36+
("libamdhip64.so*",)
37+
if HIP_ENVIRONMENT
38+
else (
39+
"cudart64*.dll", # Windows
40+
"libcudart*.so*", # libcudart.so, libcudart.so.11.0, libcudart.so.12.0, libcudart.so.12.1, libcudart.so.12.2 etc.
41+
"nvcuda*.dll", # Windows
42+
)
4143
)
4244

4345
logger = logging.getLogger(__name__)

bitsandbytes/diagnostics/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def main():
4343
print(f"{BNB_BACKEND} specs:{cuda_specs}")
4444
if not torch.cuda.is_available():
4545
print(f"Torch says {BNB_BACKEND} is not available. Possible reasons:")
46-
if not HIP_ENVIRONMENT: print(f"- {BNB_BACKEND} driver not installed")
46+
if not HIP_ENVIRONMENT:
47+
print(f"- {BNB_BACKEND} driver not installed")
4748
print(f"- {BNB_BACKEND} not installed")
4849
print(f"- You have multiple conflicting {BNB_BACKEND} libraries")
4950
if cuda_specs:

bitsandbytes/functional.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from bitsandbytes.utils import pack_dict_to_tensor, unpack_tensor_to_dict
1717

18-
from .cextension import lib, HIP_ENVIRONMENT
18+
from .cextension import HIP_ENVIRONMENT, lib
1919

2020
name2qmap = {}
2121

@@ -1007,10 +1007,10 @@ def quantize_4bit(
10071007
- `torch.Tensor`: The quantized tensor with packed 4-bit values.
10081008
- [`QuantState`]: The state object used to undo the quantization.
10091009
"""
1010-
1010+
10111011
if blocksize is None:
10121012
blocksize = 64 if not HIP_ENVIRONMENT else 128
1013-
1013+
10141014
input_shape = A.shape
10151015

10161016
_out, _absmax = torch.ops.bitsandbytes.quantize_4bit.default(
@@ -1114,10 +1114,10 @@ def dequantize_4bit(
11141114
Returns:
11151115
`torch.Tensor`: The dequantized tensor.
11161116
"""
1117-
1117+
11181118
if blocksize is None:
11191119
blocksize = 64 if not HIP_ENVIRONMENT else 128
1120-
1120+
11211121
if quant_state is None:
11221122
assert absmax is not None and out is not None
11231123

bitsandbytes/nn/modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ def __new__(
222222
) -> "Params4bit":
223223
if data is None:
224224
data = torch.empty(0)
225-
225+
226226
if blocksize is None:
227227
blocksize = 64 if not HIP_ENVIRONMENT else 128
228-
228+
229229
self = torch.Tensor._make_subclass(cls, data, requires_grad)
230230
self.blocksize = blocksize
231231
self.compress_statistics = compress_statistics

0 commit comments

Comments
 (0)