Skip to content

Added fallback logic for computing COO buffer size #294

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -256,7 +256,19 @@ int ComputeCooBufferSizePerDevice(
"large and can cause OOM. Utilize the stats returned from "
"the sparse dense matmul preprocessing API.";
}
VLOG(1) << "Computed Coo Buffer Size: " << result;

LOG_EVERY_POW_2(INFO) << " Stacked Table Name: " << stacked_table_metadata[0].name
<< " Theoretical Max: " << theoretical_max
<< " max_ids_rounded_up: " << max_ids_rounded_up
<< " num_scs_per_device: " << num_scs_per_device
<< " num_scs: " << num_scs
<< " suggested_coo_buffer_size: " << suggested_coo_buffer_size.value()
<< " Computed COO Buffer Size: " << result;
if (stacked_table_metadata[0].suggested_coo_buffer_size.has_value()) {
LOG_EVERY_POW_2(INFO) << " User COO buffer size: Table Name: " << stacked_table_metadata[0].name
<< " buffer size: " << stacked_table_metadata[0].suggested_coo_buffer_size.value();
}

// The result could be very large and cause overflow. We need to make
// sure the result is within the range of int before using it.
CHECK(result > 0 && result < INT_MAX);
Expand Down Expand Up @@ -287,6 +299,17 @@ std::optional<int> SuggestedCooBufferSizeForStackedTables(
const absl::Span<const StackedTableMetadata> stacked_table_metadata) {
std::optional<int> suggested_coo_buffer_size =
stacked_table_metadata[0].suggested_coo_buffer_size;
// Add default fallback logic
if (!suggested_coo_buffer_size.has_value()) {
int batch_size = 0;
for (const auto& metadata : stacked_table_metadata) {
batch_size += metadata.batch_size;
}

const int static_buffer_size_multiplier = 64;
suggested_coo_buffer_size = static_buffer_size_multiplier * batch_size;
}

return suggested_coo_buffer_size;
}

Expand Down
Loading