Skip to content

Commit 7408e68

Browse files
dwijenpatelzcbenz
andauthored
Fix quantized kernels in JIT build (#4372)
Co-authored-by: Cheng <git@zcbenz.com>
1 parent ab3ef95 commit 7408e68

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,7 @@ runs:
229229
else
230230
cmakeArgs+=("-DMLX_BUILD_METAL=ON")
231231
if ${{ inputs.toolkit == 'jit' }} ; then
232-
cmakeArgs+=(
233-
"-DBUILD_SHARED_LIBS=ON"
234-
"-DCMAKE_BUILD_TYPE=MinSizeRel"
235-
"-DMLX_BUILD_CPU=OFF"
236-
"-DMLX_BUILD_SAFETENSORS=OFF"
237-
"-DMLX_BUILD_GGUF=OFF"
238-
"-DMLX_METAL_JIT=ON"
239-
)
232+
cmakeArgs+=("-DMLX_METAL_JIT=ON")
240233
fi
241234
fi
242235
fi

.github/workflows/build_and_test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
with:
106106
toolkit: 'cpu'
107107
- uses: actions/upload-artifact@v7
108-
if: matrix.toolkit == 'metal'
108+
if: matrix.toolkit != 'cpu'
109109
with:
110110
name: mlx-${{ matrix.toolkit }}-macos${{ matrix.macos-target }}
111111
path: |
@@ -115,24 +115,28 @@ jobs:
115115
if-no-files-found: error
116116

117117
mac_test:
118-
name: Test macOS
118+
name: Test macOS (${{ matrix.toolkit }})
119119
if: github.repository == 'ml-explore/mlx'
120120
runs-on: [self-hosted, macos]
121121
needs: mac_build
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
toolkit: ['metal', 'jit']
122126
steps:
123127
- uses: actions/checkout@v7
124128
- uses: ./.github/actions/setup
125129
with:
126-
toolkit: 'metal'
130+
toolkit: ${{ matrix.toolkit }}
127131
use-ccache: false
128132
- uses: actions/download-artifact@v8
129133
with:
130134
path: artifact
131-
pattern: mlx-metal-*
135+
pattern: mlx-${{ matrix.toolkit }}-*
132136
- run: ls -lhR artifact
133137
- uses: ./.github/actions/test-macos
134138
with:
135-
toolkit: 'metal'
139+
toolkit: ${{ matrix.toolkit }}
136140

137141
build_documentation:
138142
name: Build Documentation

mlx/backend/metal/kernels/fp_quantized.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,8 @@ template <
12321232
int group_size,
12331233
int bits,
12341234
bool batched,
1235-
bool has_global_scale = false>
1235+
bool has_global_scale = false,
1236+
int results_per_simdgroup = 4>
12361237
[[kernel]] void fp_qmv(
12371238
const device uint32_t* w,
12381239
const device uint8_t* scales,

mlx/backend/metal/kernels/quantized.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,8 @@ template <
16031603
int group_size,
16041604
int bits,
16051605
bool batched,
1606-
bool has_global_scale = false>
1606+
bool has_global_scale = false,
1607+
int results_per_simdgroup = 4>
16071608
[[kernel]] void affine_qmv_fast(
16081609
const device uint32_t* w [[buffer(0)]],
16091610
const device T* scales [[buffer(1)]],
@@ -1660,7 +1661,8 @@ template <
16601661
int group_size,
16611662
const int bits,
16621663
bool batched,
1663-
bool has_global_scale = false>
1664+
bool has_global_scale = false,
1665+
int results_per_simdgroup = 4>
16641666
[[kernel]] void affine_qmv(
16651667
const device uint32_t* w [[buffer(0)]],
16661668
const device T* scales [[buffer(1)]],

mlx/backend/metal/quantized.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ void gather_qmm_nax(
972972
kernel = get_qmm_nax_kernel_wrapped(
973973
d,
974974
kname,
975-
"gather_qmm_t_nax_",
975+
"gather_qmm_t_nax",
976976
mode,
977977
type_string,
978978
group_size,
@@ -987,7 +987,7 @@ void gather_qmm_nax(
987987
kernel = get_qmm_nax_kernel_wrapped(
988988
d,
989989
kname,
990-
"gather_qmm_n_nax_",
990+
"gather_qmm_n_nax",
991991
mode,
992992
type_string,
993993
group_size,

0 commit comments

Comments
 (0)