Skip to content

Commit

Permalink
fix tcp port in model_service_worker.py (#2377)
Browse files Browse the repository at this point in the history
* fix tcp port in model_service_worker.py

* update torchrun parameter name

* fmt
  • Loading branch information
lxning authored Jun 1, 2023
1 parent c685b5c commit a81fc52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ public static class TorchRun {
private String rdzvEndpoint;
private String rdzvBackend = "c10d";
private String rdzvConf;
private int maxRestarts = 3;
private int monitorInterval = 5;
private int nodeRank;
private String masterAddr;
Expand Down Expand Up @@ -388,13 +387,6 @@ public static TorchRun build(Map<?, ?> torchRunMap) {
logger.warn("Invalid torchrun.rdzv-conf:{}", v);
}
break;
case "max-restarts":
if (v instanceof Integer) {
torchRun.setMaxRestarts((Integer) v);
} else {
logger.warn("Invalid torchrun.max-restarts:{}, reset to 3", v);
}
break;
case "monitor-interval":
if (v instanceof Integer) {
torchRun.setMonitorInterval((Integer) v);
Expand All @@ -417,6 +409,7 @@ public static TorchRun build(Map<?, ?> torchRunMap) {
}
break;
default:
logger.warn("unsupported parameter {}", k);
break;
}
});
Expand Down Expand Up @@ -479,18 +472,6 @@ public void setRdzvConf(String rdzvConf) {
this.rdzvConf = rdzvConf;
}

public int getMaxRestarts() {
return maxRestarts;
}

public void setMaxRestarts(int maxRestarts) {
if (maxRestarts <= 0) {
logger.warn("Invalid torchrun.max-restarts:{}, reset to 3", maxRestarts);
return;
}
this.maxRestarts = maxRestarts;
}

public int getMonitorInterval() {
return monitorInterval;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,17 @@ private void attachRunner(
argl.add("torchrun");
argl.add("--nnodes");
argl.add(String.valueOf(torchRun.getNnodes()));
argl.add("--nproc_per_node");
argl.add("--nproc-per-node");
argl.add(String.valueOf(torchRun.getNprocPerNode()));
argl.add("--max_restarts");
argl.add(String.valueOf(torchRun.getMaxRestarts()));
argl.add("--log_dir");
argl.add("--log-dir");
argl.add(ConfigManager.getInstance().getTorchRunLogDir());
argl.add("--rdzv_backend");
argl.add("--rdzv-backend");
argl.add(torchRun.getRdzvBackend());
argl.add("--rdzv_endpoint");
if (torchRun.getRdzvEndpoint() != null) {
argl.add("--rdzv-endpoint");
argl.add(torchRun.getRdzvEndpoint());
} else {
argl.add(String.format("localhost:%d", port));
}
argl.add("--rdzv_id");
argl.add("--rdzv-id");
argl.add(String.format("%s_%d", model.getModelName(), port));
if (torchRun.getMasterAddr() != null) {
argl.add("--master-addr");
Expand Down
6 changes: 3 additions & 3 deletions ts/model_service_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ def __init__(
raise RuntimeError(
"socket already in use: {}.".format(s_name_new)
) from e

logging.info("Listening on port: %s", s_name_new)
elif s_type == "tcp":
self.sock_name = host_addr if host_addr is not None else "127.0.0.1"
if port_num is None:
raise ValueError("Wrong arguments passed. No socket port given.")
self.port = port_num + LOCAL_RANK
self.port = int(port_num) + LOCAL_RANK
logging.info("Listening on addr:port: %s:%d", self.sock_name, self.port)
else:
raise ValueError("Incomplete data provided")

logging.info("Listening on port: %s", s_name)
socket_family = socket.AF_INET if s_type == "tcp" else socket.AF_UNIX
self.sock = socket.socket(socket_family, socket.SOCK_STREAM)
self.metrics_cache = MetricsCacheYamlImpl(config_file_path=metrics_config)
Expand Down

0 comments on commit a81fc52

Please sign in to comment.