Skip to content

Commit

Permalink
[micro_perf] add task_dir in perf_engine; multiply qps with 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsouthByteDance committed Aug 19, 2024
1 parent b771543 commit 51906dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion byte_micro_perf/backends/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def dump_computation_ops_report(
batch_size, total_io_amount, read_io_amount, write_io_amount = get_io_amount(op_name, input_shapes, dtype)

if error == "":
qps = round(1000 / latency * batch_size, 2)
qps = round(1000 / latency * batch_size, 2) * 1000
algo_bw = total_io_amount / latency / 1e3

bandwidth_utils = None
Expand Down
14 changes: 9 additions & 5 deletions byte_micro_perf/core/perf_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def get_args():
default="gemm",
help="The task going to be evaluted, refs to workloads/",
)
parser.add_argument(
"--task_dir",
default=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/workloads",
help="The direcotry of tasks going to be evaluted, e.g., set to workloads"
)
parser.add_argument(
"--hardware_type",
default="GPU",
Expand All @@ -65,14 +70,14 @@ def get_args():
return args


def load_workload(task: str) -> Dict[str, Any]:
def load_workload(task: str, task_dir: str) -> Dict[str, Any]:
"""
Return a list of dictionary with model Configuration
Args: List[str]
Returns: List[dic]
"""
modules_dir = (
os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/workloads"
task_dir
)

for file in os.listdir(modules_dir):
Expand All @@ -83,8 +88,7 @@ def load_workload(task: str) -> Dict[str, Any]:
and (file.endswith(".json") or os.path.isdir(path))
and file[: file.find(".json")] == task
):
module_name = file
with open("workloads/" + module_name, "r") as f:
with open(path, "r") as f:
workload_dict = json.load(f)
return workload_dict
else:
Expand Down Expand Up @@ -189,7 +193,7 @@ class PerfEngine:
def __init__(self) -> None:
super().__init__()
self.args = get_args()
self.workload = load_workload(self.args.task)
self.workload = load_workload(self.args.task, self.args.task_dir)
self.backend_type = self.args.hardware_type
self.old_os_path = os.environ["PATH"]
self.prev_sys_path = list(sys.path)
Expand Down
4 changes: 2 additions & 2 deletions byte_micro_perf/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def parse_task(task_dir):
)

for task in tasks:
cmd = "python3 core/perf_engine.py --hardware_type {} --task {} --vendor_path {}".format(
args.hardware_type, task, args.vendor_path
cmd = "python3 core/perf_engine.py --hardware_type {} --task {} --vendor_path {} --task_dir {}".format(
args.hardware_type, task, args.vendor_path, args.task_dir
)
exit_code = subprocess.call(cmd, shell=True)

Expand Down

0 comments on commit 51906dd

Please sign in to comment.