mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3553] [Engine] let a HIP helper read pinned expert rows in place #4686
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#4686
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/3553
Author: @sakuumomo
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:pr/engine-hybrid-apu-pin📝 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
28 files changed (+2850 additions, -62 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/core/expert_source.hpp(+14 -0)📝
include/strata/core/remote_experts.hpp(+22 -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/expert_source.cpp(+66 -1)➕
src/core/hip_api.h(+103 -0)➕
src/core/hybrid_hip.cpp(+336 -0)...and 8 more files
📄 Description
Depends on #3551.
Merge #3551 first. This branch is that pull request plus one commit,
604b2cf3. Until #3551 is merged, the file list here includes the hybrid build as well. The change that belongs to this pull request is that last commit only: 161 lines in five files (git diff 10fdcb31..604b2cf3).A merge commit of #3551 leaves this pull request showing only
604b2cf3. A squash of #3551 keeps the hybrid diff here, and this branch then needs a rebase onto that squash.Problem and result: With
STRATA_HYBRID, a pinned expert the helper can see was still the primary's row, so the primary copied it over PCIe. That row is now the helper's, and the primary does not copy it. The first helper claims the row, so a second HIP device does not launch the same rows.holds()stays cache membership. Decode usesclaims(), which is the cache or a pin that device can read. WithSTRATA_HYBRIDoff, the previousholds()body and the previous cache lookup stay.Related discussion: #3551, which this change needs. No separate issue.
Approach:
claims()is compiled only withSTRATA_HYBRID. A failed map, a 64-byte miss, a lost exchange, a soft commit, or an unregistered pin leaves the row on the CPU. The one-token path and the multi-token path both set the owned kind fromowns()after a successfulbegin().Validation:
Passed: four compiles of
604b2cf3on 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/zm4ln1bi1v0ahalc4y1wzi5i1nzhifhy-strata-hip-0.2.1(strataandstrata-device).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/qv2y92cv0q6csg5v9mh9wgq9dipq4ygg-strata-cuda-0.2.1(strataandstrata-device).STRATA_HYBRID=ON: the same CUDA flags, plus HIP gfx1150. CMake reported CUDA arch 89-real, "Strata hybrid: gfx1150", and that hipBLASLt solution-table dispatch is available. Output/nix/store/xwbnkgp4jg00cisqn2fw19nr5rqf9z9p-strata-hybrid-0.2.1(strataandstrata-device).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-pin/build-sycl/strata. The SYCL port compiles its own copies of the five files in this commit, so this build checks the shared headers this commit inherits from #3551.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, which is the build that compiles this rule. The desktop has an RX 6800 and an RX 6900 XT and serves with the HIP build, which keeps the previous cache lookup. No command log or timing was attached to that report.Failed: none observed.
Not run: a trace showing a pinned row stayed off the PCIe copy. A SYCL process on a device.
Limits: The ownership rule is compiled only into the hybrid build. A default CUDA, HIP, or SYCL build keeps the previous cache lookup.
Changes since the last update (2026-10-27)
main(0.2.6,4b9e05a2); content re-landed verbatim. The dependency note above now reads: this branch is the rebased #3551 branch (b32dee9c) plus one commit — the diff belonging to this pull request isb32dee9c..86c072bb. The10fdcb31/604b2cf3hashes in the original text are the pre-rebase lineage.nixos, pin3032afd8) serves daily on both machines: the laptop runs the hybrid build, which compiles this ownership rule; the desktop runs HIP-only, keeping the previous cache lookup.Changes since the last update (2026-10-30)
v0.2.8(870aedd9). This branch is the rebased #3551 branch (5fa28548) plus one commit - the diff owned by this pull request is5fa28548..9c09a1d2, content-identical to10fdcb31..604b2cf3(161 lines in five files). New tip9c09a1d2.Changes since the last update (2026-11-07)
v0.2.12(123bad4a). This branch is the rebased #3551 branch (1b97058c) plus one commit - the diff owned by this pull request is1b97058c..3fb0726c, content-identical to10fdcb31..604b2cf3and range-diff-equal to the pre-glob-fix restackc201b3bb..3502c77d(167 insertions, 2 deletions, five files). New tip3fb0726c.nixos@c3e4cdc4) passes the owner gates; the CUDA+HIP hybrid flavor build - the build that compiles this ownership rule - and the HIP-only build are green with installCheck. metal-link and title jobs are green on the new head; the PR is mergeable against currentmain.Branch commits were re-signed (GPG ed25519) on 2026-11-07; trees are unchanged from the validated work. The pre-rebase tip
9c09a1d2stays fetchable as an ancestor of the train tagpin-f6f00908.Dependencies: #3551 — this branch is that branch plus its one commit; the diff owned by this pull request is
1b97058c..3fb0726c.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.