mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3551] [Engine] add an opt-in CUDA and HIP hybrid build #4684
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4684
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3551
Author: @sakuumomo
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:pr/engine-hybrid-cuda-hip📝 Commits (10+)
e05bf4aAdd an opt-in build that runs CUDA and HIP in one processf8e0e29A hybrid build follows 0.2.2's HIP rules for a HIP primary: the early PLE flag and side-thread launch rule, the queue priming, and the integrated-GPU cache reserveb17e8dcdocs: the hybrid CUDA+HIP build (opt-in), its devices and its probe commandcf3d713A hybrid build follows 0.2.3's drafter rules for a HIP primary too: the dflash2 stream priority and fork defaults, the Strix Halo window cap and the 12 GB card linebf40f37hip_compat: cover the CUDA usages main's drafter brings to the HIP copy8843b4ehip_compat: drop grid_constant on the HIP copy0d8075fhybrid: do not glob the dsv41 engine path into strata256cd07hybrid: keep the moe_ws family out of the HIP glob - upstream #3752 (GP100 weight-stationary experts) landed with the 0.2.7 rebase, after this file was written. The kernels are pure PTX (prmt/mad.wide/f16x2 asm): on the CUDA side they are strata_mmq sources only under STRATA_EXPERIMENTAL_SM60, gated at run time to machines whose every GPU is cc 6.0. A hip-src copy of them fails on 'invalid output constraint =f' / 'invalid instruction' in the gfx1150 pass, and could never dispatch on an AMD device - so they belong beside the gdn_chunk/mmq_nvfp4/mmq_kq_lib exclusions. moko flavor build was the witness: moe_ws_down/gu_iq2/gu_iq3 were the only FAILED targets.1b8fa69hybrid: speak CUDA 13's plain runtime API names1b97058hybrid(cmake): keep upstream 0.2.12's NVIDIA-only trees out of the HIP glob📊 Changes
25 files changed (+2683 additions, -60 deletions)
View changed files
📝
CMakeLists.txt(+36 -5)➕
cmake/hip-host-tramp.py(+99 -0)➕
cmake/hybrid.cmake(+406 -0)➕
cmake/prefix-hip.py(+97 -0)📝
docs/AMD_HIP.md(+25 -1)📝
docs/MULTI_GPU.md(+2 -1)📝
include/strata/core/device.hpp(+3 -4)📝
include/strata/core/expert_cache.hpp(+1 -1)📝
include/strata/hip_compat/cublas_v2.h(+4 -0)📝
include/strata/hip_compat/cuda_runtime.h(+9 -0)➕
include/strata/hip_compat/hybrid_ordinal.h(+53 -0)📝
src/core/device.cu(+88 -3)📝
src/core/device_main.cpp(+9 -0)📝
src/core/dflash2.cpp(+16 -0)📝
src/core/expert_cache.cpp(+33 -14)➕
src/core/hip_api.h(+103 -0)➕
src/core/hybrid_hip.cpp(+336 -0)➕
src/core/hybrid_runtime.cpp(+996 -0)📝
src/core/peer_experts.cpp(+12 -0)📝
src/core/remote_experts.cpp(+30 -2)...and 5 more files
📄 Description
Problem and result: One process could not use an NVIDIA GPU and an AMD GPU together.
STRATA_HYBRIDstays off. Turning it on keeps the CUDA host path and compiles the shared kernels again for HIP. Ordinals past the CUDA devices are HIP. The build is Linux x86-64 only. A CUDA-only build and a HIP-only build leave this path out.A HIP device is named by its architecture, with compute capability left at 0 so it is not read as an NVIDIA architecture. Helpers are every other visible GPU. When hipBLASLt or rocBLAS is present, the HIP copies get the same switches as a pure HIP build, and the HIP prompt kernels use their own device table. When the current device is AMD, startup matches a pure HIP build: the probe accepts a non-gfx11 host, mapped expert fills go through one pinned buffer, the helper busy-waits for its stream,
--vram-elasticstays off, and the tail skip, PCIe share, architecture defaults, gfx12 chunk, and pipeline windows follow that card. A HIP primary does not probe the canonical PCIe pack or say that the share will change.Related discussion: no earlier issue agrees this scope.
Approach: The new files compile only with
STRATA_HYBRID. Default builds keep their previous sources and flags. gfx906 is refused at configure. If CMake leaves a configuration's HIP flags empty, the init flags are written back. TwoSHELL:-includegenerator expressions force-include the HIP headers, so CMake does not drop a repeated-include.Validation:
Passed: four compiles of
10fdcb31on Linux x86-64.STRATA_BUILD_TESTS=OFFandSTRATA_PORTABLE=ONon the Nix builds.HIP,
STRATA_HYBRIDoff:STRATA_ENABLE_HIP=ON,STRATA_ENABLE_CUDA=OFF,CMAKE_HIP_ARCHITECTURES=gfx1030,STRATA_PREFILL_MMQ=ON, HIP 7.2.3. CMake reported "Strata: HIP enabled, arch gfx1030" and did not report a hybrid build. Output/nix/store/087zqcrh6grkxlkqlmk5hfjm62flfaz5-strata-hip-0.2.1(strataandstrata-device). The compiler printed warnings while compiling for gfx1030. The link finished.CUDA,
STRATA_HYBRIDoff:STRATA_ENABLE_CUDA=ON,STRATA_ENABLE_HIP=OFF,CMAKE_CUDA_ARCHITECTURES=89-real,STRATA_PREFILL_MMQ=OFF, CUDA 12.9.86, gcc 14.4.0. CMake reported "Strata: CUDA enabled, arch 89-real" and did not report a hybrid build. Output/nix/store/3y0dc0nzihb4plvl8iaj087vw2b4clxm-strata-cuda-0.2.1(strataandstrata-device).STRATA_HYBRID=ON: the same CUDA flags, plus HIP gfx1150. CMake reported CUDA arch 89-real and "Strata hybrid: gfx1150". The log shows CUDA objects and HIP objects (strata_hip_objs, compiled for gfx1150) in one build. Output/nix/store/h0v2fqhpi910zfx8c148gl828aw12y81-strata-hybrid-0.2.1(strataandstrata-device). The compiler printed warnings while compiling for gfx1150. The link finished.SYCL: the
strata-sycl-devimage fromsycl/tools/Dockerfile(oneAPI 2026.1.0, no AOT device).sycl/tools/build.sh strataprintedBUILD EXIT 0anderrors: 0. Binary/tmp/strata-wt-hybrid/build-sycl/strata.The author ran it on two Linux machines and reports that both function as intended. The laptop has an RTX 4060 and a Radeon 890M and serves with
STRATA_HYBRID. The desktop has an RX 6800 and an RX 6900 XT and serves with the HIP build, soSTRATA_HYBRIDstays off there. No command log or timing was attached to that report.Failed: none observed.
Not run: a SYCL process on a device. A saved log of the laptop startup.
Limits: Linux x86-64 only. A HIP primary refuses
--vram-elastic.prime_hw_queuesstays on theSTRATA_USE_HIPpath. Data-type enums are not remapped between the two runtimes. The first host call on an AMD-only process can still enter the CUDA copy before a trampoline is installed. Compute capability 0 sends host code that branches on compute capability down the portable path while a HIP device is current.Changes since the last update (2026-10-27)
main(0.2.6,4b9e05a2); content re-landed verbatim. New tipb32dee9c— seven commits: the opt-in hybrid build, its 0.2.2/0.2.3 HIP-rule extensions, thehip_compatfixes main's drafter required, and the dsv41 glob guard. The commit hashes in the Validation section belong to the pre-rebase lineage.nixos, pin3032afd8) has served daily on both machines since the rebase: the laptop as the CUDA+HIP hybrid build (RTX 4060 + Radeon 890M), the desktop as a HIP-only build whereSTRATA_HYBRIDstays off (RX 6800 + RX 6900 XT).Changes since the last update (2026-10-30)
v0.2.8(870aedd9); content re-landed as before. The single conflict - the expert-cache auto message against upstream #4474's late-priced note - resolved in the rebase. New tip5fa28548, eight commits: the seven above plus themoe_wsglob exclusion (upstream #3752's GP100 weight-stationary expert kernels are pure PTX: the HIP lane can neither compile nor dispatch them, and the hybrid glob previously force-compiled them for gfx1150).nixos: every open PR branch of this stack re-merged in order onto870aedd9) passes every owner gate: HIP-only (gfx1030) and CUDA+HIP hybrid (gfx1150) flavor builds green with installCheck, and the session-file CPU and ThreadSanitizer suites green on the rebuilt lineage.Changes since the last update (2026-11-07)
v0.2.12(123bad4a, engine 0.1.58); content re-landed. New tip1b8fa69a(nine commits), plus one more commit found by the 0.2.12 flavor gate: upstream added NVIDIA-only files and trees that thecmake/hybrid.cmakeglob was force-compiling for the HIP lane, and all three survivals failed on the owner's CUDA+HIP build —src/prefill/moe_iq4_w4a8.cu(Turing+ PTX:mma.m16n8k32,cp.async,__cvta_generic_to_shared) andsrc/prefill/gdn_harness.cu(a test-target harness whose fixture header lives intests/gdn/) join themoe_ws/test exclusions, and the wholesrc/split/engine tree (sFNX's 2-4-card split engine,STRATA_BUILD_SPLIT, OFF by default) joins the existingsrc/dsv41exclusion: its sources need the Makefile definesFNX_27B/FNX_NCARDthat only its ownadd_subdirectorytargets receive. The exclusion proofs are recorded in the commit message (no HIP object names the w4a8 symbols: its only caller ismoe_mmq.cu'sContext::run, inside#if !defined(GGML_USE_HIP)). Two rebase conflicts, both fusions rather than choices: the opt-in hybrid commit against upstream'sdf2_tap_dump/prefill_cap_warnhunks ingenerate.cpp, and the side-thread launch rule against upstream'sSTRATA_LAUNCH_PROBEdiagnostic inverify.cpp; range-diff against the 0.2.8-era branch is 1:1 apart from the glob fix. Current tip1b97058c.nixos@c3e4cdc4, 93 signed commits: this stack re-merged in order onto123bad4a, the hybrid merge carrying the glob fix) passes the owner gates again: HIP-only (gfx1030) and CUDA+HIP hybrid (gfx1150, CUDA 13) flavor builds with installCheck, CPU session suites, ThreadSanitizer, and the serve suites green.main.Branch commits were re-signed (GPG ed25519) on 2026-11-07; trees are unchanged from the validated work apart from the glob fix, which the flavor gate demanded.
Dependencies: none — #3553 stacks on this branch.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.