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

feat: Expose warmup thread pool to model server #3660

Open
wants to merge 2 commits into
base: master
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
3 changes: 3 additions & 0 deletions tensorflow_serving/model_servers/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ int main(int argc, char** argv) {
&options.num_request_iterations_for_warmup,
"Number of times a request is iterated during warmup "
"replay. This value is used only if > 0."),
tensorflow::Flag("num_warmup_threads", &options.num_warmup_threads,
"Number of threads for warmp up threads pool to use for model warmup."
"Default is 0, which means no thread pool is used."),
tensorflow::Flag("version", &display_version, "Display version"),
tensorflow::Flag(
"monitoring_config_file", &options.monitoring_config_file,
Expand Down
3 changes: 3 additions & 0 deletions tensorflow_serving/model_servers/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ Status Server::BuildAndStart(const Options& server_options) {
session_bundle_config.mutable_model_warmup_options()
->mutable_num_request_iterations()
->set_value(server_options.num_request_iterations_for_warmup);
session_bundle_config.mutable_model_warmup_options()
->mutable_num_model_warmup_threads()
->set_value(server_options.num_warmup_threads);
}
session_bundle_config.set_remove_unused_fields_from_bundle_metagraph(
server_options.remove_unused_fields_from_bundle_metagraph);
Expand Down
1 change: 1 addition & 0 deletions tensorflow_serving/model_servers/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Server {
bool enable_model_warmup = true;
// This value is used only if > 0.
tensorflow::int32 num_request_iterations_for_warmup = 0;
tensorflow::int32 num_warmup_threads = 0;
tensorflow::string monitoring_config_file;
// Tensorflow session run options.
bool enforce_session_run_timeout = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ absl::Status RunSavedModelWarmup(

int num_model_warmup_threads =
model_warmup_options.has_num_model_warmup_threads()
? std::max(model_warmup_options.num_model_warmup_threads().value(), 1)
: 1;
? std::max(model_warmup_options.num_model_warmup_threads().value(), 0)
: 0;
std::unique_ptr<tensorflow::io::SequentialRecordReader> tf_record_file_reader;
absl::Status status;
int num_warmup_records = 0;
if (num_model_warmup_threads <= 1) {
if (num_model_warmup_threads < 1) {
tf_record_file_reader.reset(
new tensorflow::io::SequentialRecordReader(tf_record_file.get()));
tstring record;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import "tensorflow/core/protobuf/named_tensor.proto";
message ModelWarmupOptions {
// Number of times a request is iterated during warmup replay. By default 1.
google.protobuf.Int32Value num_request_iterations = 1;
// The number of threads to parallel execute warm up queries. By default 1.
// The number of threads to parallel execute warm up queries. By default 0.
// which means that no thread pool will be used.
google.protobuf.Int32Value num_model_warmup_threads = 2;
// Model name.
string model_name = 3;
Expand Down