Skip to content
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

This is a no-op on openxla. #24134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
27 changes: 16 additions & 11 deletions xla/service/spmd/spmd_partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5378,16 +5378,8 @@ int64_t SpmdPartitioner::CommunicationCostInBytes(HloInstruction* hlo) {
}
}

absl::StatusOr<bool> SpmdPartitioner::Run(
HloModule* module,
const absl::flat_hash_set<absl::string_view>& execution_threads) {
set_execution_threads(execution_threads);
TF_RETURN_IF_ERROR(PreprocessSharding(module, execution_threads));
TF_RETURN_IF_ERROR(PreprocessHlos(module, execution_threads));

XLA_VLOG_LINES(1, SpmdLogger::ReportBeforePartition(
*module, options_.report_instruction_count));

/* static */ void SpmdPartitioner::RecordInputsOutputsSharding(
HloModule* module) {
// Add the parameters' and output's shardings to the module.
std::vector<HloSharding> entry_params_shardings;
const auto num_parameters = module->entry_computation()->num_parameters();
Expand All @@ -5401,6 +5393,18 @@ absl::StatusOr<bool> SpmdPartitioner::Run(
auto entry_root = module->entry_computation()->root_instruction();
CHECK(entry_root->has_sharding()) << "Missing sharding in entry root.";
module->set_spmd_output_sharding(entry_root->sharding());
}

absl::StatusOr<bool> SpmdPartitioner::Run(
HloModule* module,
const absl::flat_hash_set<absl::string_view>& execution_threads) {
set_execution_threads(execution_threads);
TF_RETURN_IF_ERROR(PreprocessSharding(module, execution_threads));
TF_RETURN_IF_ERROR(PreprocessHlos(module, execution_threads));

XLA_VLOG_LINES(1, SpmdLogger::ReportBeforePartition(
*module, options_.report_instruction_count));
RecordInputsOutputsSharding(module);

FlattenCallGraph flatten;
TF_ASSIGN_OR_RETURN(auto changed, flatten.Run(module));
Expand All @@ -5411,7 +5415,8 @@ absl::StatusOr<bool> SpmdPartitioner::Run(
int64_t next_channel_id = hlo_query::NextChannelId(*module);
// Copy the root sharding since the partitioner visitor may temporarily change
// the sharding to work around manual sharding.
HloSharding root_sharding = entry_root->sharding();
HloSharding root_sharding =
module->entry_computation()->root_instruction()->sharding();

std::unique_ptr<CallGraph> call_graph = CallGraph::Build(module);
CHECK(call_graph->IsFlattened());
Expand Down
4 changes: 4 additions & 0 deletions xla/service/spmd/spmd_partitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ class SpmdPartitioner : public HloModulePass {
return execution_threads_;
}

// Update module's parameter and output sharding information, based on the
// sharding information of the module's parameters and outptuts.
static void RecordInputsOutputsSharding(HloModule* module);

protected:
// This is the internal implementation for AllGatherShards(), returns a pair
// of hlo instructions whose first element is the result of the all-gather
Expand Down