v2: fix 26B activation explosion — normalize groupSize=32 scales, fix hardcoded loops
This commit is contained in:
@@ -343,8 +343,8 @@ kernel void quantized_matmul_simd(
|
||||
uint packedBase = outRow * (inDim / 8) + g * (groupSize / 8);
|
||||
uint xBase = g * groupSize;
|
||||
|
||||
// Process 4 uint32 per iteration (32 nibbles) — half the loop count
|
||||
for (uint p = 0; p < 8; p += 4) {
|
||||
// Process 4 uint32 per iteration (32 nibbles) — half the loop count
|
||||
for (uint p = 0; p < groupSize / 8; p += 4) {
|
||||
// Vectorized uint4 load (reduces load instructions)
|
||||
device uint4 *packedPtr = (device uint4*)(&w[packedBase + p]);
|
||||
uint4 packed = *packedPtr;
|
||||
@@ -510,7 +510,7 @@ kernel void quantized_matmul_gate_up_down(
|
||||
uint wBase = gid * packedPerIn + g * (groupSize / 8);
|
||||
uint xBase = g * groupSize;
|
||||
|
||||
for (uint p = 0; p < 8; p += 4) {
|
||||
for (uint p = 0; p < groupSize / 8; p += 4) {
|
||||
device uint4 *gPtr = (device uint4*)(&w_gate[wBase + p]);
|
||||
device uint4 *uPtr = (device uint4*)(&w_up[wBase + p]);
|
||||
uint4 gP = *gPtr;
|
||||
@@ -588,7 +588,7 @@ kernel void quantized_matmul_gate_up_down(
|
||||
uint wBase = gid * packedPerOut + g * (groupSize / 8);
|
||||
uint iBase = g * groupSize;
|
||||
|
||||
for (uint p = 0; p < 8; p += 4) {
|
||||
for (uint p = 0; p < groupSize / 8; p += 4) {
|
||||
device uint4 *wPtr = (device uint4*)(&w_down[wBase + p]);
|
||||
uint4 packed = *wPtr;
|
||||
|
||||
@@ -1123,7 +1123,7 @@ kernel void quantized_matmul_gate_up_opt(
|
||||
uint wBase = gid * packedPerOut + g * (groupSize / 8);
|
||||
uint xBase = g * groupSize;
|
||||
|
||||
for (uint p = 0; p < 8; p += 4) {
|
||||
for (uint p = 0; p < groupSize / 8; p += 4) {
|
||||
device uint4 *gPtr = (device uint4*)(&w_gate[wBase + p]);
|
||||
device uint4 *uPtr = (device uint4*)(&w_up[wBase + p]);
|
||||
uint4 gP = *gPtr;
|
||||
|
||||
Reference in New Issue
Block a user