You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ignoring subspan byte offset when converting to SPIR-V causes segfault on SwiftShader #5372
I don't have swiftshader built - can you provide more information about the crash? (backtrace, etc)
Knowing whether the crash is in a Vulkan API call or whether it is in the execution of the SPIR-V will help narrow down where the error is. If the only issue is with Vulkan then I suspect SPIR-V codegen.
E ../iree/hal/vulkan/debug_reporter.cc:42] Validation Error: [ VUID-VkPipelineLayoutCreateInfo-descriptorType-03024 ] Object 0: handle = 0xe09228, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xeb2bfadc | vkCreatePipelineLayout(): max per-stage storage buffer bindings count (3) exceeds device maxPerStageDescriptorUpdateAfterBindStorageBuffers limit (0). The Vulkan spec states: The total number of descriptors with a descriptorType of VK_DESCRIPTOR_TYPE_STORAGE_BUFFER and VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible to any given shader stage across all elements of pSetLayouts must be less than or equal to VkPhysicalDeviceDescriptorIndexingProperties::maxPerStageDescriptorUpdateAfterBindStorageBuffers (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkPipelineLayoutCreateInfo-descriptorType-03024)
Hmm that may be an indicator - it's weird it lists maxPerStageDescriptorUpdateAfterBindStorageBuffers as we aren't using that feature. It's possible this is a bug in swiftshader or the validation layers. 3 bindings should be fine as maxPerStageDescriptorStorageBuffers == 16.
The final error is suspicious as well - have you ever seen that anywhere else? I know we have some error like it, but that one looks worse than normal.
[4480951.699175] Thread<00>[3498991]: segfault at 569330e7e3c0 ip 00007fd7aa92d337 sp 00007fd7b315f488 error 4
[4480951.699183] Thread<12>[3499003]: segfault at 569330e7e1c0 ip 00007fd7aa92d337 sp 00007fd7ad13d488 error 4
[4480951.699185] in memfd:swiftshader_jit (deleted)[7fd7aa92d000+1000]
ah yeah, so this is in their JIT'ed SPIRV - so either it's our generated SPIRV that is bad (accessing bad memory) or the above binding weirdness is feeding bad memory into the JIT. I wouldn't expect those warnings to start appearing with the linked PR - it doesn't change anything but some binding indices - there's no runtime or buffer allocation changes. Do you get those warnings before the PR? (I don't see anything similar with my local latest Vulkan SDK)
We could probably try turning off this pass (or adding a flag for it) for the spirv case until it's fixed, though then other models are likely to fail with too many bindings errors as they were before. Will let y'all decide the best path there :)
changed the title [-]Segmentation fault when running MobileNet V2 on SwiftShader[/-][+]Ignoring subspan byte offset when converting to SPIR-V causes segfault on SwiftShader[/+]on Apr 12, 2021
Activity
hanhanW commentedon Apr 9, 2021
Verified that the root cause is #5328
I checkout to d3eb8e4, and it worked.
I checkout to 56307e1, and it crashed.
To repro:
Set up SwiftShader env:
Compile to IREE module:
iree-translate --iree-mlir-to-vm-bytecode-module --iree-hal-target-backends=vulkan-spirv ~/input.mlir -o a.vmfb -iree-flow-dispatch-linalg-on-tensors=true -iree-codegen-spirv-experimental-linalg-on-tensors=trueRun
iree-run-module --module_file=a.vmfb --driver=vulkan --entry_function=call --function_inputs=1x16000xf32=0The
input.mliris at https://gist.githubusercontent.com/hanhanW/dafdd5ae914f866e592e124428467aed/raw/1d751b55e550b9b2d8a18a8533ff813440fec2f9/keyword_spotting_tests_fake-mobilenet-v2.mlir(coming from #5313, and found that we can repro it with the same MLIR file)
cc @MaheshRavishankar
Set IREE codegen to Linalg on tensors by default.
benvanik commentedon Apr 9, 2021
I don't have swiftshader built - can you provide more information about the crash? (backtrace, etc)
Knowing whether the crash is in a Vulkan API call or whether it is in the execution of the SPIR-V will help narrow down where the error is. If the only issue is with Vulkan then I suspect SPIR-V codegen.
benvanik commentedon Apr 9, 2021
Also, any logs from the validation layers?
hanhanW commentedon Apr 9, 2021
I actually can only see
zsh: abort build-tracy/iree/tools/iree-run-module --module_file=a.vmfb --driver=vulkanso I did not attach it.But now I found something interesting in stderr: https://gist.githubusercontent.com/hanhanW/07fe9063a98b7d649f700649f641e608/raw/68ef06db0359839b7dc55783865c903024028494/gistfile1.txt
This looks new to me?
What env should I set to get more information?
hanhanW commentedon Apr 9, 2021
With
VK_LOADER_DEBUG=all, more logs!https://gist.githubusercontent.com/hanhanW/1becdd8a4c832bbc53bf9460c0caaded/raw/7c481de0d829fb7ce41bc633fc7363abe1bae263/gistfile1.txt
hanhanW commentedon Apr 9, 2021
I'm not sure if this is useful. Some log from
dmesg.benvanik commentedon Apr 9, 2021
Hmm that may be an indicator - it's weird it lists maxPerStageDescriptorUpdateAfterBindStorageBuffers as we aren't using that feature. It's possible this is a bug in swiftshader or the validation layers. 3 bindings should be fine as maxPerStageDescriptorStorageBuffers == 16.
That maxPerStageDescriptorUpdateAfterBindStorageBuffers property comes in Vulkan 1.2, which swiftshader only half supports. It's possible that our hack here is triggering, assuming you aren't running this on android:
https://github.com/google/iree/blob/99c8eaca7ffc4a776dd4d0a0f5d82ab5c12d5376/iree/hal/vulkan/registration/driver_module.cc#L52-L59
Try always forcing it to 1.1 (the ANDROID path)?
The final error is suspicious as well - have you ever seen that anywhere else? I know we have some error like it, but that one looks worse than normal.
benvanik commentedon Apr 9, 2021
ah yeah, so this is in their JIT'ed SPIRV - so either it's our generated SPIRV that is bad (accessing bad memory) or the above binding weirdness is feeding bad memory into the JIT. I wouldn't expect those warnings to start appearing with the linked PR - it doesn't change anything but some binding indices - there's no runtime or buffer allocation changes. Do you get those warnings before the PR? (I don't see anything similar with my local latest Vulkan SDK)
hanhanW commentedon Apr 9, 2021
Let me checkout to previous one, rebuild, and circle back to you
benvanik commentedon Apr 9, 2021
I'll do an IR dump and see if I spot anything weird.
hanhanW commentedon Apr 9, 2021
They are basically the same. https://gist.githubusercontent.com/hanhanW/5c6cce44888f3c1089cd70df780ea36b/raw/4c9f092bd7e038d6573f7fc890fd0af6fd6c77df/gistfile1.txt
I will try to generate CPU kernels with ASAN later, and see if we can get something.
benvanik commentedon Apr 9, 2021
Good thinking! Swiftshader can maybe be run with ASAN as well (I did it way back in the day but forget what it entailed - maybe @ScottTodd remembers?)
7 remaining items
benvanik commentedon Apr 9, 2021
Quick look at the code and I don't spot anything reading the offset in the SPIRV/NVVM paths.
The LLVM path does this:
https://github.com/google/iree/blob/a578d6a96ecfc732e06fc7662d59b9ab53d7ad88/iree/compiler/Conversion/LinalgToLLVM/ConvertToLLVM.cpp#L510-L512
https://github.com/google/iree/blob/a578d6a96ecfc732e06fc7662d59b9ab53d7ad88/iree/compiler/Conversion/LinalgToLLVM/ConvertToLLVM.cpp#L232-L236
I'd expect to see a byte_offset() access somewhere in here:
https://github.com/google/iree/blob/79dc138c0b959d0823f21400fff868d8a8a3d95f/iree/compiler/Conversion/LinalgToSPIRV/ConvertToSPIRVPass.cpp#L73-L122
hanhanW commentedon Apr 9, 2021
@antiagainst could you take a look at binding stuff?
benvanik commentedon Apr 9, 2021
🤦 I'll fix that :P
antiagainst commentedon Apr 9, 2021
Ah, yes. Thanks @hanhanW and @benvanik for pinpointing the issue! I'll take a look and fix.
benvanik commentedon Apr 9, 2021
We could probably try turning off this pass (or adding a flag for it) for the spirv case until it's fixed, though then other models are likely to fail with too many bindings errors as they were before. Will let y'all decide the best path there :)
MaheshRavishankar commentedon Apr 9, 2021
Lets fix the bug on the SPIR-V path. It shouldnt be too much of a lift here. We will need this to switch to linalg on tensors.
MaheshRavishankar commentedon Apr 9, 2021
I am assuming this is why the BERT test is failing on PR #5390 as well (https://source.cloud.google.com/results/invocations/1909893e-4995-4520-b0ba-608b586e68d5/targets/iree%2Fgcp_ubuntu%2Fbazel%2Flinux%2Fx86-swiftshader%2Fcore%2Fpresubmit/log)
[-]Segmentation fault when running MobileNet V2 on SwiftShader[/-][+]Ignoring subspan byte offset when converting to SPIR-V causes segfault on SwiftShader[/+][spirv] Properly handle HAL subspan byte offset (#5403)
Set IREE codegen to Linalg on tensors by default.
antiagainst commentedon Apr 14, 2021
Fixed via #5403.
Set IREE codegen to Linalg on tensors by default. (#5375)