port: Windows native ROCm build for AMD Strix Halo (gfx1151)#512
Draft
paperlinguist wants to merge 3 commits into
Draft
port: Windows native ROCm build for AMD Strix Halo (gfx1151)#512paperlinguist wants to merge 3 commits into
paperlinguist wants to merge 3 commits into
Conversation
Add a complete Windows build target (strix-halo-windows) and POSIX
compatibility layer that allows DS4 to compile and run on Windows
using the ROCm 7.1 HIP SDK targeting AMD Strix Halo (Radeon 8060S,
gfx1151, RDNA4).
Tested on: AMD Ryzen AI Max / Strix Halo, 96 GB unified RAM, Windows 11,
ROCm 7.1. Full 80.76 GiB model loads in ~50s; inference runs at
~15-18 t/s prefill / ~15-16 t/s generation with --ctx 229376 (224k tokens).
New files: compat/win32/ POSIX shim layer, WINDOWS_ROCM.md documentation.
Key changes:
ds4.c: use _fstat64 on Windows (MSVC off_t is 32-bit, crashes on 86 GB file)
ds4_server.c: include sys/socket.h on Windows (was ifdef guarded out,
so WSAStartup was never called; socket() returned WSANOTINITIALISED)
rocm/ds4_rocm_runtime.cuh: cast pread offset to int64_t not off_t (MSVC
off_t is 32-bit, silently truncated offsets past 4 GB to negatives,
causing EIO on every read beyond 4 GB boundary)
rocm/ds4_rocm_runtime.cuh: add +12 GiB Q8 cache reserve on _WIN32 to
account for ROCm Windows driver overhead not present on Linux
compat/win32/unistd.h: thread-safe pread via ReOpenFile+OVERLAPPED,
close() with socket fallback via GetProcAddress
compat/win32/sys/socket.h: lazy WSAStartup via ds4_wsa_ensure_init()
Known issues: --ssd-streaming crashes (mmap DMA), isLargeBar=0.
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.
Summary
Native Windows build target for DS4 on AMD Strix Halo (Radeon 8060S, gfx1151,
RDNA4) using the ROCm 7.1 HIP SDK.
Tested on: AMD Ryzen AI Max / Strix Halo, 128GB unified RAM, Windows 11, ROCm 7.1
Performance: ~18 t/s prefill / ~16 t/s generation at
--ctx 229376(224k tokens)Model: DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf (80.76 GiB)
What this PR adds
New:
compat/win32/— complete POSIX shim layerMaps POSIX APIs to Win32 equivalents so all existing source files compile without
modification (except the targeted fixes below):
unistd.hpread()(thread-safe viaReOpenFile+OVERLAPPED),close()(CRT fd + Winsock socket via GetProcAddress),clock_gettime,usleep,PATH_MAX,off_t=__int64sys/socket.hWSAStartupon firstsocket(),poll()viaWSAPollsys/file.hflock,fcntlno-op,dprintf,sigactionstub,winsize/TIOCGWINSZsys/time.hgettimeofdayviaGetSystemTimeAsFileTimesys/mman.h/cmmap/munmap/msync/mlockviaCreateFileMapping/MapViewOfFile(64-bit)dirent.hopendir/readdir/closedirviaFindFirstFile/FindNextFilestrings.hstrcasecmp/strncasecmpmacros to_stricmp/_strnicmpNew:
Makefilestrix-halo-windows targetAll compilation goes through
hipcctargetingx86_64-pc-windows-msvcto maintaina single MSVC ABI throughout (mixing MinGW-compiled objects with MSVC-ABI ROCm DLLs
causes linker failures). Offload arch:
gfx1151.Bug fixes required for Windows
ds4.c— 64-bit stat for files > 4 GBMSVC
off_tis 32-bit.fstat()on an 86 GB file returnsEOVERFLOW. Fixed byusing
_fstat64/struct _stat64on_WIN32.ds4_server.c— WSAStartup never calledThe original code guarded out
#include <sys/socket.h>on Windows, so the compatheader (which lazily calls
WSAStartup) was never included. Everysocket()callreturned
WSANOTINITIALISED (10093), surfacing as errno 132 / "value too large".Symptom:
ds4-server: failed to listen on 127.0.0.1:8000: value too largerocm/ds4_rocm_runtime.cuh— 64-bit pread offsetcuda_pread_fullcast the file offset to(off_t)which is 32-bit on MSVC.Offsets beyond 4 GB were silently truncated to negative values, causing every
tensor read past the 4 GB boundary to fail with EIO.
Fix: Cast to
(int64_t)instead of(off_t).rocm/ds4_rocm_runtime.cuh— Q8 cache reserve for WindowsThe ROCm Windows driver consumes ~12 GiB of overhead (staging buffers, HipBLAS
workspaces) not present on Linux. The default
5%Q8->F16 cache reserve was toosmall: the cache consumed 10+ GiB before inference tensors could be allocated.
Fix: Add
+12 GiBto the reserve on_WIN32, leaving ~15 GiB free for theKV cache.
compat/win32/unistd.h— thread-safe preadThe ROCm streaming engine uses 18 concurrent worker threads all calling
pread()on the same
g_model_fd. ConcurrentReadFileon a synchronous Windows HANDLEraces on the shared internal file pointer. Fixed by using
ReOpenFileto obtain aprivate
FILE_FLAG_OVERLAPPEDhandle per call, withGetOverlappedResultforasync completion.
Documentation
WINDOWS_ROCM.mdcovers full prerequisites (AMD HIP SDK, MSYS2, rocWMMA headers,import libraries, runtime PATH), build steps, every source change with root cause
and fix, and known remaining issues.
Known issues / not in scope
--ssd-streamingcrashes at ~8 GiB:cudaMemcpy(mmap_ptr, HostToDevice)fallback fails on Windows ROCm for demand-paged file memory. Not needed when the full model fits in the 107.87 GiB pool.isLargeBar: 0: Resizable BAR not enabled; enabling it may increase max context beyond 232k tokens.ds4-agent: usesfork()which is not ported; onlyds4,ds4-server,ds4-bench, andds4-evalare built.