Select algo according to json config (#396)

The way to run nccl-test over mscclpp:
mpirun -np 8 --bind-to numa --allow-run-as-root -x
LD_PRELOAD=$(pwd)/build/apps/nccl/libmscclpp_nccl.so -x NCCL_DEBUG=WARN
-x MSCCLPP_EXECUTION_PLAN_DIR=/execution-files
/root/nccl-tests/build/all_reduce_perf -b 1K -e 1G -f 2 -d half -G 20 -w
10 -n 20
This commit is contained in:
Binyang Li
2024-12-03 14:39:20 -08:00
committed by GitHub
parent ff18bb8d0b
commit 88d28e07a7
14 changed files with 138 additions and 126 deletions

View File

@@ -59,7 +59,7 @@ def bench_time(n_iters: int, n_graph_iters: int, func):
def bench_correctness(
execution_plan_name: str,
collective: str,
input_buf: cp.ndarray,
result_buf: cp.ndarray,
test_buf: cp.ndarray,
@@ -72,9 +72,9 @@ def bench_correctness(
type_size = cp.dtype(parse_dtype(dtype_str)).itemsize
fill_data_kernel_name = "fill_data_%s" % dtype_str
if "allgather" in execution_plan_name:
if "allgather" in collective:
coll = "all_gather"
elif "reducescatter" in execution_plan_name:
elif "reducescatter" in collective:
coll = "reduce_scatter"
else:
coll = "all_reduce"
@@ -142,7 +142,7 @@ def allocate_buffer(nelems, dtype):
def build_bufs(
execution_plan_name: str,
collective: str,
size: int,
in_place: bool,
dtype: cp.dtype,
@@ -153,7 +153,7 @@ def build_bufs(
assert (size % type_size) == 0, "size %d not multiple of type size %d" % (size, type_size)
nelems = size // type_size
if "allgather" in execution_plan_name:
if "allgather" in collective:
assert (nelems % num_ranks) == 0, "nelems %d not multiple of num_ranks %d" % (nelems, num_ranks)
nelems_input = nelems if in_place else nelems // num_ranks
else:
@@ -162,7 +162,7 @@ def build_bufs(
result_buf = allocate_buffer(nelems_output, dtype=dtype)
if in_place:
if "allgather" in execution_plan_name:
if "allgather" in collective:
input_buf = cp.split(result_buf, num_ranks)[rank]
else:
input_buf = result_buf
@@ -174,7 +174,6 @@ def build_bufs(
def main(
execution_plan_name: str,
execution_plan_path: str,
size: int,
in_place: bool = True,
@@ -189,11 +188,12 @@ def main(
npkit_dump_dir = os.getenv("NPKIT_DUMP_DIR")
if npkit_dump_dir is not None:
npkit.init(mscclpp_group.my_rank)
execution_plan = ExecutionPlan(execution_plan_name, execution_plan_path)
execution_plan = ExecutionPlan(execution_plan_path)
collective = execution_plan.collective()
dtype = parse_dtype(dtype_str)
input_buf, result_buf, test_buf = build_bufs(
execution_plan_name,
collective,
size,
in_place,
dtype,
@@ -215,7 +215,7 @@ def main(
mscclpp_group.barrier()
bench_correctness(
execution_plan_name,
collective,
input_buf,
result_buf,
test_buf,
@@ -242,7 +242,6 @@ def main(
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-n", "--execution_plan_name", type=str, required=True)
parser.add_argument("-path", "--execution_plan_path", type=str, required=True)
parser.add_argument("--size", type=str, required=True)
parser.add_argument("--in_place", action="store_true", help="flag to define an in-place operation")
@@ -258,7 +257,6 @@ if __name__ == "__main__":
buffer_size = parse_size(args.size)
main(
args.execution_plan_name,
args.execution_plan_path,
buffer_size,
args.in_place,

View File

@@ -607,7 +607,7 @@ def test_executor(mpi_group: MpiGroup, filename: str):
npkit_dump_dir = os.getenv("NPKIT_DUMP_DIR")
if npkit_dump_dir is not None:
npkit.init(mscclpp_group.my_rank)
execution_plan = ExecutionPlan("allreduce_pairs", os.path.join(project_dir, "test", "execution-files", filename))
execution_plan = ExecutionPlan(os.path.join(project_dir, "test", "execution-files", filename))
nelems = 1024 * 1024
cp.random.seed(42)