You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

_auto_parallel_context.py 24 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Context of auto parallel"""
  16. import threading
  17. import mindspore.context as context
  18. from mindspore.parallel._dp_allreduce_fusion import _set_fusion_strategy_by_idx, _set_fusion_strategy_by_size
  19. from mindspore._c_expression import AutoParallelContext
  20. from mindspore._checkparam import args_type_check
  21. _MAX_GROUP_NAME_LEN = 127
  22. _DEFAULT_HCCL_FUSION_GROUP_NAME = "hccl_world_groupsum1"
  23. _DEFAULT_NCCL_FUSION_GROUP_NAME = "nccl_world_groupsum1"
  24. class _AutoParallelContext:
  25. """
  26. _AutoParallelContext is the environment in which operations are executed
  27. Note:
  28. Create a context through instantiating Context object is not recommended.
  29. Should use auto_parallel_context() to get the context since Context is singleton.
  30. """
  31. _instance = None
  32. _instance_lock = threading.Lock()
  33. def __init__(self):
  34. self._context_handle = AutoParallelContext.get_instance()
  35. def __new__(cls):
  36. if cls._instance is None:
  37. cls._instance_lock.acquire()
  38. cls._instance = object.__new__(cls)
  39. cls._instance_lock.release()
  40. return cls._instance
  41. def check_context_handle(self):
  42. """
  43. Check context handle.
  44. Raises:
  45. ValueError: If the context handle is none.
  46. """
  47. if self._context_handle is None:
  48. raise ValueError("Context handle is none in context!!!")
  49. def set_device_num(self, device_num):
  50. """
  51. Set device num for auto parallel.
  52. Args:
  53. device_num (int): The device number.
  54. Raises:
  55. ValueError: If the device num is not in [1, 4096].
  56. """
  57. self.check_context_handle()
  58. if device_num < 1 or device_num > 4096:
  59. raise ValueError("Device num must be in [1, 4096], but got {}".format(device_num))
  60. self._context_handle.set_device_num(device_num)
  61. def get_device_num(self):
  62. """Get device num."""
  63. self.check_context_handle()
  64. return self._context_handle.get_device_num()
  65. def set_global_rank(self, global_rank):
  66. """
  67. Set global rank for auto parallel.
  68. Args:
  69. global_rank (int): The rank id of current rank.
  70. Raises:
  71. ValueError: If the global rank is not in [1, 4096].
  72. """
  73. self.check_context_handle()
  74. if global_rank < 0 or global_rank > 4095:
  75. raise ValueError("Global rank must be in [0, 4095], but got {}".format(global_rank))
  76. self._context_handle.set_global_rank(global_rank)
  77. def get_global_rank(self):
  78. """Get current rank id."""
  79. self.check_context_handle()
  80. return self._context_handle.get_global_rank()
  81. def set_pipeline_stages(self, stages):
  82. """Set the stages of the pipeline"""
  83. self.check_context_handle()
  84. self._context_handle.set_pipeline_stage_split_num(stages)
  85. def get_pipeline_stages(self):
  86. """Get the stages of the pipeline"""
  87. self.check_context_handle()
  88. return self._context_handle.get_pipeline_stage_split_num()
  89. def set_gradients_mean(self, gradients_mean):
  90. """
  91. Set gradients_mean flag.
  92. Note:
  93. If gradients_mean is true, it will insert a div operator after parameter gradients allreduce.
  94. Args:
  95. gradients_mean (bool): The gradients_mean flag.
  96. """
  97. self.check_context_handle()
  98. self._context_handle.set_gradients_mean(gradients_mean)
  99. def get_gradients_mean(self):
  100. """Get gradients_mean flag."""
  101. self.check_context_handle()
  102. return self._context_handle.get_gradients_mean()
  103. def set_gradient_fp32_sync(self, gradient_fp32_sync):
  104. """
  105. Set gradient_fp32_sync.
  106. Note:
  107. If gradient_fp32_sync is true,
  108. it will convert tensor type from fp16 to fp32 before parameter gradients allreduce.
  109. Args:
  110. gradient_fp32_sync (bool): The gradient_fp32_sync flag.
  111. """
  112. self.check_context_handle()
  113. self._context_handle.set_gradient_fp32_sync(gradient_fp32_sync)
  114. def get_gradient_fp32_sync(self):
  115. """Get gradient_fp32_sync flag."""
  116. self.check_context_handle()
  117. return self._context_handle.get_gradient_fp32_sync()
  118. def set_loss_repeated_mean(self, loss_repeated_mean):
  119. """
  120. Set loss_repeated_mean flag.
  121. Note:
  122. If loss_repeated_mean is true,
  123. Distributed automatic differentiation will perform a mean operator
  124. in backward in the case of repeated calculations.
  125. Args:
  126. loss_repeated_mean (bool): The loss_repeated_mean flag.
  127. """
  128. self.check_context_handle()
  129. self._context_handle.set_loss_repeated_mean(loss_repeated_mean)
  130. def get_loss_repeated_mean(self):
  131. """Get loss_repeated_mean flag."""
  132. self.check_context_handle()
  133. return self._context_handle.get_loss_repeated_mean()
  134. def set_parallel_mode(self, parallel_mode):
  135. """
  136. Set parallel mode for auto parallel.
  137. Args:
  138. parallel_mode (str): The parallel mode of auto parallel.
  139. Raises:
  140. ValueError: If parallel mode is not supported.
  141. """
  142. self.check_context_handle()
  143. ret = self._context_handle.set_parallel_mode(parallel_mode)
  144. if ret is False:
  145. raise ValueError("Parallel mode does not support {}".format(parallel_mode))
  146. def get_parallel_mode(self):
  147. """Get parallel mode."""
  148. self.check_context_handle()
  149. return self._context_handle.get_parallel_mode()
  150. def set_strategy_search_mode(self, auto_parallel_search_mode):
  151. """
  152. Set search mode of strategy.
  153. Args:
  154. auto_parallel_search_mode (str): The search mode of strategy.
  155. """
  156. self.check_context_handle()
  157. ret = self._context_handle.set_strategy_search_mode(auto_parallel_search_mode)
  158. if ret is False:
  159. raise ValueError("Strategy search mode does not support {}".format(auto_parallel_search_mode))
  160. def get_strategy_search_mode(self):
  161. """Get search mode of strategy."""
  162. self.check_context_handle()
  163. return self._context_handle.get_strategy_search_mode()
  164. def set_parameter_broadcast(self, parameter_broadcast):
  165. """
  166. Set parameter broadcast.
  167. Args:
  168. parameter_broadcast (bool): Parameter broadcast or not.
  169. """
  170. self.check_context_handle()
  171. self._context_handle.set_parameter_broadcast(parameter_broadcast)
  172. def get_parameter_broadcast(self):
  173. """Get parameter broadcast flag."""
  174. self.check_context_handle()
  175. return self._context_handle.get_parameter_broadcast()
  176. def set_strategy_ckpt_load_file(self, strategy_ckpt_load_file):
  177. """
  178. Set strategy checkpoint load path.
  179. Args:
  180. strategy_ckpt_load_file (bool): Path to load parallel strategy checkpoint.
  181. """
  182. self.check_context_handle()
  183. self._context_handle.set_strategy_ckpt_load_file(strategy_ckpt_load_file)
  184. def get_strategy_ckpt_load_file(self):
  185. """Get strategy checkpoint load path."""
  186. self.check_context_handle()
  187. return self._context_handle.get_strategy_ckpt_load_file()
  188. def set_full_batch(self, full_batch):
  189. """
  190. Set whether load full batch on each device.
  191. Args:
  192. full_batch (bool): True if load full batch on each device.
  193. """
  194. self.check_context_handle()
  195. self._context_handle.set_full_batch(full_batch)
  196. def get_full_batch(self):
  197. """Get whether load full batch on each device."""
  198. self.check_context_handle()
  199. return self._context_handle.get_full_batch()
  200. def set_strategy_ckpt_save_file(self, strategy_ckpt_save_file):
  201. """
  202. Set strategy checkpoint save path.
  203. Args:
  204. strategy_ckpt_save_file (bool): Path to save parallel strategy checkpoint.
  205. """
  206. self.check_context_handle()
  207. import os
  208. dir_path = os.path.dirname(strategy_ckpt_save_file)
  209. if dir_path and not os.path.exists(dir_path):
  210. os.makedirs(dir_path)
  211. self._context_handle.set_strategy_ckpt_save_file(strategy_ckpt_save_file)
  212. def get_strategy_ckpt_save_file(self):
  213. """Get strategy checkpoint save path."""
  214. self.check_context_handle()
  215. return self._context_handle.get_strategy_ckpt_save_file()
  216. def get_parameter_broadcast_is_set(self):
  217. """Get parameter broadcast is set or not."""
  218. self.check_context_handle()
  219. return self._context_handle.get_parameter_broadcast_is_set()
  220. def set_all_reduce_fusion_split_indices(self, indices, group=""):
  221. """
  222. Set allreduce fusion strategy by parameters indices.
  223. Args:
  224. indices (list): Indices list.
  225. group (str): The communication group of hccl/nccl.
  226. Raises:
  227. TypeError: If type of indices item is not int.
  228. TypeError: If group is not a python str.
  229. """
  230. self.check_context_handle()
  231. if not indices:
  232. raise ValueError('indices can not be empty')
  233. if isinstance(indices, (list)):
  234. for index in indices:
  235. if not isinstance(index, int):
  236. raise TypeError('indices has invalid value')
  237. else:
  238. raise TypeError('indices must be a python list')
  239. if len(set(indices)) != len(indices):
  240. raise ValueError('indices has duplicate elements')
  241. if sorted(indices) != indices:
  242. raise ValueError('elements in indices must be sorted in ascending order')
  243. if isinstance(group, (str)):
  244. group_len = len(group)
  245. if group_len > _MAX_GROUP_NAME_LEN:
  246. raise ValueError('Group name len is out of range {_MAX_GROUP_NAME_LEN}')
  247. else:
  248. raise TypeError('Group must be a python str')
  249. if group == "":
  250. if context.get_context("device_target") == "Ascend":
  251. group = _DEFAULT_HCCL_FUSION_GROUP_NAME
  252. else:
  253. group = _DEFAULT_NCCL_FUSION_GROUP_NAME
  254. self._context_handle.set_all_reduce_fusion_split_indices(indices, group)
  255. if context.get_context("device_target") == "Ascend" and context.get_context("enable_ge"):
  256. _set_fusion_strategy_by_idx(indices)
  257. def get_all_reduce_fusion_split_indices(self, group=""):
  258. """
  259. Get allreduce fusion split indices.
  260. Args:
  261. group (str): The communication group of hccl/nccl.
  262. Returns:
  263. Return split sizes list according to the group.
  264. Raises:
  265. TypeError: If group is not a python str.
  266. """
  267. self.check_context_handle()
  268. if isinstance(group, (str)):
  269. group_len = len(group)
  270. if group_len > _MAX_GROUP_NAME_LEN:
  271. raise ValueError('Group name len is out of range {_MAX_GROUP_NAME_LEN}')
  272. else:
  273. raise TypeError('Group must be a python str')
  274. if group == "":
  275. if context.get_context("device_target") == "Ascend":
  276. group = _DEFAULT_HCCL_FUSION_GROUP_NAME
  277. else:
  278. group = _DEFAULT_NCCL_FUSION_GROUP_NAME
  279. return self._context_handle.get_all_reduce_fusion_split_indices(group)
  280. def set_all_reduce_fusion_split_sizes(self, sizes, group=""):
  281. """
  282. Set allreduce fusion strategy by parameters data sizes.
  283. Args:
  284. sizes (list): Sizes list.
  285. group (str): The communication group of hccl/nccl.
  286. Raises:
  287. TypeError: If type of sizes item is not int.
  288. TypeError: If group is not a python str.
  289. """
  290. self.check_context_handle()
  291. if isinstance(sizes, (list)):
  292. for size in sizes:
  293. if not isinstance(size, int):
  294. raise TypeError('sizes has invalid value')
  295. else:
  296. raise TypeError('sizes must be a python list')
  297. if isinstance(group, (str)):
  298. group_len = len(group)
  299. if group_len > _MAX_GROUP_NAME_LEN:
  300. raise ValueError('Group name len is out of range {_MAX_GROUP_NAME_LEN}')
  301. else:
  302. raise TypeError('Group must be a python str')
  303. if group == "":
  304. if context.get_context("device_target") == "Ascend":
  305. group = _DEFAULT_HCCL_FUSION_GROUP_NAME
  306. else:
  307. group = _DEFAULT_NCCL_FUSION_GROUP_NAME
  308. self._context_handle.set_all_reduce_fusion_split_sizes(sizes, group)
  309. if context.get_context("device_target") == "Ascend":
  310. _set_fusion_strategy_by_size(sizes)
  311. def get_all_reduce_fusion_split_sizes(self, group=""):
  312. """
  313. Get allreduce fusion split sizes.
  314. Args:
  315. group (str): The communication group of hccl/nccl.
  316. Returns:
  317. Return split sizes list according to the group.
  318. Raises:
  319. TypeError: If group is not a python str.
  320. """
  321. self.check_context_handle()
  322. if isinstance(group, (str)):
  323. group_len = len(group)
  324. if group_len > _MAX_GROUP_NAME_LEN:
  325. raise ValueError('Group name len is out of range {_MAX_GROUP_NAME_LEN}')
  326. else:
  327. raise TypeError('Group must be a python str')
  328. if group == "":
  329. if context.get_context("device_target") == "Ascend":
  330. group = _DEFAULT_HCCL_FUSION_GROUP_NAME
  331. else:
  332. group = _DEFAULT_NCCL_FUSION_GROUP_NAME
  333. return self._context_handle.get_all_reduce_fusion_split_sizes(group)
  334. def set_enable_all_reduce_fusion(self, enable_all_reduce_fusion):
  335. """
  336. Set enable/disable all reduce fusion.
  337. Args:
  338. enable_all_reduce_fusion (bool): Enable/disable all reduce fusion.
  339. """
  340. self.check_context_handle()
  341. if not isinstance(enable_all_reduce_fusion, bool):
  342. raise TypeError('enable_all_reduce_fusion is invalid type')
  343. self._context_handle.set_enable_all_reduce_fusion(enable_all_reduce_fusion)
  344. def get_enable_all_reduce_fusion(self):
  345. """Get all reduce fusion flag."""
  346. self.check_context_handle()
  347. return self._context_handle.get_enable_all_reduce_fusion()
  348. def get_device_num_is_set(self):
  349. """Get device number is set or not."""
  350. self.check_context_handle()
  351. return self._context_handle.get_device_num_is_set()
  352. def get_global_rank_is_set(self):
  353. """Get global rank is set or not."""
  354. self.check_context_handle()
  355. return self._context_handle.get_global_rank_is_set()
  356. def set_enable_parallel_optimizer(self, enable_parallel_optimizer):
  357. """
  358. Set enable/disable parallel optimizer.
  359. Args:
  360. set_enable_parallel_optimizer (bool): Enable/disable parallel optimizer.
  361. """
  362. self.check_context_handle()
  363. if not isinstance(enable_parallel_optimizer, bool):
  364. raise TypeError('enable_parallel_optimizer is invalid type')
  365. self._context_handle.set_enable_parallel_optimizer(enable_parallel_optimizer)
  366. def get_enable_parallel_optimizer(self):
  367. """Get parallel optimizer flag."""
  368. self.check_context_handle()
  369. return self._context_handle.get_enable_parallel_optimizer()
  370. def reset(self):
  371. """Reset all settings."""
  372. self.check_context_handle()
  373. self._context_handle.reset()
  374. _auto_parallel_context = None
  375. def auto_parallel_context():
  376. """
  377. Get the global _auto_parallel_context, if it is not created, create a new one.
  378. Returns:
  379. _AutoParallelContext, the global auto parallel context.
  380. """
  381. global _auto_parallel_context
  382. if _auto_parallel_context is None:
  383. _auto_parallel_context = _AutoParallelContext()
  384. return _auto_parallel_context
  385. _set_auto_parallel_context_func_map = {
  386. "device_num": auto_parallel_context().set_device_num,
  387. "global_rank": auto_parallel_context().set_global_rank,
  388. "gradients_mean": auto_parallel_context().set_gradients_mean,
  389. "gradient_fp32_sync": auto_parallel_context().set_gradient_fp32_sync,
  390. "loss_repeated_mean": auto_parallel_context().set_loss_repeated_mean,
  391. "pipeline_stages": auto_parallel_context().set_pipeline_stages,
  392. "parallel_mode": auto_parallel_context().set_parallel_mode,
  393. "auto_parallel_search_mode": auto_parallel_context().set_strategy_search_mode,
  394. "parameter_broadcast": auto_parallel_context().set_parameter_broadcast,
  395. "strategy_ckpt_load_file": auto_parallel_context().set_strategy_ckpt_load_file,
  396. "strategy_ckpt_save_file": auto_parallel_context().set_strategy_ckpt_save_file,
  397. "full_batch": auto_parallel_context().set_full_batch,
  398. "enable_parallel_optimizer": auto_parallel_context().set_enable_parallel_optimizer,
  399. "all_reduce_fusion_config": auto_parallel_context().set_all_reduce_fusion_split_indices}
  400. _get_auto_parallel_context_func_map = {
  401. "device_num": auto_parallel_context().get_device_num,
  402. "global_rank": auto_parallel_context().get_global_rank,
  403. "gradients_mean": auto_parallel_context().get_gradients_mean,
  404. "gradient_fp32_sync": auto_parallel_context().get_gradient_fp32_sync,
  405. "loss_repeated_mean": auto_parallel_context().get_loss_repeated_mean,
  406. "pipeline_stages": auto_parallel_context().get_pipeline_stages,
  407. "parallel_mode": auto_parallel_context().get_parallel_mode,
  408. "auto_parallel_search_mode": auto_parallel_context().get_strategy_search_mode,
  409. "parameter_broadcast": auto_parallel_context().get_parameter_broadcast,
  410. "strategy_ckpt_load_file": auto_parallel_context().get_strategy_ckpt_load_file,
  411. "strategy_ckpt_save_file": auto_parallel_context().get_strategy_ckpt_save_file,
  412. "full_batch": auto_parallel_context().get_full_batch,
  413. "enable_parallel_optimizer": auto_parallel_context().get_enable_parallel_optimizer,
  414. "all_reduce_fusion_config": auto_parallel_context().get_all_reduce_fusion_split_indices}
  415. @args_type_check(device_num=int, global_rank=int, gradients_mean=bool, gradient_fp32_sync=bool,
  416. loss_repeated_mean=bool, parallel_mode=str, auto_parallel_search_mode=str,
  417. parameter_broadcast=bool, strategy_ckpt_load_file=str,
  418. strategy_ckpt_save_file=str, full_batch=bool, enable_parallel_optimizer=bool,
  419. all_reduce_fusion_config=list)
  420. def _set_auto_parallel_context(**kwargs):
  421. """
  422. Set auto parallel context.
  423. Note:
  424. Attribute name is required for setting attributes.
  425. Args:
  426. device_num (int): Available device number, the value must be in [1, 4096]. Default: 1.
  427. global_rank (int): Global rank id, the value must be in [0, 4095]. Default: 0.
  428. gradients_mean (bool): Whether to perform mean operator after all-reduce of mirror. Default: False.
  429. loss_repeated_mean (bool): Whether to perform mean operator in backward in the case of repeated
  430. calculations. Default: True.
  431. gradient_fp32_sync (bool): Gradients allreduce by fp32 even though gradients is fp16 if this flag is True.
  432. Default: True.
  433. parallel_mode (str): There are five kinds of parallel modes, "stand_alone", "data_parallel",
  434. "hybrid_parallel", "semi_auto_parallel" and "auto_parallel". Default: "stand_alone".
  435. - stand_alone: Only one processor working.
  436. - data_parallel: Distributing the data across different processors.
  437. - hybrid_parallel: Achieving data parallelism and model parallelism manually.
  438. - semi_auto_parallel: Achieving data parallelism and model parallelism by
  439. setting parallel strategies.
  440. - auto_parallel: Achieving parallelism automatically.
  441. auto_parallel_search_mode (str): There are two kinds of search modes, "recursive_programming"
  442. and "dynamic_programming". Default: "dynamic_programming".
  443. - recursive_programming: Recursive programming search mode.
  444. - dynamic_programming: Dynamic programming search mode.
  445. parameter_broadcast (bool): Indicating whether to broadcast parameters before training.
  446. "stand_alone", "semi_auto_parallel" and "auto_parallel" do not support parameter
  447. broadcast. Default: False.
  448. strategy_ckpt_load_file (str): The path to load parallel strategy checkpoint. Default: ''
  449. strategy_ckpt_save_file (str): The path to save parallel strategy checkpoint. Default: ''
  450. full_batch (bool): Whether to load the whole batch on each device. Default: False.
  451. enable_parallel_optimizer (bool): Enable using optimizer segmentation or not. Default: False.
  452. all_reduce_fusion_config (list): Set allreduce fusion strategy by parameters indices.
  453. pipeline_stages (int): Set the stage information for pipeline parallel. This indicates how
  454. the devices are distributed alone the pipeline. The total devices will be divided into
  455. 'pipeline_stags' stages. This currently could only be used when
  456. parall mode semi_auto_parallel is enabled. Default: 0
  457. Raises:
  458. ValueError: If input key is not attribute in auto parallel context.
  459. """
  460. for key, value in kwargs.items():
  461. if key not in _set_auto_parallel_context_func_map:
  462. raise ValueError("Set context keyword %s is not recognized!" % key)
  463. set_func = _set_auto_parallel_context_func_map[key]
  464. set_func(value)
  465. def _get_auto_parallel_context(attr_key):
  466. """
  467. Get auto parallel context attribute value according to the key.
  468. Args:
  469. attr_key (str): The key of the attribute.
  470. Returns:
  471. Return attribute value according to the key.
  472. Raises:
  473. ValueError: If input key is not attribute in auto parallel context.
  474. """
  475. if attr_key not in _get_auto_parallel_context_func_map:
  476. raise ValueError("Get context keyword %s is not recognized!" % attr_key)
  477. get_func = _get_auto_parallel_context_func_map[attr_key]
  478. return get_func()
  479. def _reset_auto_parallel_context():
  480. """
  481. Reset auto parallel context attributes to the default values:
  482. - device_num: 1.
  483. - global_rank: 0.
  484. - gradients_mean: False.
  485. - gradient_fp32_sync: True.
  486. - parallel_mode: "stand_alone".
  487. - parameter_broadcast: False.
  488. - strategy_ckpt_load_file: ""
  489. - strategy_ckpt_save_file: ""
  490. - enable_parallel_optimizer: False
  491. - auto_parallel_search_mode: dynamic_programming
  492. - pipeline_stages: 0
  493. """
  494. auto_parallel_context().reset()