Skip to content

Commit 685962c

Browse files
committed
Enable Windows build and refine code
1 parent 302413e commit 685962c

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ elseif(BUILD_XPU)
232232
add_compile_definitions(BUILD_XPU)
233233
set(CMAKE_C_COMPILER icx)
234234
set(CMAKE_CXX_COMPILER icpx)
235+
if(WIN32)
236+
set(CMAKE_CXX_COMPILER icx)
237+
endif()
235238
else()
236239
string(APPEND BNB_OUTPUT_NAME "_cpu")
237240
set(GPU_SOURCES)

bitsandbytes/backends/xpu/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _(
145145
shape: Sequence[int],
146146
dtype: torch.dtype,
147147
) -> torch.Tensor:
148-
out = torch.zeros(shape, dtype=dtype, device=A.device)
148+
out = torch.empty(shape, dtype=dtype, device=A.device)
149149
_dequantize_4bit_impl(A, absmax, blocksize, quant_type, dtype, out=out)
150150
return out
151151

csrc/xpu_kernels.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
#include <bit>
33
#include <cmath>
44
#include <iostream>
5-
#include <unistd.h>
65

76
#include <sycl/sycl.hpp>
87

9-
inline float dDequantizeFP4Tree(unsigned char val) {
8+
inline float dDequantizeFP4(unsigned char val) {
109
if ((val & 0b1000) == 8)
1110
if ((val & 0b0100) == 4)
1211
if ((val & 0b0010) == 2)
@@ -144,8 +143,8 @@ kDequantizeBlockwise<T, TILE_SIZE, NUM_PER_TH, DATA_TYPE>::operator()(
144143
case FP4:
145144
#pragma unroll NUM_PER_TH
146145
for (int j = 0; j < NUM_PER_TH; j++) {
147-
vals[j * 2] = dDequantizeFP4Tree(qvals[j] >> 4) * local_abs_max;
148-
vals[j * 2 + 1] = dDequantizeFP4Tree(qvals[j] & 0x0F) * local_abs_max;
146+
vals[j * 2] = dDequantizeFP4(qvals[j] >> 4) * local_abs_max;
147+
vals[j * 2 + 1] = dDequantizeFP4(qvals[j] & 0x0F) * local_abs_max;
149148
}
150149
break;
151150
case NF4:

0 commit comments

Comments
 (0)