Features for large-scale deployments
This note talks about several extension points and tricks that might be useful when running PyTorch within a larger system or operating multiple systems using PyTorch in a larger organization.
The note assumes that you either build PyTorch from source in your organization or have an ability to statically link additional code to be loaded when PyTorch is used. Therefore, many of the hooks are exposed as C++ APIs that can be triggered once in a centralized place, e.g. in static initialization code.
Fleet-wide operator profiling
PyTorch comes with torch.autograd.profiler capable of measuring time
taken by individual operators on demand. One can use the same mechanism to do
“always ON” measurements for any process running PyTorch. It might be useful for
gathering information about PyTorch workloads running in a given process or
across the entire set of machines.
New callbacks for any operator invocation can be added with
torch::addGlobalCallback. Hooks will be called with
struct that describes invocation
context (e.g. ). If enabled, contains arguments
of the function represented as variant type. Note, that inputs
logging is relatively expensive and thus has to be enabled explicitly.