Skip to content

Update WebGPU target using latest Tint code. - #10134

Merged
ScottTodd merged 14 commits into
iree-org:mainfrom
ScottTodd:webgpu-update
Oct 3, 2022
Merged

ScottTodd merged 14 commits into
iree-org:mainfrom
ScottTodd:webgpu-update

Conversation

@ScottTodd

@ScottTodd ScottTodd commented Aug 18, 2022 •

Copy link
Copy Markdown
Member

Tested on a few programs, seems to still work: simple programs (no push constants) compile to WGSL that looks reasonable and complex programs (push constants) fail with errors like this:

Tint reported 1 error(s) for a SPIR-V program, see diagnostics:
error: unknown SPIR-V storage class: 9SPIR-V pointer type with ID 7 has invalid storage class 9
D:\dev\projects\iree/../iree-tmp/webgpu/unidirectional_lstm_webgpu_2022_08_18/\module__main_dispatch_0.mlir:2:2: error: failed to compile SPIR-V to WGSL. Consider inspecting the shader program using -iree-hal-dump-executable-intermediates.
  hal.executable.variant public @webgpu_wgsl_fb, target = <"webgpu", "webgpu-wgsl-fb", {spv.target_env = #spv.target_env<#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits<>>}> {
 ^
D:\dev\projects\iree/../iree-tmp/webgpu/unidirectional_lstm_webgpu_2022_08_18/\module__main_dispatch_0.mlir:2:2: note: see current operation: "hal.executable.variant"() ({
...

I want to route those diagnostics to MLIR and add line breaks at some point (that will really help output legibility when the compiler runs multithreaded)


This also adds a few compiler lit tests and enables building and running those tests on our CI (build_all and test_all). As compatibility issues are fixed, some of those lit tests will be removed or adjusted. At that point I plan to enable the rest of our test suite, similar to how Wasm is tested:

# Check WebAssembly compilation (LLVM backend with wasm target triple).
# Note:
# * no 'driver' arg is set, so this does not test execution
# * the test suite name is missing "_driver" from "check_target_driver"
# * this isn't an "end to end" test suite in the same sense as the other
# test suites in this file, but the test coverage is still useful
# Hopefully at some point we can build WebAssembly execution testing into our
# infrastructure and this will no longer bend our testing definitions as much.
iree_check_single_backend_test_suite(
name = "check_llvm-cpu-wasm",

@ScottTodd
ScottTodd requested a review from pzread as a code owner September 1, 2022 15:57
@ScottTodd
ScottTodd marked this pull request as draft September 1, 2022 15:59
@ScottTodd
ScottTodd marked this pull request as ready for review September 1, 2022 16:20
@ScottTodd
ScottTodd requested review from antiagainst and removed request for pzread September 1, 2022 16:21
Comment thread build_tools/cmake/build_all.sh Outdated
Comment on lines +57 to +59
# Enable WebGPU compiler builds and tests. All deps get fetched as needed,
# but some of the deps are too large to enable by default for all developers.
"-DIREE_TARGET_BACKEND_WEBGPU=ON"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GMNGeoffrey / @pzread FYI - if you want to review this part of the PR (covered by CODEOWNERS :P)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also mention this a bit in my RFC: Promoting IREE web platform / Emscripten builds to "stable"

Enabling this option fetches Tint on-demand for the WebGPU compiler target to use to compile SPIR-V to WGSL.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just synced this PR and I'm looking to land it. @GMNGeoffrey does this satisfy your point on the RFC?

Regarding on-demand dependencies. Can we make these as not-magic as possible?

iree/CMakeLists.txt

Lines 702 to 709 in fe40a3d

if(IREE_TARGET_BACKEND_WEBGPU)
# Tint is needed to compile SPIR-V into WGSL source code.
# Tint also requires SPIRV-Tools, which requires SPIRV-Headers.
iree_set_spirv_headers_cmake_options()
add_subdirectory(third_party/spirv_headers EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/spirv-tools EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/tint EXCLUDE_FROM_ALL)
endif()

https://github.com/iree-org/iree/blob/main/build_tools/third_party/tint/CMakeLists.txt

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear... maybe these are filling up the runner's disk space? https://github.com/iree-org/iree/actions/runs/3137979962

build_all
Unhandled exception. System.IO.IOException: No space left on device : '/runner-root/actions-runner/_diag/Worker_20220927-182608-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
System.IO.IOException: No space left on device : '/runner-root/actions-runner/_diag/Worker_20220927-182608-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at GitHub.Runner.Common.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id)
   at GitHub.Runner.Common.HostTraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
   at GitHub.Runner.Worker.Worker.RunAsync(String pipeIn, String pipeOut)
   at GitHub.Runner.Worker.Program.MainAsync(IHostContext context, String[] args)
System.IO.IOException: No space left on device : '/runner-root/actions-runner/_diag/Worker_20220927-182608-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at GitHub.Runner.Common.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at System.Diagnostics.TraceSource.Flush()
   at GitHub.Runner.Common.TraceManager.Dispose(Boolean disposing)
   at GitHub.Runner.Common.TraceManager.Dispose()
   at GitHub.Runner.Common.HostContext.Dispose(Boolean disposing)
   at GitHub.Runner.Common.HostTraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
   at GitHub.Runner.Common.Tracing.Error(Exception exception)
   at GitHub.Runner.Worker.Program.MainAsync(IHostContext context, String[] args)
   at GitHub.Runner.Common.HostContext.Dispose()
   at GitHub.Runner.Worker.Program.Main(String[] args)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should increase the CPU runner size? #10518

CPU_IMAGE="github-runner-cpu-2022-09-22-1663865258"
# The image is only 10GB, but we need some space for Docker images and such.
CPU_DISK_SIZE_GB=100

Can we view a breakdown of how disk space is being used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually building on GPU machines, or just running already built tests/benchmarks/etc.? (The new deps here should only affect the compiler build on CPU/host machines)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not building, but the setup step for the ramdisk is the same for both. We could add a conditional. But I actually think using 50/85 GB on the ramdisk is probably a bad idea anyway. We could see about lowering the also

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm... I'd still like to land this soon, so I can rebase the benvanik-webgpu-skeleton branch on the compiler changes here. I think I'll split this into two PRs: one updating the code, and one turning on the CI. The CI change will need to either change how the deps are installed or wait for infrastructure changes (more disk space, or more efficient use of the current disk space).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the CI-affecting changes to #10627

Comment thread build_tools/cmake/build_all.sh Outdated
Comment on lines +57 to +59
# Enable WebGPU compiler builds and tests. All deps get fetched as needed,
# but some of the deps are too large to enable by default for all developers.
"-DIREE_TARGET_BACKEND_WEBGPU=ON"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the original mention here. I may need to adjust my email filters to differentiate "assigned as reviewer because someone touched a build config" and "someone explicitly mentioned me"...

So the runner is actually doing its work in a 50G ramdisk (you reviewed that PR 😛): https://github.com/iree-org/iree/blob/5c1ce206c2/build_tools/github_actions/runner/config/setup.sh#L19. Until now that was plenty of space for building IREE. How big is this dependency exactly?? I don't love fetching on-demand on CI. For CUDA we build the necessary parts of the dep into the docker image. Can we do that instead?

Separately: turning this on here puts building the Web GPU backend in everyone's presubmits. Is it sufficiently stable for that?

Comment thread build_tools/cmake/build_host_tools.sh Resolved
@ScottTodd
ScottTodd enabled auto-merge (squash) October 3, 2022 16:42
@ScottTodd
ScottTodd merged commit 339d9d7 into iree-org:main Oct 3, 2022
@ScottTodd
ScottTodd deleted the webgpu-update branch October 3, 2022 17:21
jpienaar pushed a commit to jpienaar/iree that referenced this pull request Oct 3, 2022
Tested on a few programs, seems to still work: simple programs (no push
constants) compile to WGSL that looks reasonable and complex programs
(push constants) fail with errors like this:
```
Tint reported 1 error(s) for a SPIR-V program, see diagnostics:
error: unknown SPIR-V storage class: 9SPIR-V pointer type with ID 7 has invalid storage class 9
D:\dev\projects\iree/../iree-tmp/webgpu/unidirectional_lstm_webgpu_2022_08_18/\module__main_dispatch_0.mlir:2:2: error: failed to compile SPIR-V to WGSL. Consider inspecting the shader program using -iree-hal-dump-executable-intermediates.
  hal.executable.variant public @webgpu_wgsl_fb, target = <"webgpu", "webgpu-wgsl-fb", {spv.target_env = #spv.target_env<#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits<>>}> {
 ^
D:\dev\projects\iree/../iree-tmp/webgpu/unidirectional_lstm_webgpu_2022_08_18/\module__main_dispatch_0.mlir:2:2: note: see current operation: "hal.executable.variant"() ({
...
```

I want to route those diagnostics to MLIR and add line breaks at some
point (that will really help output legibility when the compiler runs
multithreaded)

---

This also adds a few compiler lit tests ~and enables building and
running those tests on our CI (`build_all` and `test_all`)~. As
compatibility issues are fixed, some of those lit tests will be removed
or adjusted. At that point I plan to enable the rest of our test suite,
similar to how Wasm is tested:
https://github.com/iree-org/iree/blob/2b226445bec8c8e28e863a467fc9e9db70a53296/tests/e2e/xla_ops/BUILD#L393-L402
ScottTodd added a commit that referenced this pull request Oct 25, 2022
…10627)

Split from #10134 - this starts
building the WebGPU compiler target backend and runs the tests added in
that PR.
PhaneeshB pushed a commit to PhaneeshB/iree that referenced this pull request Oct 31, 2022
…ree-org#10627)

Split from iree-org#10134 - this starts
building the WebGPU compiler target backend and runs the tests added in
that PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/web 🌐 Web-specific build, execution, benchmarking, and deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants