Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Updated vulkan.sh/.bat to check and use recent toolchain
Davide Eynard017cdeb4b721
diff --git a/llamafile/vulkan.bat b/llamafile/vulkan.batindex 44f622c2..4f2a1f5d 100644--- a/llamafile/vulkan.bat+++ b/llamafile/vulkan.bat@@ -93,6 +93,21 @@ if not exist "%VULKAN_SDK%\Lib\vulkan-1.lib" (exit /b 1)+:: -------- record the shader toolchain --------+:: The SDK's glslc and headers decide which shader extensions the DLL gets+:: (see the feature probe below), so the build log must show which were used.+:: glslc --version prints shaderc on line 1 and glslang on line 3.+set "GLSLC_VERSION="+set /a _GLSLC_LINE=0+for /f "usebackq delims=" %%v in (`"%GLSLC%" --version 2^>nul`) do (+ set /a _GLSLC_LINE+=1+ if !_GLSLC_LINE! equ 1 set "GLSLC_VERSION=%%v"+ if !_GLSLC_LINE! equ 3 set "GLSLC_VERSION=!GLSLC_VERSION! %%v"+)+set "VK_HEADER_FILE=%VULKAN_SDK%\Include\vulkan\vulkan_core.h"+set "VK_HEADER_VERSION="+for /f "tokens=3" %%v in ('findstr /r /c:"^#define VK_HEADER_VERSION " "%VK_HEADER_FILE%" 2^>nul') do set "VK_HEADER_VERSION=%%v"+:: -------- find Visual Studio / Build Tools --------where cl >nul 2>&1if errorlevel 1 (@@ -148,17 +163,23 @@ pushd "%LLAMA_CPP_DIR%\ggml" 2>nul && (:: gate which shader variants vulkan-shaders-gen emits and which pipelines:: ggml-vulkan.cpp creates, so they must reflect the actual glslc on this:: machine. Omitting them silently drops coopmat/coopmat2/decode-vector/-:: integer-dot/bf16 support from the DLL. Keep this list in sync with+:: integer-dot/bf16/fp4/fp8 support from the DLL. Keep this list in sync with:: upstream's test_shader_extension_support() calls in:: ggml-vulkan/CMakeLists.txt.set "FEATURE_TESTS_DIR=%SHADERS_DIR%\feature-tests"set "GLSLC_DEFINES="+set "SHADER_FEATURES_OK="+set "SHADER_FEATURES_MISSING="echo Probing glslc shader extension support...call :probe_glslc coopmat.comp GGML_VULKAN_COOPMAT_GLSLC_SUPPORTcall :probe_glslc coopmat2.comp GGML_VULKAN_COOPMAT2_GLSLC_SUPPORTcall :probe_glslc coopmat2_decode_vector.comp GGML_VULKAN_COOPMAT2_DECODE_VECTOR_GLSLC_SUPPORTcall :probe_glslc integer_dot.comp GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORTcall :probe_glslc bfloat16.comp GGML_VULKAN_BFLOAT16_GLSLC_SUPPORT+call :probe_glslc float_e2m1.comp GGML_VULKAN_FLOAT_E2M1_GLSLC_SUPPORT+call :probe_glslc float_e4m3.comp GGML_VULKAN_FLOAT_E4M3_GLSLC_SUPPORT+if defined SHADER_FEATURES_OK set "SHADER_FEATURES_OK=!SHADER_FEATURES_OK:~1!"+if defined SHADER_FEATURES_MISSING set "SHADER_FEATURES_MISSING=!SHADER_FEATURES_MISSING:~1!"echo.:: The defines bake into vulkan-shaders-gen, the generated header, and every@@ -183,6 +204,9 @@ echo Output: %OUTPUT%echo Build: %BUILD_DIR%echo Jobs: %JOBS%echo Vulkan SDK: %VULKAN_SDK%+echo glslc: %GLSLC%+if defined GLSLC_VERSION echo !GLSLC_VERSION!+if defined VK_HEADER_VERSION (echo Headers: VK_HEADER_VERSION !VK_HEADER_VERSION! from !VK_HEADER_FILE!) else (echo Headers: VK_HEADER_VERSION unknown - could not parse !VK_HEADER_FILE!)echo.:: ========================================================================@@ -360,6 +384,17 @@ echo.echo Successfully built: %OUTPUT%for %%f in ("%OUTPUT%") do echo Size: %%~zf bytesecho.+echo Toolchain:+echo glslc: %GLSLC%+if defined GLSLC_VERSION echo !GLSLC_VERSION!+if defined VK_HEADER_VERSION (echo Vulkan headers: VK_HEADER_VERSION !VK_HEADER_VERSION! from !VK_HEADER_FILE!) else (echo Vulkan headers: VK_HEADER_VERSION unknown - could not parse !VK_HEADER_FILE!)+echo Shader features: !SHADER_FEATURES_OK!+if defined SHADER_FEATURES_MISSING (+ echo MISSING: !SHADER_FEATURES_MISSING!+ echo not supported by this glslc; the corresponding GPU paths are+ echo not in the DLL -- install a newer LunarG Vulkan SDK and set VULKAN_SDK+)+echo.endlocalexit /b 0@@ -369,9 +404,11 @@ exit /b 0:probe_glslc"%GLSLC%" -o NUL -fshader-stage=compute --target-env=vulkan1.3 "%FEATURE_TESTS_DIR%\%~1" >nul 2>&1if errorlevel 1 (+ set "SHADER_FEATURES_MISSING=!SHADER_FEATURES_MISSING! %~n1"echo %~1: not supported by glslc) else (set "GLSLC_DEFINES=!GLSLC_DEFINES! /D%~2"+ set "SHADER_FEATURES_OK=!SHADER_FEATURES_OK! %~n1"echo %~1: supported)exit /b 0diff --git a/llamafile/vulkan.sh b/llamafile/vulkan.shindex aead08cb..eab04142 100755--- a/llamafile/vulkan.sh+++ b/llamafile/vulkan.sh@@ -138,6 +138,16 @@ echo " Build: $BUILD_DIR"echo " Jobs: $JOBS"echo " CXX: $CXX"echo " glslc: $GLSLC"+# Record the shader toolchain. A distro glslc can be years behind the SDK's and+# silently lacks shader extensions (see the feature probe below), and the+# Vulkan headers decide which extension code paths ggml-vulkan.cpp compiles,+# so a build log must show which ones were used.+GLSLC_VERSION=$("$GLSLC" --version 2>/dev/null | sed -n '1p;3p' | tr '\n' ' ' | sed 's/ *$//' || true)+VK_HEADER_FILE=$(echo '#include <vulkan/vulkan_core.h>' | $CXX -E -x c++ $SPIRV_INCLUDE - 2>/dev/null \+ | grep -m1 -o '"[^"]*vulkan_core\.h"' | tr -d '"' || true)+VK_HEADER_VERSION=$(grep -m1 'define VK_HEADER_VERSION ' "${VK_HEADER_FILE:-/dev/null}" 2>/dev/null | awk '{print $3}' || true)+echo " ${GLSLC_VERSION:-version unknown}"+echo " Vulkan headers: VK_HEADER_VERSION ${VK_HEADER_VERSION:-unknown} (${VK_HEADER_FILE:-not found})"echo ""START_TIME=$(date +%s)@@ -152,14 +162,18 @@ START_TIME=$(date +%s)# test_shader_extension_support() calls in ggml-vulkan/CMakeLists.txt.#GLSLC_DEFINES=""+SHADER_FEATURES_OK=""+SHADER_FEATURES_MISSING=""FEATURE_TESTS_DIR="$SHADERS_DIR/feature-tests"probe_glslc_extension() {# $1 = feature test shader, $2 = defineif "$GLSLC" -o /dev/null -fshader-stage=compute --target-env=vulkan1.3 \"$FEATURE_TESTS_DIR/$1" >/dev/null 2>&1; thenGLSLC_DEFINES="$GLSLC_DEFINES -D$2"+ SHADER_FEATURES_OK="$SHADER_FEATURES_OK ${1%.comp}"echo " $1: supported"else+ SHADER_FEATURES_MISSING="$SHADER_FEATURES_MISSING ${1%.comp}"echo " $1: not supported by glslc"fi}@@ -377,3 +391,14 @@ echo "Total time: $((END_TIME - START_TIME)) seconds"echo ""echo "Successfully built: $OUTPUT"ls -lh "$OUTPUT"+echo ""+echo "Toolchain:"+echo " glslc: $GLSLC"+echo " ${GLSLC_VERSION:-version unknown}"+echo " Vulkan headers: VK_HEADER_VERSION ${VK_HEADER_VERSION:-unknown} (${VK_HEADER_FILE:-not found})"+echo " Shader features: ${SHADER_FEATURES_OK# }"+if [ -n "$SHADER_FEATURES_MISSING" ]; then+ echo " MISSING: ${SHADER_FEATURES_MISSING# }"+ echo " (not supported by this glslc; the corresponding GPU paths are"+ echo " not in the module -- build with the LunarG Vulkan SDK, VULKAN_SDK=...)"+fi