vulkan: Divide GROUP_NORM workgroup to 2D to avoid maxComputeWorkGroupCount limit (#31930)
* Divide workgroup to 2D to workaround maxComputeWorkGroupCount limit * Replaced with existing macro
This commit is contained in:
1 parent
c1a4febe9d
commit
3837bf0bc0
2 files changed
+15
-5
No files matched your search
@@ -9712,8 +9712,13 @@ static void ggml_vk_op_f32(ggml_backend_vk_context * ctx, vk_context& subctx, co
|
||||
break;
|
||||
case GGML_OP_GROUP_NORM:
|
||||
{
|
||||
const uint32_t num_groups = dst->op_params[0];
|
||||
elements = { num_groups * (uint32_t)src0->ne[3], 1, 1 };
|
||||
const uint32_t total_workgroups = dst->op_params[0] * (uint32_t)src0->ne[3];
|
||||
const uint32_t groups_x = std::min(total_workgroups, ctx->device->properties.limits.maxComputeWorkGroupCount[0]);
|
||||
const uint64_t groups_y_needed = CEIL_DIV(uint64_t(total_workgroups), groups_x);
|
||||
const uint32_t groups_y = std::min<uint64_t>(groups_y_needed, ctx->device->properties.limits.maxComputeWorkGroupCount[1]);
|
||||
const uint64_t groups_xy = uint64_t(groups_x) * groups_y;
|
||||
elements = { groups_x, groups_y, uint32_t(CEIL_DIV(uint64_t(total_workgroups), groups_xy)) };
|
||||
GGML_ASSERT(elements[2] <= ctx->device->properties.limits.maxComputeWorkGroupCount[2]);
|
||||
} break;
|
||||
case GGML_OP_DIAG_MASK_INF:
|
||||
elements = { (uint32_t)ggml_nrows(src0), (uint32_t)ne00, 1 };
|
||||
@@ -10933,8 +10938,9 @@ void ggml_vk_group_norm(ggml_backend_vk_context * ctx, vk_context& subctx, const
|
||||
const uint32_t num_groups = int_op_params[0];
|
||||
const float eps = float_op_params[1];
|
||||
const uint32_t group_size = src0->ne[0] * src0->ne[1] * ((src0->ne[2] + num_groups - 1) / num_groups);
|
||||
const uint32_t num_workgroups = num_groups * src0->ne[3];
|
||||
|
||||
ggml_vk_op_f32<vk_op_push_constants>(ctx, subctx, src0, nullptr, nullptr, nullptr, dst, GGML_OP_GROUP_NORM, { group_size, 0, eps, 0.0f, 0.0f, 0.0f });
|
||||
ggml_vk_op_f32<vk_op_push_constants>(ctx, subctx, src0, nullptr, nullptr, nullptr, dst, GGML_OP_GROUP_NORM, { group_size, num_workgroups, eps, 0.0f, 0.0f, 0.0f });
|
||||
}
|
||||
|
||||
static uint32_t ggml_vk_rms_num_partials(ggml_backend_vk_context * ctx, const ggml_tensor *node) {
|
||||
|
||||
@@ -18,8 +18,12 @@ void main() {
|
||||
const float eps = p.param1;
|
||||
|
||||
const uint tid = gl_LocalInvocationID.x;
|
||||
const uint start = gl_WorkGroupID.x * group_size + tid;
|
||||
const uint end = (gl_WorkGroupID.x + 1) * group_size;
|
||||
const uint group = gl_WorkGroupID.x + gl_WorkGroupID.y * gl_NumWorkGroups.x + gl_WorkGroupID.z * gl_NumWorkGroups.x * gl_NumWorkGroups.y;
|
||||
if (group >= p.KY) {
|
||||
return;
|
||||
}
|
||||
const uint start = group * group_size + tid;
|
||||
const uint end = (group + 1) * group_size;
|
||||
|
||||
tmp[tid] = 0.0f;
|
||||
|
||||
|
||||
Reference in new issue
Block a user