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

remove invalid warning log #2867

Merged
merged 8 commits into from
Jan 23, 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
10 changes: 3 additions & 7 deletions frontend/server/src/main/java/org/pytorch/serve/ModelServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.pytorch.serve.archive.model.ModelNotFoundException;
import org.pytorch.serve.grpcimpl.GRPCInterceptor;
import org.pytorch.serve.grpcimpl.GRPCServiceFactory;
import org.pytorch.serve.http.messages.RegisterModelRequest;
import org.pytorch.serve.metrics.MetricCache;
import org.pytorch.serve.metrics.MetricManager;
import org.pytorch.serve.servingsdk.ModelServerEndpoint;
Expand Down Expand Up @@ -214,11 +215,6 @@ private void initModelStore() throws InvalidSnapshotException, IOException {
if (marMinWorkers > 0 && marMaxWorkers >= marMinWorkers) {
minWorkers = marMinWorkers;
maxWorkers = marMaxWorkers;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If someone gives faulty values like 0, -1 etc, shouldn't we have a warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for checking

logger.warn(
"Invalid model config in mar, minWorkers:{}, maxWorkers:{}",
marMinWorkers,
marMaxWorkers);
}
}
modelManager.updateModel(
Expand Down Expand Up @@ -266,8 +262,8 @@ private void initModelStore() throws InvalidSnapshotException, IOException {
modelName,
null,
null,
1,
100,
-1 * RegisterModelRequest.DEFAULT_BATCH_SIZE,
-1 * RegisterModelRequest.DEFAULT_MAX_BATCH_DELAY,
configManager.getDefaultResponseTimeout(),
defaultModelName,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public RegisterModelRequest(QueryStringDecoder decoder) {
"initial_workers",
ConfigManager.getInstance().getConfiguredDefaultWorkersPerModel());
synchronous = Boolean.parseBoolean(NettyUtils.getParameter(decoder, "synchronous", "true"));
responseTimeout =
NettyUtils.getIntParameter(decoder, "response_timeout", -1 * DEFAULT_BATCH_SIZE);
responseTimeout = NettyUtils.getIntParameter(decoder, "response_timeout", -1);
modelUrl = NettyUtils.getParameter(decoder, "url", null);
s3SseKms = Boolean.parseBoolean(NettyUtils.getParameter(decoder, "s3_sse_kms", "false"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public ModelArchive registerModel(String url, String defaultModelName)
null,
null,
null,
1,
100,
-1 * RegisterModelRequest.DEFAULT_BATCH_SIZE,
-1 * RegisterModelRequest.DEFAULT_MAX_BATCH_DELAY,
configManager.getDefaultResponseTimeout(),
defaultModelName,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ public void run() {
logger.debug("Shutting down the thread .. Scaling down.");
} else {
logger.debug(
"Backend worker monitoring thread interrupted or backend worker process died.",
"Backend worker monitoring thread interrupted or backend worker process died., responseTimeout:"
+ responseTimeout
+ "sec",
e);
}
} catch (WorkerInitializationException e) {
Expand Down Expand Up @@ -586,7 +588,8 @@ public void channelRead0(ChannelHandlerContext ctx, ModelWorkerResponse msg) {
try {
replies.offer(msg, responseTimeout, TimeUnit.SECONDS);
} catch (InterruptedException | NullPointerException e) {
logger.error("Failed to offer reply", e);
logger.error(
"Failed to offer reply, responseTimeout:" + responseTimeout + "sec", e);
throw new IllegalStateException("Reply queue is full.");
}
}
Expand Down
38 changes: 16 additions & 22 deletions test/pytest/test_model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,48 +96,42 @@ def create_mar_file(work_dir, model_archiver, model_name):
mar_file_path.unlink(missing_ok=True)


def register_model(mar_file_path, model_store, params, torchserve):
@pytest.fixture(scope="module", name="base_model_name")
def register_model(mar_file_path, model_store, torchserve):
shutil.copy(mar_file_path, model_store)

file_name = Path(mar_file_path).name

model_name = Path(file_name).stem
base_model_name = Path(file_name).stem

params = params + (
("model_name", model_name),
params = (
("model_name", f"{base_model_name}_b4"),
("url", file_name),
("initial_workers", "2"),
("synchronous", "true"),
)

test_utils.reg_resp = test_utils.register_model_with_params(params)
return model_name


@pytest.mark.skip(reason="Flaky on Regression GPU")
def test_register_model_with_batch_size(mar_file_path, model_store, torchserve):
params = (
("model_name", f"{base_model_name}_b2"),
("url", file_name),
("initial_workers", "2"),
("synchronous", "true"),
("batch_size", "2"),
)

model_name = register_model(mar_file_path, model_store, params, torchserve)

describe_resp = test_utils.describe_model(model_name, "1.0")
test_utils.reg_resp = test_utils.register_model_with_params(params)
yield base_model_name

assert describe_resp[0]["batchSize"] == 2

test_utils.unregister_model(model_name)
def test_register_model_with_batch_size(base_model_name):
describe_resp = test_utils.describe_model(f"{base_model_name}_b2", "1.0")

assert describe_resp[0]["batchSize"] == 2

def test_register_model_without_batch_size(mar_file_path, model_store, torchserve):
params = (
("initial_workers", "2"),
("synchronous", "true"),
)
model_name = register_model(mar_file_path, model_store, params, torchserve)

describe_resp = test_utils.describe_model(model_name, "1.0")
def test_register_model_without_batch_size(base_model_name):
describe_resp = test_utils.describe_model(f"{base_model_name}_b4", "1.0")

assert describe_resp[0]["batchSize"] == 4

test_utils.unregister_model(model_name)