Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion torch_xla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _setup_default_env():
os.environ.setdefault('TPU_ML_PLATFORM', 'PyTorch/XLA')
# This is used for ML Framework Telemetry.
os.environ.setdefault('TPU_ML_PLATFORM_VERSION', __version__)
os.environ.setdefault('ENABLE_RUNTIME_UPTIME_TELEMETRY', '1')

if tpu.version() == 4:
os.environ.setdefault('TPU_MEGACORE', 'megacore_dense')
Expand Down Expand Up @@ -212,7 +213,8 @@ def _init_xla_lazy_backend():
from .experimental import plugins
from ._internal import neuron, xpu # Additional built-in plugins

if os.getenv('XLA_REGISTER_INSTALLED_PLUGINS') == '1':
if os.getenv('XLA_REGISTER_INSTALLED_PLUGINS',
'0' if _XLAC._has_cuda_support() else '1') == '1':
plugins.use_dynamic_plugins()
plugins.register_installed_plugins()

Expand Down
11 changes: 9 additions & 2 deletions torch_xla/_internal/tpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import torch_xla.core.xla_env_vars as xenv
import torch_xla.core.xla_model as xm
from torch_xla.experimental import plugins
from torch_xla.version import __version__

_GCE_METADATA_ROOT_URL = 'http://metadata.google.internal/computeMetadata/v1'
_ACCELERATOR_TYPE_TO_HOST_BOUNDS = {
Expand Down Expand Up @@ -342,10 +343,16 @@ def configure_multiprocess(self, local_rank, local_world_size):
return configure_topology(local_rank, local_world_size)

def physical_chip_count(self):
return num_available_chips()
# HACK: We may reduce the number of processes we spawn depending on TPU
# topology settings
return num_local_processes()

def client_create_options(self):
return {
'max_inflight_computations':
xu.getenv_as('XLA_TPU_MAX_INFLIGHT_COMPUTATIONS', int, 4)
xu.getenv_as('XLA_TPU_MAX_INFLIGHT_COMPUTATIONS', int, 4),
'ml_framework_name':
'PyTorch/XLA',
'ml_framework_version':
__version__
}
7 changes: 7 additions & 0 deletions torch_xla/csrc/init_python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,13 @@ void InitXlaModuleBindings(py::module m) {
return XlaCustomCall(inputs, payload, output_shapes, output_dtypes,
/*is_tpu=*/true);
});
m.def("_has_cuda_support", []() {
#ifdef GOOGLE_CUDA
return true;
#else
return false;
#endif
});
m.def("_xla_gpu_custom_call",
[](const std::vector<at::Tensor>& inputs, const std::string& payload,
const std::vector<std::vector<int64_t>>& output_shapes,
Expand Down