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

Enable worker core pinning in CPU nightly benchmark #2166

Merged
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
581c362
verify setup
min-jean-cho Mar 1, 2023
df13c86
verify setup
min-jean-cho Mar 1, 2023
2fed1fa
fix
min-jean-cho Mar 2, 2023
5372e3e
build frontend
min-jean-cho Mar 2, 2023
233abd6
fix
min-jean-cho Mar 2, 2023
54d84fc
fix
min-jean-cho Mar 2, 2023
874dcea
fix
min-jean-cho Mar 2, 2023
1c9943a
fix
min-jean-cho Mar 2, 2023
f0fd731
fix
min-jean-cho Mar 2, 2023
798aa2a
log error
min-jean-cho Mar 2, 2023
998b147
update
min-jean-cho Mar 2, 2023
981cce3
update
min-jean-cho Mar 2, 2023
f49d9e0
fix
min-jean-cho Mar 2, 2023
99adfc1
update
min-jean-cho Mar 2, 2023
b911393
update
min-jean-cho Mar 2, 2023
2a8cae3
update
min-jean-cho Mar 2, 2023
4d4f127
update
min-jean-cho Mar 2, 2023
a04450d
test github action
min-jean-cho Mar 3, 2023
91e928d
test
min-jean-cho Mar 3, 2023
22c0531
verify logical core setup
min-jean-cho Mar 3, 2023
fc82e2e
run full test
min-jean-cho Mar 3, 2023
8da4f34
run full test
min-jean-cho Mar 3, 2023
61553b3
test without ht
min-jean-cho Mar 3, 2023
2009a94
run full test physical cores
min-jean-cho Mar 3, 2023
7488b0e
enable --use_logical_core in nightly benchmark
min-jean-cho Mar 6, 2023
ae5dfd4
Delete benchmark_worker_core_pinning_cpu.yml
min-jean-cho Mar 6, 2023
3cfdcbc
remove benchmark testing
min-jean-cho Mar 6, 2023
917810a
Merge branch 'minjean/enable_worker_core_pinning' of https://github.c…
min-jean-cho Mar 6, 2023
ede19e0
remove benchmark testing
min-jean-cho Mar 6, 2023
ff20976
remove benchmark testing
min-jean-cho Mar 6, 2023
e887b1b
Merge branch 'master' into minjean/enable_worker_core_pinning
msaroufim Mar 9, 2023
22454bf
Merge branch 'master' into minjean/enable_worker_core_pinning
msaroufim Mar 16, 2023
d29d629
(1) enable core pinning for nightly benchmark (2) double check setup
min-jean-cho Apr 12, 2023
60e8ce3
verify setup
min-jean-cho Apr 12, 2023
255cf39
verify setup
min-jean-cho Apr 12, 2023
06f3df8
Merge branch 'master' into minjean/enable_worker_core_pinning
min-jean-cho Apr 12, 2023
25b2be0
verify setup
min-jean-cho Apr 12, 2023
7907d71
verify setup
min-jean-cho Apr 12, 2023
7381a3a
verify setup
min-jean-cho Apr 12, 2023
67e493d
verify setup
min-jean-cho Apr 12, 2023
b3649d0
verified setup
min-jean-cho Apr 12, 2023
d090059
update
min-jean-cho Apr 12, 2023
1bed291
revert
min-jean-cho Apr 12, 2023
c0dab14
lint
min-jean-cho Apr 12, 2023
c399735
lint
min-jean-cho Apr 12, 2023
26d5c39
Merge branch 'master' into minjean/enable_worker_core_pinning
lxning Apr 13, 2023
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
2 changes: 0 additions & 2 deletions .github/workflows/benchmark_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ jobs:
pip install -r benchmarks/requirements-ab.txt
- name: Benchmark cpu nightly
if: ${{ matrix.hardware == 'cpu' }}
env:
OMP_NUM_THREADS: 1
run: python benchmarks/auto_benchmark.py --input benchmarks/benchmark_config_cpu.yaml --skip false
- name: Benchmark gpu nightly
if: ${{ matrix.hardware == 'gpu' }}
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/auto_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def report_cmd(self, cmd):

self.bm_config["report_cmd"] = " ".join(cmd_options)

def enable_launcher_with_logical_core(self):
if self.bm_config["hardware"] == "cpu":
with open("./benchmarks/config.properties", "a") as f:
f.write("cpu_launcher_enable=true\n")
f.write("cpu_launcher_args=--use_logical_core\n")

def load_config(self):
report_cmd = None
for k, v in self.yaml_dict.items():
Expand All @@ -100,6 +106,8 @@ def load_config(self):
else "{}/cpu".format(MODEL_JSON_CONFIG_PATH)
)

self.enable_launcher_with_logical_core()

if self.skip_ts_install:
self.bm_config["version"] = get_torchserve_version()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class WorkerLifeCycle {
private Connector connector;
private ReaderThread errReader;
private ReaderThread outReader;
private String launcherArgs;
private int numWorker;
private int currNumRunningWorkers;

Expand All @@ -50,10 +49,11 @@ public Process getProcess() {
return process;
}

public ArrayList<String> launcherArgsToList() {
public ArrayList<String> launcherArgsToList(String launcherArgs) {
ArrayList<String> arrlist = new ArrayList<String>();
arrlist.add("-m");
arrlist.add("intel_extension_for_pytorch.cpu.launch");
arrlist.add("torch.backends.xeon.run_cpu");

if (launcherArgs != null && launcherArgs.length() > 1) {
String[] argarray = launcherArgs.split(" ");
for (int i = 0; i < argarray.length; i++) {
Expand All @@ -63,22 +63,25 @@ public ArrayList<String> launcherArgsToList() {
return arrlist;
}

public boolean isLauncherAvailable()
public boolean isLauncherAvailable(String launcherArgs)
throws WorkerInitializationException, InterruptedException {
boolean launcherAvailable = false;
try {
ArrayList<String> cmd = new ArrayList<String>();
cmd.add("python");
ArrayList<String> args = launcherArgsToList();
cmd.addAll(args);
cmd.add("--no_python");
// try launching dummy command to check launcher availability
String dummyCmd = "hostname";
cmd.add(dummyCmd);

String[] cmdList = new String[cmd.size()];
cmdList = cmd.toArray(cmdList);

ArrayList<String> cmd = new ArrayList<String>();
cmd.add("python");
ArrayList<String> args = launcherArgsToList(launcherArgs);
cmd.addAll(args);
cmd.add("--no_python");
// try launching dummy command to check launcher availability
String dummyCmd = "hostname";
cmd.add(dummyCmd);

String[] cmdList = new String[cmd.size()];
cmdList = cmd.toArray(cmdList);

logger.debug("launcherAvailable cmdline: {}", cmd.toString());

try {
Process processLauncher = Runtime.getRuntime().exec(cmdList);
int ret = processLauncher.waitFor();
launcherAvailable = (ret == 0);
Expand Down Expand Up @@ -115,23 +118,24 @@ public void startWorker(int port, String deviceIds)
}

if (configManager.isCPULauncherEnabled()) {
launcherArgs = configManager.getCPULauncherArgs();
boolean launcherAvailable = isLauncherAvailable();
String launcherArgs = configManager.getCPULauncherArgs();
boolean launcherAvailable = isLauncherAvailable(launcherArgs);
if (launcherAvailable) {
ArrayList<String> args = launcherArgsToList();
ArrayList<String> args = launcherArgsToList(launcherArgs);
argl.addAll(args);

// multi-worker core pinning
if (this.numWorker > 1) {
argl.add("--ninstances");
argl.add(String.valueOf(this.numWorker));
argl.add("--instance_idx");
argl.add("--rank");
// instance_idx is 0-indexed
argl.add(String.valueOf(this.currNumRunningWorkers));
}

} else {
logger.warn(
"CPU launcher is enabled but launcher is not available. Proceeding without launcher.");
"torch.backends.xeon.run_cpu is not available. Proceeding without worker core pinning. For better performance, please make sure torch.backends.xeon.run_cpu is available.");
}
}

Expand Down
14 changes: 14 additions & 0 deletions ts_scripts/install_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def install_jmeter(self):
def install_wget(self):
pass

def install_numactl(self):
pass


class Linux(Common):
def __init__(self):
Expand Down Expand Up @@ -107,6 +110,10 @@ def install_libgit2(self):
os.system(f"cd libgit2-1.3.0 && cmake . && make && sudo make install && cd ..")
os.system(f"rm -rf libgit2-1.3.0 && rm libgit2-1.3.0.tar.gz")

def install_numactl(self):
if os.system("numactl --show") != 0 or args.force:
os.system(f"{self.sudo_cmd}apt-get install -y numactl")

Comment on lines +113 to +116
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need add numactl into docker container for cpu?


class Windows(Common):
def __init__(self):
Expand All @@ -122,6 +129,9 @@ def install_nodejs(self):
def install_wget(self):
pass

def install_numactl(self):
pass


class Darwin(Common):
def __init__(self):
Expand All @@ -146,6 +156,10 @@ def install_wget(self):
if os.system("wget --version") != 0 or args.force:
os.system("brew install wget")

def install_numactl(self):
if os.system("numactl --show") != 0 or args.force:
os.system("brew install numactl")


def install_dependencies(cuda_version=None, nightly=False):
os_map = {"Linux": Linux, "Windows": Windows, "Darwin": Darwin}
Expand Down