Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions mlx/backend/metal/jit_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,22 +1417,37 @@ MTL::ComputePipelineState* get_steel_attention_nax_kernel(
bool split_d) {
const auto& lib_name = kernel_name;
auto lib = d.get_library(lib_name, [&]() {
// attention_nax_dsplit has no BV parameter (its value head dim is BD), so
// it takes the same arguments as its instantiation in
// steel_attention_nax.metal. Passing bv shifts every later argument and
// the library fails to compile.
auto template_def = split_d ? get_template_definition(
lib_name,
"attention_nax_dsplit",
get_type_string(q.dtype()),
bq,
bk,
bd,
wm,
wn,
get_type_string(m.dtype()))
: get_template_definition(
lib_name,
"attention_nax",
get_type_string(q.dtype()),
bq,
bk,
bd,
bv,
wm,
wn,
get_type_string(m.dtype()));
std::string kernel_source;
concatenate(
kernel_source,
metal::utils(),
metal::steel_attention_nax(),
get_template_definition(
lib_name,
split_d ? "attention_nax_dsplit" : "attention_nax",
get_type_string(q.dtype()),
bq,
bk,
bd,
bv,
wm,
wn,
get_type_string(m.dtype())));
template_def);
return kernel_source;
});
return d.get_kernel(kernel_name, lib, hash_name, func_consts);
Expand Down
Loading