MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / _set_random_seed

Function _set_random_seed

codegeex/megatron/initialize.py:291–302  ·  view source on GitHub ↗

Set random seed for reproducability.

(seed_)

Source from the content-addressed store, hash-verified

289
290
291def _set_random_seed(seed_):
292 """Set random seed for reproducability."""
293 if seed_ is not None and seed_ > 0:
294 # Ensure that different pipeline MP stages get different seeds.
295 seed = seed_ + (100 * mpu.get_pipeline_model_parallel_rank())
296 random.seed(seed)
297 np.random.seed(seed)
298 torch.manual_seed(seed)
299 if torch.cuda.device_count() > 0:
300 mpu.model_parallel_cuda_manual_seed(seed)
301 else:
302 raise ValueError("Seed ({}) should be a positive integer.".format(seed))
303
304
305def write_args_to_tensorboard():

Callers 1

finish_mpu_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected