Skip to content

Commit

Permalink
Integrate CompilationProvider framework into NVPTXCompiler
Browse files Browse the repository at this point in the history
Removes all the logic that deals with PTX from NVPTXCompiler and instead
uses the `CompilationProvider` classes for PTX compilation.

This has the advantage that it
- Removes a bunch of untested code from nvptx_compiler.cc
- Fixes bugs in the caching logic
- Makes it possible to reuse the same PTX compilation pipeline for Triton Kernels in JAX
- Makes it possible to reuse the same PTX compilation pipeline in the Runtime where we currently only support driver compilation.

PiperOrigin-RevId: 702701896
  • Loading branch information
beckerhe authored and tensorflower-gardener committed Dec 4, 2024
1 parent 63248b1 commit 1c27e02
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 522 deletions.
46 changes: 29 additions & 17 deletions third_party/xla/xla/service/gpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ cc_library(
],
deps = [
":nvptx_compiler_impl",
"//xla:debug_options_flags",
"//xla/service:compiler",
"//xla/stream_executor/cuda:cuda_platform_id",
"@local_tsl//tsl/platform:path",
Expand All @@ -1787,12 +1788,13 @@ cc_library(
deps = [
":buffer_sharing",
":cublas_padding_requirements",
":gpu_asm_opts_util",
":gpu_compiler",
":ir_emission_utils",
":metrics",
":ptx_compile_options_from_debug_options",
":target_constants",
"//xla:autotune_results_proto_cc",
"//xla:debug_options_flags",
"//xla:util",
"//xla:xla_data_proto_cc",
"//xla:xla_proto_cc",
Expand Down Expand Up @@ -1842,40 +1844,28 @@ cc_library(
"//xla/stream_executor:dnn",
"//xla/stream_executor:semantic_version",
"//xla/stream_executor:stream_executor_h",
"//xla/stream_executor/cuda:assemble_compilation_provider",
"//xla/stream_executor/cuda:caching_compilation_provider",
"//xla/stream_executor/cuda:compilation_options",
"//xla/stream_executor/cuda:compilation_provider",
"//xla/stream_executor/cuda:cuda_diagnostics",
"//xla/stream_executor/cuda:cuda_platform_id",
"//xla/stream_executor/cuda:driver_compilation",
"//xla/stream_executor/cuda:nvjitlink",
"//xla/stream_executor/cuda:nvjitlink_known_issues",
"//xla/stream_executor/cuda:nvjitlink_support",
"//xla/stream_executor/cuda:ptx_compilation_method",
"//xla/stream_executor/cuda:ptx_compiler",
"//xla/stream_executor/cuda:ptx_compiler_support",
"//xla/stream_executor/cuda:ptx_linking_method",
"//xla/stream_executor/cuda:subprocess_compilation",
"//xla/stream_executor/gpu:gpu_asm_opts",
"//xla/tsl/util:env_var",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:node_hash_map",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:span",
"@llvm-project//llvm:IRReader",
"@llvm-project//llvm:Support",
"@llvm-project//llvm:ir_headers",
"@local_tsl//tsl/platform:env",
"@local_tsl//tsl/platform:errors",
"@local_tsl//tsl/platform:path",
"@local_tsl//tsl/platform:status",
"@local_tsl//tsl/platform:statusor",
"@local_tsl//tsl/profiler/lib:scoped_annotation",
"@local_tsl//tsl/profiler/lib:traceme",
Expand Down Expand Up @@ -3244,3 +3234,25 @@ xla_cc_test(
"@local_tsl//tsl/platform:statusor",
],
)

cc_library(
name = "ptx_compile_options_from_debug_options",
srcs = ["ptx_compile_options_from_debug_options.cc"],
hdrs = ["ptx_compile_options_from_debug_options.h"],
deps = [
"//xla:xla_proto_cc_impl",
"//xla/stream_executor/cuda:compilation_options",
],
)

xla_cc_test(
name = "ptx_compile_options_from_debug_options_test",
srcs = ["ptx_compile_options_from_debug_options_test.cc"],
deps = [
":ptx_compile_options_from_debug_options",
"//xla/stream_executor/cuda:compilation_options",
"@com_google_googletest//:gtest_main",
"@local_tsl//tsl/platform:status_matchers",
"@local_tsl//tsl/platform:test",
],
)
Loading

0 comments on commit 1c27e02

Please sign in to comment.