Skip to content

Commit

Permalink
Enable coordination service for CloudTPU.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 556823075
  • Loading branch information
tensorflower-gardener committed Aug 14, 2023
1 parent 0862517 commit a2f494a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def tpu_hardware_feature(self):
@property
def environment(self):
"""Returns the current environment which TensorFlow is running in."""
return self._environment
return ''

def _start_local_server(self):
address = compat.as_text(self._cloud_tpu_client.get_local_ip())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,10 @@ def testTpuTopology(self):
self.assertIsInstance(cluster_resolver.tpu_hardware_feature,
topology_pb2.TPUHardwareFeature)

def testEnvironment(self):
cluster_resolver = resolver.TPUClusterResolver(tpu='local')
self.assertEqual(cluster_resolver.environment, '')


if __name__ == '__main__':
test.main()
12 changes: 9 additions & 3 deletions tensorflow/python/eager/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ def connect_to_cluster(cluster_spec_or_resolver,
# tpu_cluster_resolver.TPUClusterResolver
if (isinstance(cluster_spec_or_resolver, cluster_resolver.ClusterResolver)
and hasattr(cluster_spec_or_resolver, "tpu_hardware_feature")):
is_uptc_sess = ".uptc-worker." in cluster_spec_or_resolver.master()
service_type = remote_utils.coordination_service_type(
protocol, is_uptc_sess)
service_leader = cluster_spec_or_resolver.get_coordination_service_leader(
)
# Maybe enable coordination service internally.
if cluster_spec_or_resolver.environment == "google":
is_uptc_sess = ".uptc-worker." in cluster_spec_or_resolver.master()
service_type = remote_utils.coordination_service_type(
protocol, is_uptc_sess)
# Enable coordination service for Cloud TPU.
else:
service_type = "standalone"

if service_type:
# If `enable_health_check` is true, coordination service agent would
# do connecting (and tasks would send heartbeat if connection is set up)
Expand Down

0 comments on commit a2f494a

Please sign in to comment.