Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
420d26c
Vulkan patch for 8bit,16bit storage and 8 Bit arithmetic
yunusberndt Aug 28, 2025
c4004c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 28, 2025
3471ca5
Better checks if vulkan SDK already exists
yunusberndt Aug 28, 2025
954879c
style(black): reformat ti_build/vulkan.py
yunusberndt Aug 29, 2025
be8c7b3
style(pre-commit): match pinned Black formatting
yunusberndt Aug 29, 2025
b7ee168
fix: resolve Vulkan build and compatibility issues for AMD GPUs
yunusberndt Aug 31, 2025
6de05c0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2025
c0f15db
Enhance Vulkan support for AMD GPUs by refining 16-bit storage capabi…
yunusberndt Sep 8, 2025
d313084
reverted gitignore to upstream standard
yunusberndt Sep 8, 2025
6fbb35b
Merge branch 'Vulkan-patch-for-AMD' of https://github.com/yunusberndt…
yunusberndt Sep 8, 2025
19f2341
Refine Vulkan device creation and update build configuration
yunusberndt Sep 8, 2025
5f16600
Fix formatting issues: black, clang-format, trailing whitespace, and …
yunusberndt Sep 8, 2025
89ec379
Fix pre-commit formatting issues: Black 25.1.0 and clang-format
yunusberndt Sep 8, 2025
c2c8e30
Fix Vulkan 1.1 version check for AMD 8-bit/16-bit support
yunusberndt Sep 8, 2025
f2a0879
Add debug output for AMD GPU capability detection
yunusberndt Sep 8, 2025
b4eeb77
Add detailed debug output for feature detection values
yunusberndt Sep 8, 2025
48dd4f5
Fix debug output formatting for shaderInt8/shaderFloat16 values
yunusberndt Sep 9, 2025
0786496
Add debug output to check if VK_KHR_SHADER_FLOAT16_INT8 extension is …
yunusberndt Sep 9, 2025
276790c
Add debug output to check if VK_KHR_SHADER_FLOAT16_INT8 extension is …
yunusberndt Sep 9, 2025
c77a3fe
Add comprehensive debug output for AMD GPU extension detection and de…
yunusberndt Sep 9, 2025
5abcc6f
Add debug output for Vulkan instance creation and API version fallback
yunusberndt Sep 9, 2025
03dd5ca
Fix Vulkan API version fallback: try 1.1 before 1.0 for AMD GPU compa…
yunusberndt Sep 9, 2025
3f9f23c
Add debug output to check VK_KHR_SHADER_FLOAT16_INT8 at both instance…
yunusberndt Sep 9, 2025
4babaee
Remove debug statements from vulkan_device_creator.cpp
yunusberndt Sep 9, 2025
5674276
changelog messages
yunusberndt Sep 9, 2025
2424598
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/scripts/ti_build/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ def build_wheel(python: Command, pip: Command) -> None:
proj_tags = []
extra = []

# Explicitly set flags to match official Windows release build EXACTLY
# This matches .github/workflows/release.yml lines 238-244
cmake_args["TI_WITH_OPENGL"] = True
cmake_args["TI_WITH_VULKAN"] = True
cmake_args["TI_WITH_DX11"] = True
cmake_args["TI_WITH_DX12"] = True
cmake_args["TI_BUILD_TESTS"] = True
cmake_args["TI_WITH_C_API"] = True

# NOTE: Official release does NOT include:
# - TI_WITH_GGUI=ON (this adds IMM32.dll dependency)
# - TI_WITH_LTO=ON (this affects linker behavior)
# - TI_GENERATE_PDB=ON (this affects DLL structure)

cmake_args.writeback()
if misc.options.tag_local:
wheel_tag = f"+{misc.options.tag_local}"
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/scripts/ti_build/vulkan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@
@banner("Setup Vulkan 1.3.296.0")
def setup_vulkan():
u = platform.uname()

# Check if Vulkan SDK is already available
if u.system == "Windows":
# Check common Vulkan SDK installation paths
possible_paths = [
"C:\\VulkanSDK",
"C:\\Program Files\\VulkanSDK",
"C:\\Program Files (x86)\\VulkanSDK",
]

for path in possible_paths:
if os.path.exists(path):
# Find the latest version
versions = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]
if versions:
latest_version = sorted(versions)[-1]
vulkan_sdk_path = os.path.join(path, latest_version)
os.environ["VULKAN_SDK"] = vulkan_sdk_path
os.environ["VK_SDK_PATH"] = vulkan_sdk_path
os.environ["VK_LAYER_PATH"] = os.path.join(vulkan_sdk_path, "Bin")
path_prepend("PATH", os.path.join(vulkan_sdk_path, "Bin"))
print(f"Using existing Vulkan SDK at: {vulkan_sdk_path}")
return

if u.system == "Linux":
url = "https://sdk.lunarg.com/sdk/download/1.3.296.0/linux/vulkansdk-linux-x86_64-1.3.296.0.tar.xz"
prefix = get_cache_home() / "vulkan-1.3.296.0"
Expand Down
49 changes: 49 additions & 0 deletions BUILD_CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Taichi Build Configuration

## **Environment Setup:**
```powershell
# Set LLVM_DIR to official Taichi LLVM (CRITICAL)
$env:LLVM_DIR = "$env:LOCALAPPDATA\ti-build-cache\llvm15"

# Set CMake arguments to match official Windows release build
$env:TAICHI_CMAKE_ARGS = "-DTI_WITH_OPENGL=ON -DTI_WITH_VULKAN=ON -DTI_WITH_DX11=ON -DTI_WITH_DX12=ON -DTI_BUILD_TESTS=ON -DTI_WITH_C_API=ON"
```

## **Build Command:**
```powershell
# Use older linker version (14.34) to match official Taichi
cmd /c 'call "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.34 && python build.py wheel --tag-local v174.granular16bit --python native --permissive'
```

## **Required Visual Studio Components:**
- **Desktop development with C++** workload
- **MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) - 14.34** (non-Spectre-mitigated)
- **C++ Clang Compiler for Windows**
- **C++ 2022 Redistributable MSM**
- **MS Build support for LLVM (clang-cl) toolset**

## **Critical CMake Flags (matching official release):**
- **`TI_WITH_OPENGL=ON`** - OpenGL backend
- **`TI_WITH_VULKAN=ON`** - Vulkan backend
- **`TI_WITH_DX11=ON`** - DirectX 11 backend
- **`TI_WITH_DX12=ON`** - DirectX 12 backend
- **`TI_BUILD_TESTS=ON`** - Build test suite
- **`TI_WITH_C_API=ON`** - C API support

## **Excluded Flags (not in official release):**
- **`TI_WITH_GGUI=ON`** - Adds IMM32.dll dependency (not in official)
- **`TI_WITH_LTO=ON`** - Link Time Code Generation (not in official)
- **`TI_GENERATE_PDB=ON`** - Debug symbols (not in official)

## **Build System Configuration:**
- **Visual Studio 2022 Build Tools** with MSVC 14.34.31948.0
- **Python 3.12.4** with native build
- **Official Taichi LLVM** from `%LOCALAPPDATA%\ti-build-cache\llvm15`
- **MSBuild** as the build system

## **Key Dependencies:**
- **`d3d11.dll`** - DirectX 11 runtime
- **`D3DCOMPILER_47.dll`** - DirectX shader compiler
- **`msvcp140.dll`** - MSVC C++ runtime
- **`vcruntime140.dll`** - MSVC runtime
- **`vcruntime140_1.dll`** - MSVC runtime extension
3 changes: 2 additions & 1 deletion cmake/TaichiCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ add_library(${CORE_LIBRARY_NAME} OBJECT ${TAICHI_CORE_SOURCE})

target_include_directories(${CORE_LIBRARY_NAME} PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/include)
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/SPIRV-Tools/include)
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/PicoSHA2)
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/eigen)
target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/FP16/include)

target_include_directories(${CORE_LIBRARY_NAME} PRIVATE external/SPIRV-Tools/include)

target_link_libraries(${CORE_LIBRARY_NAME} PUBLIC ti_device_api)

if(TI_WITH_LLVM)
Expand Down
30 changes: 30 additions & 0 deletions python/taichi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Highlights:
- Fix Vulkan API version fallback: try 1.1 before 1.0 for AMD GPU compatibility (by **Yunus Berndt**)
- Refine Vulkan device creation and update build configuration (by **Yunus Berndt**)
- Better checks if vulkan SDK already exists (by **Yunus Berndt**)
- Vulkan patch for 8bit,16bit storage and 8 Bit arithmetic (by **Yunus Berndt**)

Full changelog:
- Add debug output to check VK_KHR_SHADER_FLOAT16_INT8 at both instance and device levels (by **Yunus Berndt**)
- Fix Vulkan API version fallback: try 1.1 before 1.0 for AMD GPU compatibility (by **Yunus Berndt**)
- Add debug output for Vulkan instance creation and API version fallback (by **Yunus Berndt**)
- Add comprehensive debug output for AMD GPU extension detection and device selection (by **Yunus Berndt**)
- Add debug output to check if VK_KHR_SHADER_FLOAT16_INT8 extension is detected in device extensions (by **Yunus Berndt**)
- Add debug output to check if VK_KHR_SHADER_FLOAT16_INT8 extension is actually enabled (by **Yunus Berndt**)
- Fix debug output formatting for shaderInt8/shaderFloat16 values (by **Yunus Berndt**)
- Add detailed debug output for feature detection values (by **Yunus Berndt**)
- Add debug output for AMD GPU capability detection (by **Yunus Berndt**)
- Fix Vulkan 1.1 version check for AMD 8-bit/16-bit support (by **Yunus Berndt**)
- Fix pre-commit formatting issues: Black 25.1.0 and clang-format (by **Yunus Berndt**)
- Fix formatting issues: black, clang-format, trailing whitespace, and end-of-file fixes (by **Yunus Berndt**)
- Refine Vulkan device creation and update build configuration (by **Yunus Berndt**)
- Merge branch 'Vulkan-patch-for-AMD' of https://github.com/yunusberndt/taichi into Vulkan-patch-for-AMD (by **Yunus Berndt**)
- reverted gitignore to upstream standard (by **Yunus Berndt**)
- Enhance Vulkan support for AMD GPUs by refining 16-bit storage capabilities (by **Yunus Berndt**)
- [pre-commit.ci] auto fixes from pre-commit.com hooks (by **pre-commit-ci[bot]**)
- fix: resolve Vulkan build and compatibility issues for AMD GPUs (by **Yunus Berndt**)
- style(pre-commit): match pinned Black formatting (by **Yunus Berndt**)
- style(black): reformat ti_build/vulkan.py (by **Yunus Berndt**)
- Better checks if vulkan SDK already exists (by **Yunus Berndt**)
- [pre-commit.ci] auto fixes from pre-commit.com hooks (by **pre-commit-ci[bot]**)
- Vulkan patch for 8bit,16bit storage and 8 Bit arithmetic (by **Yunus Berndt**)
59 changes: 55 additions & 4 deletions taichi/codegen/spirv/spirv_ir_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,51 @@ void IRBuilder::init_header() {
.add("SPV_KHR_storage_buffer_storage_class")
.commit(&header_);

// === BEGIN: 8/16-bit storage support (emit only when device supports it) ===
if (caps_->get(cap::spirv_has_8bit_storage)) {
// ib_.begin(spv::OpExtension).add("SPV_KHR_8bit_storage").commit(&header_);
// Pick only the storage caps your device has; these two are the common
// ones:
ib_.begin(spv::OpCapability)
.add(spv::CapabilityStorageBuffer8BitAccess)
.commit(&header_);
ib_.begin(spv::OpCapability)
.add(spv::CapabilityUniformAndStorageBuffer8BitAccess)
.commit(&header_);
ib_.begin(spv::OpCapability)
.add(spv::CapabilityStoragePushConstant8)
.commit(&header_);
}

if (caps_->get(cap::spirv_has_16bit_storage)) {
ib_.begin(spv::OpExtension).add("SPV_KHR_16bit_storage").commit(&header_);

// Only enable specific 16-bit storage capabilities that are supported
// This fixes AMD GPU compatibility issues where not all 16-bit features are
// supported
if (caps_->get(cap::spirv_has_storage_buffer_16bit_access)) {
ib_.begin(spv::OpCapability)
.add(spv::CapabilityStorageBuffer16BitAccess)
.commit(&header_);
}
if (caps_->get(cap::spirv_has_uniform_and_storage_buffer_16bit_access)) {
ib_.begin(spv::OpCapability)
.add(spv::CapabilityUniformAndStorageBuffer16BitAccess)
.commit(&header_);
}
if (caps_->get(cap::spirv_has_storage_push_constant_16)) {
ib_.begin(spv::OpCapability)
.add(spv::CapabilityStoragePushConstant16)
.commit(&header_);
}
if (caps_->get(cap::spirv_has_storage_input_output_16)) {
ib_.begin(spv::OpCapability)
.add(spv::CapabilityStorageInputOutput16)
.commit(&header_);
}
}
// === END: 8/16-bit storage support ===

if (caps_->get(cap::spirv_has_no_integer_wrap_decoration)) {
ib_.begin(spv::OpExtension)
.add("SPV_KHR_no_integer_wrap_decoration")
Expand Down Expand Up @@ -153,11 +198,15 @@ void IRBuilder::init_pre_defs() {
}

t_bool_ = declare_primitive_type(get_data_type<bool>());
if (caps_->get(cap::spirv_has_int8)) {
// 8-bit integers: declare if arithmetic *or* storage is available
if (caps_->get(cap::spirv_has_int8) ||
caps_->get(cap::spirv_has_8bit_storage)) {
t_int8_ = declare_primitive_type(get_data_type<int8>());
t_uint8_ = declare_primitive_type(get_data_type<uint8>());
}
if (caps_->get(cap::spirv_has_int16)) {
// 16-bit integers: declare if arithmetic *or* storage is available
if (caps_->get(cap::spirv_has_int16) ||
caps_->get(cap::spirv_has_16bit_storage)) {
t_int16_ = declare_primitive_type(get_data_type<int16>());
t_uint16_ = declare_primitive_type(get_data_type<uint16>());
}
Expand Down Expand Up @@ -313,11 +362,13 @@ SType IRBuilder::get_primitive_type(const DataType &dt) const {
TI_ERROR("Type {} not supported.", dt->to_string());
return t_int64_;
} else if (dt->is_primitive(PrimitiveTypeID::u8)) {
if (!caps_->get(cap::spirv_has_int8))
if (!caps_->get(cap::spirv_has_int8) &&
!caps_->get(cap::spirv_has_8bit_storage))
TI_ERROR("Type {} not supported.", dt->to_string());
return t_uint8_;
} else if (dt->is_primitive(PrimitiveTypeID::u16)) {
if (!caps_->get(cap::spirv_has_int16))
if (!caps_->get(cap::spirv_has_int16) &&
!caps_->get(cap::spirv_has_16bit_storage))
TI_ERROR("Type {} not supported.", dt->to_string());
return t_uint16_;
} else if (dt->is_primitive(PrimitiveTypeID::u32)) {
Expand Down
7 changes: 7 additions & 0 deletions taichi/inc/rhi_constants.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ PER_DEVICE_CAPABILITY(spirv_has_int16)
PER_DEVICE_CAPABILITY(spirv_has_int64)
PER_DEVICE_CAPABILITY(spirv_has_float16)
PER_DEVICE_CAPABILITY(spirv_has_float64)
PER_DEVICE_CAPABILITY(spirv_has_8bit_storage)
PER_DEVICE_CAPABILITY(spirv_has_16bit_storage)
// Granular 16-bit storage capabilities for AMD GPU compatibility
PER_DEVICE_CAPABILITY(spirv_has_storage_buffer_16bit_access)
PER_DEVICE_CAPABILITY(spirv_has_uniform_and_storage_buffer_16bit_access)
PER_DEVICE_CAPABILITY(spirv_has_storage_push_constant_16)
PER_DEVICE_CAPABILITY(spirv_has_storage_input_output_16)
PER_DEVICE_CAPABILITY(spirv_has_atomic_int64)
PER_DEVICE_CAPABILITY(spirv_has_atomic_float16) // load, store, exchange
PER_DEVICE_CAPABILITY(spirv_has_atomic_float16_add)
Expand Down
54 changes: 45 additions & 9 deletions taichi/python/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,57 @@
#include "taichi/python/export.h"
#include "taichi/common/interface.h"
#include "taichi/util/io.h"
#include <cstdio>
#include <cstdlib>

namespace taichi {

static void log_boot(const char *msg) {
const char *temp = std::getenv("TEMP");
std::string dir = temp ? std::string(temp) : std::string(".");
std::string path = join_path(dir, "taichi_pyd_boot.log");
if (FILE *f = std::fopen(path.c_str(), "a")) {
std::fprintf(f, "%s\n", msg);
std::fclose(f);
}
}

PYBIND11_MODULE(taichi_python, m) {
m.doc() = "taichi_python";
try {
log_boot("PYD: enter taichi_python module init");
m.doc() = "taichi_python";

for (auto &kv : InterfaceHolder::get_instance()->methods) {
kv.second(&m);
}
log_boot("PYD: before InterfaceHolder methods");
for (auto &kv : InterfaceHolder::get_instance()->methods) {
kv.second(&m);
}
log_boot("PYD: after InterfaceHolder methods");

log_boot("PYD: before export_lang");
export_lang(m);
log_boot("PYD: after export_lang");

export_lang(m);
export_math(m);
export_misc(m);
export_visual(m);
export_ggui(m);
export_math(m);
log_boot("PYD: after export_math");

export_misc(m);
log_boot("PYD: after export_misc");

export_visual(m);
log_boot("PYD: after export_visual");

export_ggui(m);
log_boot("PYD: after export_ggui");

log_boot("PYD: module init completed");
} catch (const std::exception &e) {
log_boot("PYD: exception during module init");
log_boot(e.what());
throw;
} catch (...) {
log_boot("PYD: unknown exception during module init");
throw;
}
}

} // namespace taichi
Loading