Skip to content

Commit d9b33fe

Browse files
authored
metal : round up to 16 to fix MTLDebugComputeCommandEncoder assertion (ggml-org#3938)
1 parent 5ba3746 commit d9b33fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ggml-metal.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ void ggml_metal_graph_compute(
10171017
[encoder setBytes:&ne00 length:sizeof(ne00) atIndex:2];
10181018
[encoder setBytes:&ne01 length:sizeof(ne01) atIndex:3];
10191019
[encoder setBytes:&ne02 length:sizeof(ne02) atIndex:4];
1020-
[encoder setThreadgroupMemoryLength:nth/32*sizeof(float) atIndex:0];
1020+
[encoder setThreadgroupMemoryLength:MAX(16, nth/32*sizeof(float)) atIndex:0];
10211021

10221022
[encoder dispatchThreadgroups:MTLSizeMake(ne01*ne02*ne03, 1, 1) threadsPerThreadgroup:MTLSizeMake(nth, 1, 1)];
10231023
} break;
@@ -1348,7 +1348,7 @@ void ggml_metal_graph_compute(
13481348
[encoder setBytes:&ne00 length:sizeof( int64_t) atIndex:2];
13491349
[encoder setBytes:&nb01 length:sizeof(uint64_t) atIndex:3];
13501350
[encoder setBytes:&eps length:sizeof( float) atIndex:4];
1351-
[encoder setThreadgroupMemoryLength:nth*sizeof(float) atIndex:0];
1351+
[encoder setThreadgroupMemoryLength:MAX(16, nth*sizeof(float)) atIndex:0];
13521352

13531353
const int64_t nrows = ggml_nrows(src0);
13541354

0 commit comments

Comments
 (0)