1
1
module Distributed
2
2
3
- using .. Reactant: Reactant
3
+ using .. Reactant: Reactant, Accelerators
4
4
using Sockets
5
5
6
6
const initialized = Ref (false )
@@ -303,8 +303,8 @@ const _TPU_COORDINATOR_PORT = "8476"
303
303
function get_coordinator_address (
304
304
env:: AbstractCloudTPUEnvDetector , timeout_in_seconds:: Integer
305
305
)
306
- coordinator_address = if Reactant . TPUUtils . has_megascale_address ()
307
- Reactant . TPUUtils . get_tpu_env_value (" MEGASCALE_COORDINATOR_ADDRESS" )
306
+ coordinator_address = if Accelerators . TPU . has_megascale_address ()
307
+ Accelerators . TPU . get_tpu_env_value (" MEGASCALE_COORDINATOR_ADDRESS" )
308
308
else
309
309
first (_get_worker_list_in_slice (env))
310
310
end
@@ -361,13 +361,13 @@ function get_process_id(env::AbstractCloudTPUEnvDetector)
361
361
end
362
362
363
363
function _get_num_slices (:: AbstractCloudTPUEnvDetector )
364
- Reactant . TPUUtils . has_megascale_address () || return 1
365
- return parse (Int, Reactant . TPUUtils . get_tpu_env_value (" MEGASCALE_NUM_SLICES" ))
364
+ Accelerators . TPU . has_megascale_address () || return 1
365
+ return parse (Int, Accelerators . TPU . get_tpu_env_value (" MEGASCALE_NUM_SLICES" ))
366
366
end
367
367
368
368
function _get_slice_id (:: AbstractCloudTPUEnvDetector )
369
- Reactant . TPUUtils . has_megascale_address () || return 0
370
- return parse (Int, Reactant . TPUUtils . get_tpu_env_value (" MEGASCALE_SLICE_ID" ))
369
+ Accelerators . TPU . has_megascale_address () || return 0
370
+ return parse (Int, Accelerators . TPU . get_tpu_env_value (" MEGASCALE_SLICE_ID" ))
371
371
end
372
372
373
373
function _get_process_id_in_slice end
@@ -376,7 +376,7 @@ function _get_worker_list_in_slice end
376
376
# # GceTPUCluster
377
377
378
378
function is_env_present (:: GceTPUCluster )
379
- if ! Reactant . TPUUtils . RUNNING_IN_CLOUD_TPU_VM[]
379
+ if ! Accelerators . TPU . RUNNING_IN_CLOUD_TPU_VM[]
380
380
@debug " Did not detect cloud TPU VM"
381
381
return false
382
382
end
@@ -386,8 +386,8 @@ function is_env_present(::GceTPUCluster)
386
386
return false
387
387
end
388
388
389
- metadata_response, metadata_code = Reactant . TPUUtils . get_metadata (" agent-worker-number" )
390
- if metadata_code == Reactant . TPUUtils . _TPU_METADATA_RESPONSE_CODE_SUCCESS
389
+ metadata_response, metadata_code = Accelerators . TPU . get_metadata (" agent-worker-number" )
390
+ if metadata_code == Accelerators . TPU . _TPU_METADATA_RESPONSE_CODE_SUCCESS
391
391
@debug " Gce Tpu Cluster detected for Reactant Distributed System"
392
392
return true
393
393
else
@@ -400,23 +400,23 @@ function is_env_present(::GceTPUCluster)
400
400
end
401
401
402
402
function _get_process_id_in_slice (:: GceTPUCluster )
403
- return parse (Int, first (Reactant . TPUUtils . get_metadata (" agent-worker-number" )))
403
+ return parse (Int, first (Accelerators . TPU . get_metadata (" agent-worker-number" )))
404
404
end
405
405
406
406
function _get_worker_list_in_slice (:: GceTPUCluster )
407
- workers = split (first (Reactant . TPUUtils . get_metadata (" worker-network-endpoints" )), ' ,' )
407
+ workers = split (first (Accelerators . TPU . get_metadata (" worker-network-endpoints" )), ' ,' )
408
408
return [split (w, ' :' )[3 ] for w in workers]
409
409
end
410
410
411
411
# # GkeTPUCluster
412
412
413
413
function is_env_present (:: GkeTPUCluster )
414
- if Reactant . TPUUtils . RUNNING_IN_CLOUD_TPU_VM[] && haskey (ENV , " TPU_WORKER_HOSTNAMES" )
414
+ if Accelerators . TPU . RUNNING_IN_CLOUD_TPU_VM[] && haskey (ENV , " TPU_WORKER_HOSTNAMES" )
415
415
@debug " Detected GKE TPU cluster for Reactant Distributed System"
416
416
return true
417
417
end
418
418
419
- if ! Reactant . TPUUtils . RUNNING_IN_CLOUD_TPU_VM[]
419
+ if ! Accelerators . TPU . RUNNING_IN_CLOUD_TPU_VM[]
420
420
@debug " Did not detect cloud TPU VM"
421
421
return false
422
422
end
0 commit comments