Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in origin dtype mode, add lisence #24

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .paddleapex.api_tracer import Tracer

__all__ = [Tracer]
Binary file modified doc/multi-end-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions paddleapex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .api_tracer import Tracer

__all__ = ["Tracer"]
14 changes: 13 additions & 1 deletion paddleapex/apex/acc_direct_cmp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# 进行比对及结果展示
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import csv
import argparse
Expand Down
14 changes: 14 additions & 0 deletions paddleapex/apex/acc_multi_cmp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
import sys
Expand Down
13 changes: 13 additions & 0 deletions paddleapex/apex/compare_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
16 changes: 15 additions & 1 deletion paddleapex/apex/compare_utils/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# 定义比对算法及比对标准
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
import paddle
import numpy as np
from compare_utils.compare_utils import CompareConst
Expand Down
16 changes: 15 additions & 1 deletion paddleapex/apex/compare_utils/compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# 进行比对及结果展示
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
import os
import csv
import paddle
Expand Down
15 changes: 15 additions & 0 deletions paddleapex/apex/compare_utils/compare_column.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
from compare_utils.compare_utils import CompareConst


Expand Down
13 changes: 13 additions & 0 deletions paddleapex/apex/compare_utils/compare_dependency.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import os
import stat
Expand Down
13 changes: 13 additions & 0 deletions paddleapex/apex/compare_utils/compare_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import time
import os
import numpy as np
Expand Down
15 changes: 15 additions & 0 deletions paddleapex/apex/framework_cmp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
15 changes: 15 additions & 0 deletions paddleapex/apex/framework_cmp/json_transfer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
"""
This script is used to transfer the json file from paddle format to torch format.
"""
Expand Down
16 changes: 15 additions & 1 deletion paddleapex/apex/framework_cmp/remove_repeat_dict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# 原地删除dump json中相同dtype、相同shape的api信息。
"""
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
import json
import copy
import argparse
Expand Down
14 changes: 13 additions & 1 deletion paddleapex/apex/mem_cmp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# 进行比对及结果展示
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import csv
import re
Expand Down
14 changes: 13 additions & 1 deletion paddleapex/apex/prof_cmp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# 进行比对及结果展示
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import csv
import re
Expand Down
50 changes: 33 additions & 17 deletions paddleapex/apex/run_paddle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
import shutil
Expand Down Expand Up @@ -42,7 +56,6 @@
}
PROFILE_RUN_TIMES = 100


def recursive_delete_arg(arg_in):
if isinstance(arg_in, (list, tuple)):
for item in arg_in:
Expand Down Expand Up @@ -180,6 +193,7 @@ def ut_case_parsing(forward_content, cfg):
multi_dtype_ut = cfg.multi_dtype_ut.split(",") if cfg.multi_dtype_ut else []
debug_case = cfg.test_case_name.split(",") if cfg.test_case_name else []
debug_mode = False
paddle.set_device(cfg.backend)
if len(debug_case) > 0:
debug_mode = True
enforce_types = [type_map[item] for item in multi_dtype_ut]
Expand Down Expand Up @@ -334,15 +348,14 @@ def run_profile_case(
):
print(f"Running {api_call_name} profile test!")
api_info_dict_copy = copy.deepcopy(api_info_dict)
device_args, device_kwargs, _ = create_input_args(
device_args, device_kwargs, need_backward = create_input_args(
api_info_dict_copy, backend, enforce_dtype, real_data_path
)
if api_call_name in debug_case:
x = [device_args, device_kwargs]
out_path = os.path.realpath(out_path) if out_path else "./"
save_pth = os.path.join(out_path, "input_data", api_call_name)
paddle.save(x, save_pth)

# device warmming up
try:
device_out = run_forward(api_call_name, device_args, device_kwargs)
Expand All @@ -367,20 +380,24 @@ def profile_inner_loop_():
paddle.device.synchronize()
fwd_end_time = time.time()
fwd_time = fwd_end_time - fwd_start_time
fwd_time = fwd_time * 1000000 # fwd_time is in us
fwd_time = fwd_time * 1000000 / float(PROFILE_RUN_TIMES) # fwd_time is in us
except Exception as err:
msg = "Run_forward Error: %s" % str(err)
print_warn_log(msg)
return -1, -1
try:
if not need_backward:
return fwd_time, -1
paddle.device.synchronize()
bwd_start_time = time.time()
for _ in range(PROFILE_RUN_TIMES):
paddle.autograd.backward([device_out], dout, retain_graph=True)
device_out = run_forward(api_call_name, device_args, device_kwargs)
paddle.autograd.backward([device_out], dout)
paddle.device.synchronize()
bwd_end_time = time.time()
bwd_time = bwd_end_time - bwd_start_time # bwd_time is in second
bwd_time = bwd_time * 1000000 # bwd_time is in us
bwd_time = bwd_time * 1000000 / float(PROFILE_RUN_TIMES) # bwd_time is in us
bwd_time = bwd_time - fwd_time
except Exception as err:
msg = "Run_backward Error: %s" % str(err)
print_warn_log(msg)
Expand All @@ -397,16 +414,14 @@ def profile_inner_loop_():
log_path = os.path.join(out_path, "profile_analyze.log")

F = open(log_path, "a")
if enforce_dtype:
op_fwd = api_call_name + "*" + enforce_dtype.name + ".forward"
op_bwd = api_call_name + "*" + enforce_dtype.name + ".backward"
else:
op_fwd = api_call_name + ".forward"
op_bwd = api_call_name + ".backward"
print_info_log(f"{op_fwd}:\t{fwd_time/float(PROFILE_RUN_TIMES)}")
print_info_log(f"{op_bwd}:\t{bwd_time/float(PROFILE_RUN_TIMES)}")
msg_fwd = f"{api_call_name}.forward\tdtype\t{enforce_dtype.name}\tinput shape\t{input_shape_lst}\toutput shape\t{output_shape_lst}\tforward\t{fwd_time/float(PROFILE_RUN_TIMES)}"
msg_bwd = f"{api_call_name}.backward\tdtype\t{enforce_dtype.name}\tinput shape\t{input_shape_lst}\toutput shape\t{output_shape_lst}\tbackward\t{bwd_time/float(PROFILE_RUN_TIMES)}"
dtype = "" if not enforce_dtype else f"*{enforce_dtype.name}"
op_fwd = api_call_name + dtype + ".forward"
op_bwd = api_call_name + dtype + ".backward"
print_info_log(f"{op_fwd}:\t{fwd_time}")
print_info_log(f"{op_bwd}:\t{bwd_time}")
dtype = "\t" if not enforce_dtype else f"\t{enforce_dtype.name}"
msg_fwd = f"{api_call_name}.forward\tdtype{dtype}\tinput shape\t{input_shape_lst}\toutput shape\t{output_shape_lst}\tforward\t{fwd_time}"
msg_bwd = f"{api_call_name}.backward\tdtype{dtype}\tinput shape\t{input_shape_lst}\toutput shape\t{output_shape_lst}\tbackward\t{bwd_time}"

F.write(msg_fwd + "\n")
F.write(msg_bwd + "\n")
Expand Down Expand Up @@ -449,7 +464,8 @@ def run_mem_case(
log_path = os.path.join(out_path, "memory_analyze.log")
os.mkdir(out_path) if not os.path.exists(out_path) else None
F = open(log_path, "a")
op_name = api_call_name + "*" + enforce_dtype.name + ".forward"
dtype = "" if not enforce_dtype else f"*{enforce_dtype.name}"
op_name = api_call_name + dtype + ".forward"
F.write(f"{op_name}:\t{str(activation_cost)}\n")
F.close()
return
Expand Down
Loading