M100 fp32 only regen - #79746
Conversation
This commit adapts the PaddlePaddle build to work with the xtrans custom CUDA backend (xtrans_cuda_11.7_ubuntu2004_x86_64_mars) which does not support standard cuDNN or some cuBLAS interfaces. Key changes: - cmake: disable WITH_CUTLASS, add clang-rt builtins link, fix cudnn/cublas detection for xtrans backend - backends/dynload: remove unsupported cuBLAS axpy/scal/copy entries; wrap cudnn.cc body in WITH_CUDNN_FRONTEND guard - backends/gpu: add stub InitDnnHandle/DestroyDnnHandle/DnnVersion when WITH_CUDNN_FRONTEND is not set; fix forwards.h / gpu_decls.h guards - resource_manager: restore full implementation, keep cuDNN calls commented out - fuse_bn_act_pass / fuse_bn_add_act_pass: add stub ApplyImpl + REGISTER_PASS so USE_PASS() links correctly without cuDNN - matmul_kernel.cu: restore with int8_t registration + CudaGemm<int8_t> stub; cuda_gemm_kernel.cu disabled (renamed .md) - softmax.cu / cross_entropy.cu: restored with Eigen/CUDA-only paths, cuDNN paths removed - 70+ kernel files renamed to *.md to skip cuDNN/cuBLAS-dependent operators during build (batch_norm, conv, layer_norm, softmax, etc.) - .gitignore: add xtrans compiler intermediate file patterns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
[XPU] Adaptation for cuDNN
… fixing the logical operator in the XPU header guard in xpudnn.h.
…mmented-out cuFFT-related interfaces.
Introduces a WITH_XPU_CADA build option that lets CINN's existing CUDA codegen/NVRTC/runtime path target Baidu KUNLUN M100 through xtrans, a CUDA/NVRTC/Driver-API compatible toolchain, instead of requiring a real NVIDIA CUDA install. Key changes: - CMakeLists.txt / cmake/cinn.cmake / cmake/cinn/*.cmake: new WITH_XPU_CADA option, xtrans toolchain root/library discovery (XTRANS_ROOT), and isolation of the handful of spots where xtrans's layout differs from a stock NVIDIA CUDA install (no lib64/stubs, 0-byte NVTX stub, cusolver->cusparse link dependency, etc). - paddle/cinn/backends/cuda_util.h, paddle/cinn/runtime/cuda/cuda_util.cc, paddle/phi/backends/dynload/cudnn.h: CINN's cudnn calls are ported to phi's existing dynload/lazy-dlopen wrapper instead of link-time linking libcudnn.so. This avoids pulling xtrans's own libLLVM-15.so (a transitive dependency of xtrans's libcudnn.so) into any process that also links CINN's statically-linked LLVM 12, which otherwise collides at the global llvm::cl::opt registry and aborts at startup (hit in eager_generator). - paddle/cinn/backends/nvrtc/header_generator.cc: skip injecting jitify's JIT-safe stub headers under WITH_XPU_CADA (xtrans already provides a real, self-consistent stdlib via --include-path, and jitify's <limits>/<cmath> stubs conflict with it). - paddle/cinn/backends/nvrtc/nvrtc_util.cc: propagate -DPADDLE_WITH_XPU_CADA into the NVRTC device-code compile itself (previously only visible to host-side C++), so the WITH_XPU_CADA-only code paths injected into runtime headers actually activate. - paddle/cinn/runtime/cuda/float16_xpu_cada.h (new), paddle/cinn/runtime/cuda/bfloat16.h, paddle/cinn/runtime/cuda/cinn_cuda_runtime_source.cuh, paddle/cinn/backends/codegen_cuda_dev.cc: xtrans/clang's stricter overload resolution (vs nvcc) makes cinn::common::float16/bfloat16's implicit float+double conversions ambiguous in several call sites (shuffle intrinsics, cmath max/min promotion, generic struct shuffling). A SFINAE-based generic struct-shuffle overload is added for WITH_XPU_CADA; float16/bfloat16/fp8/welford/argidx reduce code paths that still hit the remaining ambiguity are temporarily scoped out for WITH_XPU_CADA (float32 reduce is unaffected and verified working end-to-end via CINN on M100/xtrans). - paddle/cinn/runtime/cuda/xtrans_cublas_v2_compat.h (new), paddle/cinn/runtime/cuda/cublas_util.h: work around xtrans's cublas_v2.h textually rewriting several cublas symbols to _v2 variants that xtrans's own libcublas.so does not export. - paddle/ap/*: fix xtrans/clang not implicitly instantiating member function templates reached only through `if constexpr` branches inside lambdas (explicit instantiation added), plus narrowing- conversion and API-usage fixes required to compile under xtrans/clang. Verified: WITH_XPU_CADA+CINN build completes, and simple_add_cinn.py (fp32 elementwise add) passes end-to-end through CINN's JIT/NVRTC path on M100 via xtrans.
|
|
Paddle-Bot
left a comment
There was a problem hiding this comment.
发现 1 条 P0 与 5 条 P1 问题,详见行内评论与 Review Board。
| set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
||
| include(system) | ||
| add_compile_options("-fpermissive") |
| endif() | ||
|
|
||
|
|
||
| string(APPEND CMAKE_CXX_FLAGS " -Wno-error") |
| endif() | ||
|
|
||
| if(WITH_GPU | ||
| AND 0 # 先跳过FA |
| set(WITH_MKL_CBLAS ${WITH_MKL}) | ||
| if(WITH_GPU) | ||
| set(WITH_CUDA ${WITH_GPU}) | ||
| if(WITH_GPU OR WITH_XPU_CADA) |
There was a problem hiding this comment.
WITH_XPU_CADA=ON 且默认 WITH_GPU=OFF 时,这里仍把 WITH_CUDNN 设为默认开启并定义 CINN_WITH_CUDNN,但 cmake/configure.cmake 只在 WITH_GPU 下定义 PADDLE_WITH_CUDA,paddle/phi/backends/dynload/CMakeLists.txt 也只在 WITH_GPU 下编译 cuDNN dynload。于是 cinn/runtime/cuda_util.cc 会包含被 PADDLE_WITH_CUDA 整体屏蔽的 cudnn.h 并使用未定义的 cuDNN 类型/包装器,CADA 默认配置无法编译。请让 CADA 的 cuDNN 依赖与这些宏/目标保持一致,或默认关闭 CINN_WITH_CUDNN。
| // GetNvidiaAllIncludePath expects, nor is it installed under | ||
| // /usr/local/cuda; its headers live under XTRANS_ROOT/targets/<arch>/include | ||
| // (see cmake/cinn.cmake XTRANS_ROOT/XTRANS_INCLUDE_DIR). | ||
| const char* xtrans_root_env = std::getenv("XTRANS_ROOT"); |
| // longer needs these types (CINN_CUDA_FP16/CINN_CUDA_BF16 are suppressed | ||
| // for WITH_XPU_CADA), so skip including/using them entirely here rather | ||
| // than injecting a variant that never gets referenced; re-add once fixed. | ||
| const std::string CodeGenCudaDev::source_header_ = // NOLINT |
There was a problem hiding this comment.
PR Category
PR Types
Description
是否引起精度变化