Repository navigation
[Engine] inkling2: AMD ROCm/HIP support for strata-ink2, strata-ink2ref, and setup - #16
Merged
baptisterajaut merged 3 commits intoNov 22, 2026
Conversation
Author
|
Moved directly to upstream: Niko1221#6561 |
Author
|
Reopened against feat/inkling2 so the diff stays scoped to the 3 AMD ROCm/HIP commits; closed Niko1221#6561 to avoid duplicating Niko1221#6520. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
strata-ink2,strata-ink2ref, andinstall_inkling2currently target NVIDIA CUDA only. This PR ports both binaries and the Linux setup build path to AMD ROCm/HIP wave32 RDNA GPUs (gfx10/gfx11/gfx12) without changing CUDA code paths.On an AMD Ryzen AI MAX+ 395 (Radeon 8060S,
gfx1151, ROCm 7.14),strata-ink2matchesstrata-ink2refat mean KL4.105e-12(top-1100.00%), runs 128K FP16 KV + DSpark--spec 1all-resident in23.10 GiBVRAM with128/128exact greedy token match against--spec 0, and passes end-to-end serving for chat, vision, tool calls,/v1/responses,/v1/messages, and conversation cache reuse.Related discussion
Niko1221#6520 (and Niko1221#6442).
Approach
engine/include/strata/hip_compat/): addcudaStreamPerThread,cudaStreamCaptureModeRelaxed,cudaErrorUnknown,cudaDeviceGetPCIBusId,cudaMemcpyToSymbolAsync,__HIP_STREAM_PER_THREADsymbol address handling (&symbolfor_sptAPIs),CUBLAS_PEDANTIC_MATH->HIPBLAS_DEFAULT_MATH,cublasSgemmin the hipBLAS 0.54 branch, and system-scope__ldcv.engine/src/inkling2/ink2_wmma_hip.cuh): drop-in16x16x16FP16->FP32wmmalayer using__builtin_amdgcn_wmma_f32_16x16x16_f16_w32ongfx11,..._gfx12ongfx12, and a wave32__shflfallback on non-WMMA wave32 cards.kb_moe_gemm_tc,kb_moe_gemm_tc_gg, andkb_attn_tcstay untouched.engine/src/inkling2/ink2_engine.cu,engine/cmake/strata_gpu_engine.cmake): enablestrata-ink2andstrata-ink2refunderSTRATA_ENABLE_CUDA OR STRATA_ENABLE_HIPwith-fgpu-default-stream=per-threadon HIP, implementVmm/VRangedirectly via HIP VMM (hipMem*, minimum2 MiBgranularity rounding), precheckFA_SMEMagainstcudaDevAttrMaxSharedMemoryPerBlockOptinon HIP, and defaultc_q8wto0on HIP. Static preprocessing projection of#if !defined(STRATA_USE_HIP)onink2_engine.cuis byte-identical to2daf740d.terminal/setup.py,terminal/strata_control/ink2_family.py,terminal/tests/terminal/test_inkling2_setup.py,terminal/tests/terminal/test_gh_0217_hipflags.py): offer Inkling-2-Mini on Linux AMD wave32 RDNA cards (INK2_HIP_ARCHS), buildstrata-ink2with ROCm/HIP CMake flags intobuild-ink2-hip, writebackend: "hip"to the run config, cover HIP build, stamp reuse, and arch refusal intest_inkling2_setup.py, and updatetest_gh_0217_hipflags.pyfor the thirdCMAKE_HIP_FLAGScall site insetup.py.Validation
Environment: Linux x86_64, AMD Ryzen AI MAX+ 395 / Radeon 8060S (
gfx1151), ROCm 7.14 (AMD Clang 23.0.0), officialthinkingmachines/Inkling-2-Minicheckpoint ated40e7da625f594fc9c4990f5f66be24873c22d7(SHA-256 verified), plus GitHub Actions CI on this PR.Passed:
Backend compile checks(onbc4a9373):CUDA 12.9,CUDA 13.0,HIP ROCm 7.2,SYCL oneAPI 2026.1, andMetal strataall passed;ChecksCPU CMake (Linux, Windows MSVC), host builds (Linux, macOS, Windows), andConfig snapshot(ubuntu-24.04, windows-2022) all passed.gfx1151build:cmake -S engine -B build-ink2-hip -G Ninja -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DCMAKE_HIP_ARCHITECTURES=gfx1151andcmake --build build-ink2-hip --target strata-ink2ref strata-ink2(strata-ink21.7 MB,strata-ink2ref136 KB).gfx1151hardware probes:ink2_wmma_hip.cuh(col_majormax err2.68e-7,row_major+kb_attn_tcprobe max err4.29e-6), per-thread stream symbol copy + graph capture (exact), HIP VMM (raw_gran=4096, rounded to2 MiB, pass).strata-ink2refvsstrata-ink2(--kv f32 --chunk 0 --graph 1): 28 prompt positions mean KL4.105e-12, max KL4.574e-11, top-1100.00%, 8/8 greedy tokens exact.--vram-reserve-mib 4096 --kv-grow 1 --tc 1 --chunk 256):--graph 0vs--graph 1bit-identical across5,601,624logits (max_abs_diff=0);--cpu-threads 8(AVX-512 + HIP doorbell +__ldcv)max_abs=0, top-1100.00%.--max-context 131072 --kv f16 --tc 1 --chunk 1024 --spec 1): loads in9.7 s(23.10 GiBVRAM),--spec 1matches--spec 0on128/128greedy tokens (32.2->37.4 tok/son high-acceptance sample, up to50.6 tok/sunderserve.server).serve.server --engine strata: verified/v1/models, streaming/v1/chat/completions(reasoning_content+content), tool calls, PNG vision (2.02 sincluding lazy ViT load),/v1/responses(1.35 s),/v1/messages(2.12 s), and 10.5K-token prompt conversation-cache reuse (19.36 scold at~604 tok/sprefill ->2.07 swarm).ddc6038e:test_gh_0217_hipflags.py(2/2),test_inkling2_setup.py(19/19),test_setup_amd.py(53/53),test_inkling_images.py(7/7),test_inkling_frontend.py(11/11).Failed:
v0.2.18/2daf740d(unrelated to this PR):serve(6 tests intest_mcp_image_default.pyandtest_stop_closed_pipe.py),terminal/tools(3hy4-flashtests plus 2test_setup_model_pins.pyassertions onink2_family.py).tests/terminal/test_gh_0217_hipflags.pyinitially failedlen(found) == 2onbc4a9373becauseink2_buildadded the third-isystem {root}/includeHIP build insetup.py; fixed inddc6038e.Not run:
ink2_engine.cuCUDA projection verified byte-identical statically).gfx1100,gfx1201, orgfx1030(ink2_wmma_hip.cuhgfx11,gfx12, and wave32 fallback paths passed a local C++20 wave unit test underclang++ -Wall -Wextra -Werror; real GPU tests ran ongfx1151only).ink2_offered).Limits
setup.pyskipsnvidia-smidesktop VRAM probing (display = False,used = 0.0) on HIP; on small-VRAM Linux AMD desktop cards this can overestimate free VRAM for offload pools unless--vram-reserve-mibis passed.gfx906) are excluded.