Repository navigation
fix(subgroup_size): guard 64-bit invocation product overflow and zero local_size_x - #1939
Merged
ItsNotRexed merged 1 commit intoNov 22, 2026
Merged
Conversation
This was referenced Nov 22, 2026
Contributor
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression from this PR. RTX 4080 SUPER: 111/113 pass. On current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two edge-case bugs in
decide_subgroup_size()(runtime/src/subgroup_size.h):invocations:std::uint64_t(entry.local_size[0]) * entry.local_size[1] * entry.local_size[2]can wrap modulo 2^64 (e.g.{0x1000000, 0x1000000, 0x10000}wraps to0), bypassing themaxComputeWorkgroupSubgroupslimit (VUID-VkPipelineShaderStageCreateInfo-pNext-02756). Replaced withsubgroup_workgroup_fits(), which checksxy <= max_invocations / local_size[2]without overflow.local_size[0]falsely enablingREQUIRE_FULL_SUBGROUPS_BIT: When a malformed/unknownlocal_sizeentry yieldsentry.local_size[0] == 0,0 % r.wanted == 0evaluatedtrueand setVK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT. Guarded withentry.local_size[0] != 0.Regression Test (Fail-First)
Added two cases to
runtime/test/subgroup_size_test.cpp:Debug): failed on{0x1000000u, 0x1000000u, 0x10000u}(line 176: r.outcome == SubgroupOutcome::device_default && r.size == 0 && r.flags == 0,EXIT=1).Debug+RelWithDebInfo):subgroup_sizeandd3d12_vulkan_device(RTX 4070 Ti withLEONIDA_VK_VALIDATION=1) pass 2/2 in both configs with zero warnings and zero Vulkan validation errors.