已合并
算子黑名单批量删除 #6180
AtomGit-Bot创建于 2024年3月19日
算子黑名单批量删除 #6180
已合并
从refs/pull/6180/head合入到master
共 18 个文件变更+0-44
| @@ -631,7 +631,4 @@ def get_pytorch_val_loader(data_path, batch_size, workers=5, _worker_init_fn=Non | |||
| 631 | 631 | ||
| 632 | 632 | ||
| 633 | if __name__ == '__main__': | 633 | if __name__ == '__main__': |
| 634 | - option = {} | ||
| 635 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = "BNTrainingUpdate" | ||
| 636 | - torch.npu.set_option(option) | ||
| 637 | main() | 634 | main() |
| @@ -35,9 +35,6 @@ from mmocr.utils import (collect_env, get_root_logger, is_2dlist, | |||
| 35 | import torch_npu | 35 | import torch_npu |
| 36 | from torch_npu.contrib import transfer_to_npu | 36 | from torch_npu.contrib import transfer_to_npu |
| 37 | 37 | ||
| 38 | -option = {} | ||
| 39 | -option["NPU_FUZZY_COMPILE_BLACKLIST"] = "MaskedFill" | ||
| 40 | -torch.npu.set_option(option) | ||
| 41 | torch.npu.set_compile_mode(jit_compile=False) | 38 | torch.npu.set_compile_mode(jit_compile=False) |
| 42 | 39 | ||
| 43 | 40 | ||
| @@ -199,8 +199,6 @@ if __name__ == "__main__": | |||
| 199 | option = {'ACL_PRECISION_MODE': 'allow_fp32_to_fp16'} | 199 | option = {'ACL_PRECISION_MODE': 'allow_fp32_to_fp16'} |
| 200 | if os.getenv('ALLOW_HF32', False): | 200 | if os.getenv('ALLOW_HF32', False): |
| 201 | option = {'ACL_PRECISION_MODE': 'must_keep_origin_dtype'} | 201 | option = {'ACL_PRECISION_MODE': 'must_keep_origin_dtype'} |
| 202 | - # LogSoftmaxV2算子在二进制下有精度问题,添加至黑名单规避 | ||
| 203 | - option['NPU_FUZZY_COMPILE_BLACKLIST'] = 'LogSoftmaxV2' | ||
| 204 | torch_npu.npu.set_option(option) | 202 | torch_npu.npu.set_option(option) |
| 205 | 203 | ||
| 206 | launch( | 204 | launch( |
| @@ -313,9 +313,6 @@ if __name__ == '__main__': | |||
| 313 | print(opt) | 313 | print(opt) |
| 314 | 314 | ||
| 315 | torch.npu.set_compile_mode(jit_compile=False) | 315 | torch.npu.set_compile_mode(jit_compile=False) |
| 316 | - option = dict() | ||
| 317 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = "Identity" | ||
| 318 | - torch.npu.set_option(option) | ||
| 319 | if opt.task in ['val', 'test']: # run normally | 316 | if opt.task in ['val', 'test']: # run normally |
| 320 | test(opt.data, | 317 | test(opt.data, |
| 321 | opt.weights, | 318 | opt.weights, |
| @@ -34,9 +34,6 @@ import deepspeed_npu | |||
| 34 | from torch_npu.contrib import transfer_to_npu | 34 | from torch_npu.contrib import transfer_to_npu |
| 35 | 35 | ||
| 36 | torch.npu.set_compile_mode(jit_compile=True) | 36 | torch.npu.set_compile_mode(jit_compile=True) |
| 37 | -option = {"NPU_FUZZY_COMPILE_BLACKLIST":"Tril,LayerNormGrad"} | ||
| 38 | -torch.npu.set_option(option) | ||
| 39 | - | ||
| 40 | 37 | ||
| 41 | import transformers | 38 | import transformers |
| 42 | from transformers import ( | 39 | from transformers import ( |
| @@ -76,8 +76,6 @@ def main(): | |||
| 76 | model_args, data_args, training_args = parser.parse_args_into_dataclasses() | 76 | model_args, data_args, training_args = parser.parse_args_into_dataclasses() |
| 77 | if training_args.do_train: | 77 | if training_args.do_train: |
| 78 | torch.npu.set_compile_mode(jit_compile=True) | 78 | torch.npu.set_compile_mode(jit_compile=True) |
| 79 | - option = {"NPU_FUZZY_COMPILE_BLACKLIST": "Tril,LayerNormGrad"} | ||
| 80 | - torch.npu.set_option(option) | ||
| 81 | 79 | ||
| 82 | if training_args.do_predict: | 80 | if training_args.do_predict: |
| 83 | training_args.local_rank = -1 | 81 | training_args.local_rank = -1 |
| @@ -28,8 +28,6 @@ if __name__ == "__main__": | |||
| 28 | 28 | ||
| 29 | use_jit_compile = os.getenv('JIT_COMPILE', 'False').lower() in ['true', '1'] | 29 | use_jit_compile = os.getenv('JIT_COMPILE', 'False').lower() in ['true', '1'] |
| 30 | torch.npu.set_compile_mode(jit_compile=use_jit_compile) | 30 | torch.npu.set_compile_mode(jit_compile=use_jit_compile) |
| 31 | - option = {"NPU_FUZZY_COMPILE_BLACKLIST": "Tril,SoftmaxV2,LayerNormGrad", "MM_BMM_ND_ENABLE": 'enable'} | ||
| 32 | - torch.npu.set_option(option) | ||
| 33 | neox_args = NeoXArgs.consume_neox_args() | 31 | neox_args = NeoXArgs.consume_neox_args() |
| 34 | neox_args.configure_distributed_args() | 32 | neox_args.configure_distributed_args() |
| 35 | neox_args.build_tokenizer() # tokenizer needs to be build in training in order to set the padding vocab | 33 | neox_args.build_tokenizer() # tokenizer needs to be build in training in order to set the padding vocab |
| @@ -60,7 +60,6 @@ def _main(args, output_file): | |||
| 60 | option={} | 60 | option={} |
| 61 | option['ACL_OP_SELECT_IMPL_MODE'] = 'high_performance' | 61 | option['ACL_OP_SELECT_IMPL_MODE'] = 'high_performance' |
| 62 | option['ACL_OPTYPELIST_FOR_IMPLMODE'] = 'LayerNorm' | 62 | option['ACL_OPTYPELIST_FOR_IMPLMODE'] = 'LayerNorm' |
| 63 | - option['NPU_FUZZY_COMPILE_BLACKLIST'] = 'MultiHeadAttention,MultiHeadAttentionGrad' | ||
| 64 | torch.npu.set_option(option) | 63 | torch.npu.set_option(option) |
| 65 | utils.import_user_module(args) | 64 | utils.import_user_module(args) |
| 66 | 65 | ||
| @@ -61,7 +61,6 @@ def main(args): | |||
| 61 | option = {} | 61 | option = {} |
| 62 | option['ACL_OP_SELECT_IMPL_MODE'] = 'high_performance' | 62 | option['ACL_OP_SELECT_IMPL_MODE'] = 'high_performance' |
| 63 | option['ACL_OPTYPELIST_FOR_IMPLMODE'] = 'LayerNorm' | 63 | option['ACL_OPTYPELIST_FOR_IMPLMODE'] = 'LayerNorm' |
| 64 | - option['NPU_FUZZY_COMPILE_BLACKLIST'] = 'MultiHeadAttention,MultiHeadAttentionGrad' | ||
| 65 | torch.npu.set_option(option) | 64 | torch.npu.set_option(option) |
| 66 | if args.distributed_world_size == 1: | 65 | if args.distributed_world_size == 1: |
| 67 | torch.npu.set_device('npu:{}'.format(args.npu_id)) | 66 | torch.npu.set_device('npu:{}'.format(args.npu_id)) |
| @@ -76,8 +76,6 @@ elif os.getenv('ALLOW_FP32', False): | |||
| 76 | torch.npu.matmul.allow_hf32 = False | 76 | torch.npu.matmul.allow_hf32 = False |
| 77 | torch.npu.set_compile_mode(jit_compile=False) | 77 | torch.npu.set_compile_mode(jit_compile=False) |
| 78 | option = {} | 78 | option = {} |
| 79 | -# 二进制场景下,这三个算子前后存在大量aicpu上的transdata,性能较差;加入黑名单后性能提升明显 | ||
| 80 | -option["NPU_FUZZY_COMPILE_BLACKLIST"] = "Conv2DBackpropFilter,Conv2DBackpropInput,Conv2D" | ||
| 81 | option["MM_BMM_ND_ENABLE"] = 'disable' | 79 | option["MM_BMM_ND_ENABLE"] = 'disable' |
| 82 | torch.npu.set_option(option) | 80 | torch.npu.set_option(option) |
| 83 | 81 | ||
| @@ -84,7 +84,6 @@ elif os.getenv('ALLOW_FP32', False): | |||
| 84 | torch.npu.matmul.allow_hf32 = False | 84 | torch.npu.matmul.allow_hf32 = False |
| 85 | torch.npu.set_compile_mode(jit_compile=False) | 85 | torch.npu.set_compile_mode(jit_compile=False) |
| 86 | option = {} | 86 | option = {} |
| 87 | -option["NPU_FUZZY_COMPILE_BLACKLIST"] = "Conv2DBackpropFilter,Conv2DBackpropInput,Conv2D" | ||
| 88 | option["MM_BMM_ND_ENABLE"] = 'disable' | 87 | option["MM_BMM_ND_ENABLE"] = 'disable' |
| 89 | torch.npu.set_option(option) | 88 | torch.npu.set_option(option) |
| 90 | 89 | ||
| @@ -191,7 +191,6 @@ if __name__ == "__main__": | |||
| 191 | torch_npu.npu.set_compile_mode(jit_compile=False) | 191 | torch_npu.npu.set_compile_mode(jit_compile=False) |
| 192 | # TODO: DynamicGRUV2 now not support fp32 | 192 | # TODO: DynamicGRUV2 now not support fp32 |
| 193 | option = {} | 193 | option = {} |
| 194 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = "DynamicGRUV2" | ||
| 195 | option["ACL_PRECISION_MODE"] = "allow_fp32_to_fp16" | 194 | option["ACL_PRECISION_MODE"] = "allow_fp32_to_fp16" |
| 196 | torch.npu.set_option(option) | 195 | torch.npu.set_option(option) |
| 197 | main(sys.argv[1:]) | 196 | main(sys.argv[1:]) |
| @@ -601,7 +601,4 @@ def load_tensor(name, device): | |||
| 601 | 601 | ||
| 602 | if __name__ == '__main__': | 602 | if __name__ == '__main__': |
| 603 | torch.npu.set_compile_mode(jit_compile=False) | 603 | torch.npu.set_compile_mode(jit_compile=False) |
| 604 | - option = {} | ||
| 605 | - option['NPU_FUZZY_COMPILE_BLACKLIST'] = 'DynamicRNN,DynamicRNNV2' | ||
| 606 | - torch.npu.set_option(option) | ||
| 607 | main() | 604 | main() |
| @@ -496,8 +496,4 @@ def main(): | |||
| 496 | 496 | ||
| 497 | 497 | ||
| 498 | if __name__ == "__main__": | 498 | if __name__ == "__main__": |
| 499 | - option = {} | ||
| 500 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = '''BNTrainingReduce,BNTrainingReduceGrad, | ||
| 501 | - BNTrainingUpdate,BNTrainingUpdateGrad''' | ||
| 502 | - torch.npu.set_option(option) | ||
| 503 | main() | 499 | main() |
| @@ -215,7 +215,4 @@ def main(): | |||
| 215 | 215 | ||
| 216 | 216 | ||
| 217 | if __name__ == '__main__': | 217 | if __name__ == '__main__': |
| 218 | - option = {} | ||
| 219 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = "BatchMultiClassNonMaxSuppression" | ||
| 220 | - torch.npu.set_option(option) | ||
| 221 | main() | 218 | main() |
| @@ -197,7 +197,4 @@ def main(): | |||
| 197 | 197 | ||
| 198 | if __name__ == '__main__': | 198 | if __name__ == '__main__': |
| 199 | torch_npu.npu.set_compile_mode(jit_compile=False) | 199 | torch_npu.npu.set_compile_mode(jit_compile=False) |
| 200 | - option = {} | ||
| 201 | - option["NPU_FUZZY_COMPILE_BLACKLIST"] = "BatchMultiClassNonMaxSuppression" | ||
| 202 | - torch.npu.set_option(option) | ||
| 203 | main() | 200 | main() |
| @@ -82,9 +82,6 @@ import os | |||
| 82 | import apex | 82 | import apex |
| 83 | #模糊编译 | 83 | #模糊编译 |
| 84 | torch.npu.set_start_fuzz_compile_step(3) | 84 | torch.npu.set_start_fuzz_compile_step(3) |
| 85 | -option = {} | ||
| 86 | -option["NPU_FUZZY_COMPILE_BLACKLIST"] = "LayerNormGrad" | ||
| 87 | -torch.npu.set_option(option) | ||
| 88 | try: | 85 | try: |
| 89 | from apex import amp | 86 | from apex import amp |
| 90 | except: | 87 | except: |
| @@ -54,10 +54,6 @@ from detectron2.evaluation import ( | |||
| 54 | verify_results, | 54 | verify_results, |
| 55 | ) | 55 | ) |
| 56 | from detectron2.modeling import GeneralizedRCNNWithTTA | 56 | from detectron2.modeling import GeneralizedRCNNWithTTA |
| 57 | -#算子黑名单 | ||
| 58 | -option = {} | ||
| 59 | -option["NPU_FUZZY_COMPILE_BLACKLIST"] = "NMSWithMask,BatchMultiClassNonMaxSuppression,AxpyV2" | ||
| 60 | -torch.npu.set_option(option) | ||
| 61 | class Trainer(DefaultTrainer): | 57 | class Trainer(DefaultTrainer): |
| 62 | """ | 58 | """ |
| 63 | We use the "DefaultTrainer" which contains pre-defined default logic for | 59 | We use the "DefaultTrainer" which contains pre-defined default logic for |