已合并
adaptor: verl support mindspeedllm #4329
pengnuoheng创建于 3月23日
adaptor: verl support mindspeedllm #4329
已合并
共 1 个文件变更+22-2
| @@ -76,7 +76,8 @@ class FeatureAdaptor: | |||
| 76 | """ | 76 | """ |
| 77 | Execute adaptations. | 77 | Execute adaptations. |
| 78 | """ | 78 | """ |
| 79 | - | 79 | + |
| 80 | + MindSpeedFeaturesManager.remove_patches() | ||
| 80 | args = FeatureAdaptor.get_mindspeed_llm_args() | 81 | args = FeatureAdaptor.get_mindspeed_llm_args() |
| 81 | FeatureAdaptor.delete_lock_file() | 82 | FeatureAdaptor.delete_lock_file() |
| 82 | 83 | ||
| @@ -88,5 +89,24 @@ class FeatureAdaptor: | |||
| 88 | # accelerate package will check TE on sys.modules, so we need remove this patch | 89 | # accelerate package will check TE on sys.modules, so we need remove this patch |
| 89 | if 'transformer_engine' in sys.modules: | 90 | if 'transformer_engine' in sys.modules: |
| 90 | del sys.modules["transformer_engine"] | 91 | del sys.modules["transformer_engine"] |
| 91 | - | 92 | + |
| 93 | + | ||
| 94 | +def repatch(config): | ||
| 95 | + LOG.info("repatch mindspeedllm features") | ||
| 96 | + MindSpeedFeaturesManager.remove_patches() | ||
| 97 | + args = FeatureAdaptor.get_mindspeed_llm_args() | ||
| 98 | + for k, v in config.items(): | ||
| 99 | + setattr(args, k, v) | ||
| 100 | + FeatureAdaptor.delete_lock_file() | ||
| 101 | + | ||
| 102 | + # apply mindspeed base patches | ||
| 103 | + MindSpeedFeaturesManager.apply_features_pre_patches(args) | ||
| 104 | + # apply megatron patches | ||
| 105 | + MindSpeedFeaturesManager.apply_features_patches(args) | ||
| 106 | + | ||
| 107 | + # accelerate package will check TE on sys.modules, so we need remove this patch | ||
| 108 | + if 'transformer_engine' in sys.modules: | ||
| 109 | + del sys.modules["transformer_engine"] | ||
| 110 | + | ||
| 111 | + | ||
| 92 | FeatureAdaptor.execute() | 112 | FeatureAdaptor.execute() |