这是indexloc提供的服务,不要输入任何密码
Skip to content

Add an xla flag to lower ragged dots through the ragged dot fusion emitter #97278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ absl::StatusOr<std::unique_ptr<HloInstruction>> RaggedToGeneral(
absl::StatusOr<bool> RaggedDotRewriter::Run(
HloModule* module,
const absl::flat_hash_set<absl::string_view>& execution_threads) {
if (module->config()
.debug_options()
.xla_gpu_experimental_use_ragged_dot_fusion()) {
return false;
}

// Gather all Ragged Dot operations.
std::vector<HloRaggedDotInstruction*> ragged_dots;
for (auto* computation :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ TEST_F(RaggedDotRewriterTest, DontDoAnythingIfNoRaggedDot) {
EXPECT_FALSE(changed);
}

TEST_F(RaggedDotRewriterTest, DontRewriteIfUsingRaggedDotFusion) {
absl::string_view module_string = R"(
HloModule module

ENTRY main {
p0 = bf16[64,9]{1,0} parameter(0)
p1 = bf16[2,9,8]{2,1,0} parameter(1)
p2 = s64[2]{0} parameter(2)
ROOT ragged-dot = bf16[64,8]{1,0} ragged-dot(p0, p1, p2),
lhs_contracting_dims={1}, rhs_contracting_dims={1},
lhs_ragged_dims={0}, rhs_group_dims={0}
})";

TF_ASSERT_OK_AND_ASSIGN(std::unique_ptr<HloModule> module,
ParseAndReturnVerifiedModule(module_string));
module->mutable_config()
.mutable_debug_options()
.set_xla_gpu_experimental_use_ragged_dot_fusion(true);
TF_ASSERT_OK_AND_ASSIGN(bool changed, RaggedDotRewriter().Run(module.get()));
EXPECT_FALSE(changed);
}

TEST_F(RaggedDotRewriterTest, RaggedNonContracting) {
absl::string_view module_string = R"(
HloModule module
Expand Down
6 changes: 5 additions & 1 deletion third_party/xla/xla/xla.proto
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ message DebugOptions {
// gemm_fusion_autotuner.
optional bool xla_gpu_experimental_use_autotuner_pass = 396;

// If true, use the ragged dot fusion emitter rather than expanding to a
// regular dot.
optional bool xla_gpu_experimental_use_ragged_dot_fusion = 401;

// If true, PTX compilation will fail if a kernel spills registers.
// This is meant for debugging and only applies to CUDA PTX compilation.
optional bool xla_gpu_fail_ptx_compilation_on_register_spilling = 353;
Expand Down Expand Up @@ -1287,7 +1291,7 @@ message DebugOptions {
// Note: when adding a new flag, please add it to one of the hardware-specific
// or hardware-agnostic sections at the top of this proto message.

// Next id: 401
// Next id: 402

// Extra options to pass to the compilation backend (e.g. LLVM); specific
// interpretation of these values is left to the backend.
Expand Down