Fix core dump issue for binary built for old GPUs (cm<89) - #231
Open
jasonchen31 wants to merge 2 commits into
Open
Fix core dump issue for binary built for old GPUs (cm<89)#231jasonchen31 wants to merge 2 commits into
jasonchen31 wants to merge 2 commits into
Conversation
jasonchen31
marked this pull request as draft
August 13, 2026 20:56
Contributor
Author
|
I compiled again while fixing the SensVoice ASR Webui missing issue, Sage Attention was somehow included and the build failed again. Still working on it. |
Contributor
Author
|
It should be fixed this time. clean build success, and GPU inference correctly. |
jasonchen31
marked this pull request as ready for review
August 13, 2026 22:55
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.
Fixing #227
PR: Gate SageAttention2 for pre-sm_89 CUDA builds and expose
--cuda-archin the Linux build scriptProblem
Two bugs broke CUDA builds targeting old GPUs (compute capability 6.1, e.g. Pascal GTX 10xx):
SageAttention2 is unconditionally compiled and can't build for old GPUs.
The vendored ggml CUDA backend globs
sage-attn2.cuinto every build. Itsheaders include
<cuda/barrier>/<cuda/pipeline>unconditionally, whichCUDA hard-errors on sub-sm_70 targets:
scripts/build_linux.sh --backend cudanever sets the target GPU architecture.It silently inherits
CMAKE_CUDA_ARCHITECTURES=native(the build machine'sGPU). Building on any modern GPU produced a single-arch image with no sm_61
code, and left the Sage gate "ON" (arch >= 89), so kernels with SM89+
instructions were packaged into a binary that core-dumped when run on a 6.1 GPU.
A direct
cmake -S . -B build -DENGINE_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=61worked because it pins the arch (and 61 < 89 disables Sage at compile time).
Changes
external/ggml/src/ggml-cuda/CMakeLists.txt(build gate)Add a fail-closed build-time gate for SageAttention2:
ON, but turnedOFFif anyCMAKE_CUDA_ARCHITECTURESentryparses to
< 89(or is unparseable, e.g.native).OFF,sage-attn2.cuis removed from the source list and aGGML_CUDA_SAGE_ATTN2_ENABLEDcompile definition is not added; amessage(STATUS ...)reportsCUDA SageAttention2 disabled.external/ggml/src/ggml-cuda/sage-attn2.cuh(stub definitions)Because
ggml-cuda.cuunconditionally references the four Sage entry points(
ggml_cuda_sage_attn2,_i8,_supported,_i8_supported), the header now:GGML_CUDA_SAGE_ATTN2_ENABLEDis defined(arch >= 89), and
static inlinestubs when it is not:supported()returnsfalse(op never attached to a graph) and the compute entry points
GGML_ABORT.Since
ggml-cuda.cualready includes this header, no dispatcher edits areneeded.
scripts/build_linux.sh(target architecture control)--cuda-arch <spec>flag that forwards-DCMAKE_CUDA_ARCHITECTURES=<spec>(with
-UCMAKE_CUDA_ARCHITECTURESto avoid the sticky cache entry, mirroringthe existing HIP
--gpu-targetshandling).<auto: machine-native ...>when unset).Docs
docs/build/linux.md: document--cuda-arch, including theold-GPU example and the equivalence with the working direct CMake invocation.
Noted that
ENGINE_ENABLE_NATIVE_CPU=OFFis not required, sinceGGML_NATIVEaffects CUDA arch only as a fallback whenCMAKE_CUDA_ARCHITECTURESis undefined.Why this is safe for correctness
an attention path:
src/community_models/minimax_h3/dit_denoiser.cppalreadyfalls back to
ggml_flash_attn_extwhen the Sage op is unsupported.(
BEST_FATTN_KERNEL_TILEinexternal/ggml/src/ggml-cuda/fattn.cu), which iscompiled into the sm_61 build.
supported()guard already returns
falsefor cc < 890, so a 6.1 GPU would have used flashattention regardless. The real fix is compiling the whole backend for sm_61.
Usage
# Old GPU (compute capability 6.1) ./scripts/build_linux.sh --backend cuda --cuda-arch 61 --target audiocpp_cli --target audiocpp_serverValidation status
git difffor CMakeLists.txt is a pure additive change (22 insertions /0 deletions); CRLF line endings of the vendored file are preserved.
cmake -P-equivalent simulation that the gate resolvescorrectly:
61/52/mixed-low/native-> Sage OFF;89-real/120a-real-> ON.