|
| 1 | ++++ |
| 2 | +title = "Rust GPU Transitions to Community Ownership" |
| 3 | +authors = ["LegNeato", "eddyb"] |
| 4 | ++++ |
| 5 | + |
| 6 | +We are excited to announce that as of today the <a |
| 7 | +href="https://rust-gpu.github.io">Rust GPU</a> project will be transitioning from |
| 8 | +[Embark Studios](https://www.embark-studios.com/) to community ownership under the [Rust |
| 9 | +GPU GitHub organization](https://github.com/rust-gpu/rust-gpu). This move marks the |
| 10 | +beginning of a broader strategy aimed at revitalizing, unifying, and standardizing GPU |
| 11 | +programming in Rust. We are eager to share more details in the near future but in the |
| 12 | +meantime if you are a maintainer of a GPU-related Rust project, please reach out! |
| 13 | + |
| 14 | +## What is Rust GPU? |
| 15 | + |
| 16 | +<a href="https://rust-gpu.github.io">Rust GPU</a> makes it possible to write and run GPU |
| 17 | +software in Rust, leveraging the language's powerful safety and concurrency features to |
| 18 | +enhance performance and reliability. With Rust GPU, you can seamlessly develop for both |
| 19 | +CPU and GPU using a unified codebase, all while benefiting from Rust’s existing |
| 20 | +ecosystem. |
| 21 | + |
| 22 | +The Rust GPU compiler backend emits code compatible with |
| 23 | +[Vulkan](https://www.vulkan.org), ensuring your code runs across a wide range of devices |
| 24 | +and vendors. |
| 25 | + |
| 26 | +If instead you wish to stick to the NVIDIA ecosystem, stay tuned as the [Rust |
| 27 | +CUDA](https://github.com/rust-gpu/rust-cuda) project is in the process of being rebooted |
| 28 | +and possibly integrated with Rust GPU. |
| 29 | + |
| 30 | +To put Rust GPU in context, here's an overview of the current landscape: |
| 31 | + |
| 32 | +- [rust-gpu](https://github.com/EmbarkStudios/rust-gpu): Compiles unmodified Rust code to |
| 33 | + [SPIR-V](https://www.khronos.org/spir/) (Vulkan) so that it can run on the GPU. |
| 34 | +- [rust-cuda](https://github.com/Rust-GPU/Rust-CUDA): Compiles unmodified Rust code to |
| 35 | + [NVVM](https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html) (CUDA) so that it can run |
| 36 | + on the GPU. _Currently unmaintained but stay tuned!_ |
| 37 | +- [nvptx backend in |
| 38 | + rustc](https://doc.rust-lang.org/rustc/platform-support/nvptx64-nvidia-cuda.html): |
| 39 | + Compiles unmodified Rust code to |
| 40 | + [PTX](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html) (CUDA) so |
| 41 | + that it can run on the GPU. |
| 42 | +- [CubeCL](https://github.com/tracel-ai/cubecl): Compute language extension for Rust. |
| 43 | + Enables annotated Rust code to run on the GPU. |
| 44 | +- [krnl](https://github.com/charles-r-earp/krnl): Safe, portable, high performance |
| 45 | + compute (GPGPU) kernels. Enables annotated Rust code to run on the GPU (via Rust GPU). |
| 46 | +- [cudarc](https://github.com/coreylowman/cudarc): Minimal and safe api over the CUDA |
| 47 | + toolkit. Enables calling CUDA from Rust running on the CPU. |
| 48 | +- [wgpu](https://wgpu.rs/): A safe and portable graphics library for Rust based on the |
| 49 | + WebGPU API. Enables communicating with the GPU from Rust running on the CPU. |
| 50 | +- [naga](https://github.com/gfx-rs/wgpu/tree/trunk/naga): A source code translator |
| 51 | + written in Rust that converts between various GPU-specific shader languages |
| 52 | + ([WGSL](https://www.w3.org/TR/WGSL/), |
| 53 | + [GLSL](https://en.wikipedia.org/wiki/OpenGL_Shading_Language), |
| 54 | + [HLSL](https://en.wikipedia.org/wiki/High-Level_Shader_Language), and |
| 55 | + [MSL](https://developer.apple.com/metal/)). These shaders ultimately run on the GPU. |
| 56 | +- [ZLUDA](https://github.com/vosen/ZLUDA): A drop-in replacement for CUDA written in |
| 57 | + Rust. Enables using tools and libraries targeted at CUDA on non-NVIDIA hardware. |
| 58 | +- [Ashai Linux GPU |
| 59 | + Drivers](https://asahilinux.org/2022/12/gpu-drivers-now-in-asahi-linux/): GPU drivers |
| 60 | + partially written in Rust to add Linux support for Apple GPUs. |
| 61 | + |
| 62 | +## Why Rust for GPU Programming? |
| 63 | + |
| 64 | +1. **Modern and Unified Experience:** There is no longer a need to learn a GPU-specific |
| 65 | + programming language. You can write both CPU and GPU code in Rust, leveraging your |
| 66 | + existing Rust knowledge and maintaining a consistent development experience. |
| 67 | + Furthermore, the _same code can run on both the CPU and GPU_, with divergent behavior |
| 68 | + gated behind `cfg` attributes and macros where necessary. |
| 69 | + |
| 70 | + Even if your current codebase isn't written in Rust, choosing Rust for the GPU parts |
| 71 | + instead of GPU-specific languages gives you more widely applicable skills in one of |
| 72 | + the [fastest-growing languages on |
| 73 | + GitHub](https://octoverse.github.com/2022/top-programming-languages). Rust is also |
| 74 | + one of the [most admired programming |
| 75 | + languages](https://github.blog/developer-skills/programming-languages-and-frameworks/why-rust-is-the-most-admired-language-among-developers/) |
| 76 | + while GPU-specific languages are considered a necessary evil. |
| 77 | + |
| 78 | +2. **Fearless Concurrency:** Rust's ownership model and type system guarantee memory |
| 79 | + safety, minimizing bugs and undefined behavior. Rust's borrow checker also enables |
| 80 | + fearless concurrency, which is essential for maximizing performance on massively |
| 81 | + parallel GPUs. |
| 82 | + |
| 83 | +3. **Powerful Abstractions:** Programming in GPU-specific languages can often feel like |
| 84 | + [taking a step back to the 90s](https://xol.io/blah/death-to-shading-languages/), |
| 85 | + where primitive tools and sharp edges abound. Because of this, code written for GPUs |
| 86 | + is simplistic with low cyclomatic complexity. Rust has an expressive type system and |
| 87 | + zero-cost abstractions that enable writing high-level, reusable code without |
| 88 | + sacrificing performance. This approach leads to more maintainable and sophisticated |
| 89 | + GPU programs, streamlining the development process and enhancing productivity. |
| 90 | + |
| 91 | +4. **Leverage Existing Ecosystem:** The state-of-the-art for sharing GPU code is copy |
| 92 | + and pasting. With Rust GPU we are excited to bring the excellent `cargo` and |
| 93 | + crates.io ecosystem to GPU programming and provide some sanity. |
| 94 | + |
| 95 | + Additionally, Rust's `no_std` ecosystem offers a wide array of libraries that can be |
| 96 | + used in environments without the standard library. Traditionally this has meant |
| 97 | + embedded devices, but a lot of the same assumptions apply to GPU shaders! As a |
| 98 | + consequence, you can reuse [existing `no_std` libraries from |
| 99 | + crates.io](https://crates.io/categories/no-std::no-alloc) in your GPU code _without |
| 100 | + the authors explicitly adding GPU support_. This is uniquely enabled by Rust GPU's |
| 101 | + implementation choices and Rust's |
| 102 | + [registers](https://without.boats/blog/the-registers-of-rust/). Sharing and reusing |
| 103 | + code from the greater Rust ecosystem is a superpower when writing GPU programs that |
| 104 | + will massively compound over time. |
| 105 | + |
| 106 | + Soon developers will write and share Rust libraries that _require_ running on the |
| 107 | + GPU, similar to how some existing open source libraries require a specific OS or CPU |
| 108 | + architecture. We expect many innovative GPU-specific algorithms and projects to be |
| 109 | + built in Rust. |
| 110 | + |
| 111 | +## A Heartfelt Thank You to Embark |
| 112 | + |
| 113 | +First and foremost, we extend our deepest gratitude to [Embark |
| 114 | +Studios](https://www.embark-studios.com/) for their incredible work in kickstarting and |
| 115 | +supporting the Rust GPU project. Their dedication and contributions have been |
| 116 | +invaluable, laying a strong foundation for the future. The community is immensely |
| 117 | +grateful for all the resources and expertise Embark has poured into this project. |
| 118 | + |
| 119 | +## Transition Challenges: Repository Transfer |
| 120 | + |
| 121 | +Unfortunately, Embark has decided not to transfer the existing repository via [GitHub's |
| 122 | +transfer |
| 123 | +tool](https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository), |
| 124 | +which means we will lose all our stars, issues, and pull requests. Additionally, |
| 125 | +automatic GitHub redirects will not be added. All this causes avoidable churn. |
| 126 | + |
| 127 | +We have not fully transitioned to the new community-owned repository due to these |
| 128 | +downsides and we believe the best course of action is to encourage Embark to reconsider |
| 129 | +and simply press the GitHub transfer button, easing this transition for everyone |
| 130 | +involved. We appreciate the community's patience and understanding as we get things |
| 131 | +sorted out and we'd love your support encouraging Embark to reconsider the mechanics of |
| 132 | +the transfer. |
| 133 | + |
| 134 | +## New Focus: GPU Compute and GPGPU |
| 135 | + |
| 136 | +With the industry's growing emphasis on generative AI and LLMs, we are shifting our |
| 137 | +primary focus towards GPU compute and General-Purpose GPU (GPGPU) programming. This also |
| 138 | +aligns with the trend in GPU hardware to increasingly utilize the compute capabilities |
| 139 | +of GPUs to run graphics pipelines as software libraries rather than relying on |
| 140 | +specialized hardware. Even graphics-focused programs such as video games are moving away |
| 141 | +from solely relying on graphics pipelines and instead running as much of the engine as |
| 142 | +possible in GPU compute. |
| 143 | + |
| 144 | +In the past, the primary focus on graphics use-cases did not materialize the necessary |
| 145 | +contributors and community engagement to make the Rust GPU project sustainable. We hope |
| 146 | +our new focus will attract more contributors and users. |
| 147 | + |
| 148 | +However, it is important to note that graphics use-cases will continue to be supported, |
| 149 | +developed, and improved in Rust GPU! We appreciate our early graphics adopters and |
| 150 | +remain committed to enhancing the graphics capabilities of Rust GPU. |
| 151 | + |
| 152 | +## Addressing Stability and Nightly Rust |
| 153 | + |
| 154 | +Though Rust GPU requires the nightly version of Rust, Embark had unique stability goals |
| 155 | +which resulted in Rust GPU not tracking the _latest_ nightly. This has been a hurdle for |
| 156 | +adoption, as most people experimenting with Rust GPU are likely already on nightly to |
| 157 | +get the latest and greatest, not use a randomly chosen nightly from months ago. To |
| 158 | +address this, we will be tracking the latest Rust nightly builds moving forward. For |
| 159 | +those concerned about stability, you can pin to a particular nightly version via <a |
| 160 | +href="https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file">`rust-toolchain`</a>, |
| 161 | +and there are ways to build your GPU code with nightly while keeping your CPU code on |
| 162 | +stable. |
| 163 | + |
| 164 | +With today's release we are closer to this goal but we aren't quite tracking the latest |
| 165 | +nightly yet as some newer `rustc` changes require more substantial changes to Rust GPU's |
| 166 | +compiler backend. |
| 167 | + |
| 168 | +## Short-Term Roadmap |
| 169 | + |
| 170 | +Our immediate focus is on the following tasks: |
| 171 | + |
| 172 | +- **Merge all outstanding work.** |
| 173 | +- **Track the latest Rust nightly.** Stay up-to-date with the latest developments in |
| 174 | + Rust and catch changes that break Rust GPU's compiler backend as soon as they land |
| 175 | + upstream. |
| 176 | +- **Release more often.** Increase our release cadence to deliver improvements and fixes |
| 177 | + more frequently, as well as aid in debugging issues. |
| 178 | +- **Extend/update documentation, FAQ, and guides.** Provide solutions to common problems |
| 179 | + and usage scenarios and document unsupported language constructs. |
| 180 | +- **Better compatibility.** |
| 181 | + - Fully switch to [quasi-pointers](https://github.com/EmbarkStudios/spirt/pull/24) to |
| 182 | + support more advanced Rust constructs. |
| 183 | + - Add `alloc` support. This will allow us to move from supporting [at most 500 |
| 184 | + `no_std`, no alloc crates](https://crates.io/categories/no-std::no-alloc) to [over |
| 185 | + 6,000 `no_std` + alloc crates](https://crates.io/categories/no-std). |
| 186 | +- **Better testing.** |
| 187 | + - Develop our own crater-like tool to create a burndown list of `no_std` and `alloc` |
| 188 | + crates that don't work with Rust GPU. |
| 189 | + - Implement a differential testing harness. |
| 190 | + - Establish ecosystem CI similar to the [SWC |
| 191 | + project](https://github.com/swc-project/swc/tree/main/.github/swc-ecosystem-ci). |
| 192 | + |
| 193 | +## Long-Term Vision: First-Class GPU Targets in Rust |
| 194 | + |
| 195 | +Looking further ahead, one of our ambitious goals is to merge Rust GPU or its successor |
| 196 | +into the Rust compiler itself. We want to make GPUs (and TPUs and NPUs) first-class |
| 197 | +targets in Rust and make programming them as ergonomic as CPU programming. **Hardware is |
| 198 | +shifting from scalar, serial processing to matrix, parallel processing—software must do |
| 199 | +the same.** We are excited about the future of Rust GPU and the potential it holds. |
| 200 | + |
| 201 | +Thank you for your continued support and contributions. Stay tuned for more updates, and |
| 202 | +don't hesitate to reach out if you have any questions or want to get involved. |
| 203 | + |
| 204 | +Happy coding! |
| 205 | + |
| 206 | +_LegNeato ([GitHub](https://github.com/LegNeato), |
| 207 | +[Twitter](https://twitter.com/legneato)) and eddyb ([GitHub](https://github.com/eddyb))_ |
| 208 | + |
| 209 | +**Rust GPU Maintainers** |
0 commit comments