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

Deprecate Python global configuration functions [Part 1] #5923

Merged
merged 21 commits into from Dec 15, 2020

Conversation

@edgchen1
Copy link
Contributor

@edgchen1 edgchen1 commented Nov 25, 2020

Description
Enable options to be set via execution provider (EP)-specific options and log deprecation warning from current global configuration functions.

TODO: Come up with convenient way to set EP-specific options (possibly refine existing APIs), update documentation and tests with new usage.

Motivation and Context
Deprecate global configuration functions in favor of EP-specific options.

edgchen1 added 3 commits Nov 25, 2020
…options to be set via EP-specific options and output deprecation warning from current global configuration functions.
@edgchen1 edgchen1 marked this pull request as ready for review Nov 25, 2020
@edgchen1 edgchen1 requested a review from microsoft/onnxruntime as a code owner Nov 25, 2020
@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Nov 25, 2020

/azp run orttraining-amd-gpu-ci-pipeline #Resolved

@azure-pipelines
Copy link

@azure-pipelines azure-pipelines bot commented Nov 25, 2020

Azure Pipelines successfully started running 1 pipeline(s).

#Resolved

@edgchen1 edgchen1 requested review from weixingzhang and suffiank Nov 26, 2020
cuda_provider_options.cuda_mem_limit,
cuda_provider_options.arena_extend_strategy,
cuda_provider_options.do_copy_in_default_stream));
sess, *onnxruntime::CreateExecutionProviderFactory_CUDA(info.device_id,

This comment has been minimized.

@pranavsharma

pranavsharma Dec 4, 2020
Contributor

I know this is not the objective of this PR. Can CUDAExecutionProviderInfo be stored in the factory obj as-is instead of re-create it in CreateProvider() later? This will also keep the signature of this factory function clean - no need to keep adding more parameters as more options are added. Similar comment applies to other EPs like ROCM. #Resolved

This comment has been minimized.

@edgchen1

edgchen1 Dec 4, 2020
Author Contributor

ok, i can update the CUDA and ROCM EP factories for now


In reply to: 535833627 [](ancestors = 535833627)

const auto nuphar_provider_options_it = provider_options_map.find(type);
if (nuphar_provider_options_it != provider_options_map.end()) {
const auto& nuphar_provider_options = nuphar_provider_options_it->second;
const auto nuphar_settings_it = nuphar_provider_options.find("nuphar_settings");

This comment has been minimized.

@pranavsharma

pranavsharma Dec 4, 2020
Contributor

Can ReadProviderOption be used here? #Resolved

const auto& nuphar_provider_options = nuphar_provider_options_it->second;
const auto nuphar_settings_it = nuphar_provider_options.find("nuphar_settings");
if (nuphar_settings_it != nuphar_provider_options.end()) {
nuphar_settings = nuphar_settings_it->second;

This comment has been minimized.

@pranavsharma

pranavsharma Dec 4, 2020
Contributor

nit: can avoid the copy. #Resolved

* Returns true if the option is present, false otherwise.
*/
template <typename T>
bool ReadProviderOption(const ProviderOptions& options, const std::string& key, T& value) {

This comment has been minimized.

@pranavsharma

pranavsharma Dec 4, 2020
Contributor

Is using optional better instead of returning true/false? #Resolved

This comment has been minimized.

@edgchen1

edgchen1 Dec 4, 2020
Author Contributor

good idea


In reply to: 535835891 [](ancestors = 535835891)

This comment has been minimized.

@edgchen1

edgchen1 Dec 4, 2020
Author Contributor

actually this signature is useful for the existing usage:

CUDAExecutionProviderInfo info{};
ReadProviderOption(options, provider_option_names::kMemLimit, info.cuda_mem_limit);

but i can add another function that returns an optional


In reply to: 536446380 [](ancestors = 536446380,535835891)

This comment has been minimized.

@pranavsharma

pranavsharma Dec 5, 2020
Contributor

Sure. One other thing I noticed is that we validate values returned by this function for only some of the keys. GetOrDefault might be better I guess instead of returning optional as the user will not have the burden to check for the value in optional. Also, it should satisfy all usages. #Resolved

This comment has been minimized.

@edgchen1

edgchen1 Dec 5, 2020
Author Contributor

Ah ok, i can change it to ReadProviderOptionOrDefault()


In reply to: 536454011 [](ancestors = 536454011)

* Tries to parse a value from an entire string.
*/
template <typename T>
bool TryParse(const std::string& str, T& value) {

This comment has been minimized.

@pranavsharma

pranavsharma Dec 4, 2020
Contributor

Would using stol family of functions be simpler?

This comment has been minimized.

@edgchen1

edgchen1 Dec 4, 2020
Author Contributor

not sure if it would. one nice thing about operator>> is that i don't need to call different functions explicitly. also can specify a particular locale without having to update the global one.


In reply to: 535837295 [](ancestors = 535837295)

@azure-pipelines
Copy link

@azure-pipelines azure-pipelines bot commented Dec 4, 2020

No pipelines are associated with this pull request.

#Resolved

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 8, 2020

/azp run orttraining-amd-gpu-ci-pipeline

@azure-pipelines
Copy link

@azure-pipelines azure-pipelines bot commented Dec 8, 2020

No pipelines are associated with this pull request.
"Invalid ", provider_option_names::kDeviceId, " value: ", info.device_id,
", must be between 0 (inclusive) and ", num_devices, " (exclusive).");
}
ReadProviderOption(options, provider_option_names::kMemLimit, info.cuda_mem_limit);

This comment has been minimized.

@suffiank

suffiank Dec 9, 2020
Contributor

I think it just sets the initial arena size. Maybe it needs a clearer name. @codemzs

This comment has been minimized.

@edgchen1

edgchen1 Dec 9, 2020
Author Contributor

i think it is the maximum, looks like the value eventually goes to

size_t max_mem; // use 0 to allow ORT to choose the default


In reply to: 538900994 [](ancestors = 538900994)

This comment has been minimized.

@suffiank

suffiank Dec 9, 2020
Contributor

OK, makes sense then. It looks like an unset value defaults to the numeric limit.

constexpr const char* kMemLimit = "cuda_mem_limit";
constexpr const char* kArenaExtendStrategy = "arena_extend_strategy";
constexpr const char* kCudnnConvAlgo = "cudnn_conv_algo";
constexpr const char* kDoCopyInDefaultStream = "do_copy_in_default_stream";

This comment has been minimized.

@suffiank

suffiank Dec 9, 2020
Contributor

Are there descriptors for each of these?

This comment has been minimized.

@edgchen1

edgchen1 Dec 9, 2020
Author Contributor

hm, not sure if there are. will add documentation if needed in part 2


In reply to: 538901750 [](ancestors = 538901750)

m.def("set_cuda_device_id", [](const int id) { cuda_device_id = static_cast<OrtDevice::DeviceId>(id); });
// TODO remove deprecated global config
m.def("set_cuda_device_id", [](const int id) {
LogDeprecationWarning("set_cuda_device_id", "CUDA/ROCM execution provider option \"device_id\"");

This comment has been minimized.

@suffiank

suffiank Dec 9, 2020
Contributor

What's the correct way to set these options? Is that for Part 2?

This comment has been minimized.

@edgchen1

edgchen1 Dec 9, 2020
Author Contributor

through the EP specific options. part 2 will refine the existing way of setting EP specific options


In reply to: 538908003 [](ancestors = 538908003)

@edgchen1 edgchen1 dismissed stale reviews from suffiank and pranavsharma via a0da40c Dec 12, 2020
@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Linux CPU CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Linux CPU x64 NoContribops CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,MacOS NoContribops CI Pipeline,Windows CPU CI Pipeline,orttraining-linux-gpu-ci-pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Linux CPU x64 NoContribops CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Linux GPU CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Linux GPU TensorRT CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run MacOS NoContribops CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run Windows CPU CI Pipeline

@edgchen1
Copy link
Contributor Author

@edgchen1 edgchen1 commented Dec 15, 2020

/azp run orttraining-linux-gpu-ci-pipeline

@edgchen1 edgchen1 merged commit 64709b1 into master Dec 15, 2020
21 checks passed
21 checks passed
Android CI Pipeline Build #20201214.21 succeeded
Details
Linux CPU CI Pipeline #20201214.33 succeeded
Details
Linux CPU Minimal Build E2E CI Pipeline Build #20201214.25 succeeded
Details
Linux CPU x64 NoContribops CI Pipeline #20201215.3 succeeded
Details
Linux GPU CI Pipeline #20201215.3 succeeded
Details
Linux GPU TensorRT CI Pipeline #20201215.3 succeeded
Details
Linux OpenVINO CI Pipeline Build #20201214.21 succeeded
Details
MacOS CI Pipeline Build #20201214.25 succeeded
Details
MacOS NoContribops CI Pipeline #20201215.3 succeeded
Details
Windows CPU CI Pipeline #20201215.3 succeeded
Details
Windows GPU CI Pipeline Build #20201214.23 succeeded
Details
Windows GPU TensorRT CI Pipeline Build #20201214.23 succeeded
Details
centos7_cpu Build #20201214.26 succeeded
Details
centos7_cpu (linux_centos_ci Debug) linux_centos_ci Debug succeeded
Details
centos7_cpu (linux_centos_ci Release) linux_centos_ci Release succeeded
Details
license/cla All CLA requirements met.
Details
orttraining-amd-gpu-ci-pipeline Build #orttraining_ci_20201214_21 succeeded
Details
orttraining-distributed Build #20201214.26 succeeded
Details
orttraining-linux-ci-pipeline Build #20201214.25 succeeded
Details
orttraining-linux-gpu-ci-pipeline #20201215.3 succeeded
Details
orttraining-mac-ci-pipeline Build #20201214.24 succeeded
Details
@edgchen1 edgchen1 deleted the edgchen1/python_ep_options branch Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.