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

Warn when Config's pipeline_batch_size < model_max_batch_size #1858

Merged
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
27 changes: 25 additions & 2 deletions python/morpheus/morpheus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ class Config(ConfigBase):

mode: PipelineModes = PipelineModes.OTHER

_pipeline_batch_size: int = 256
_model_max_batch_size: int = 8
feature_length: int = 256
pipeline_batch_size: int = 256
num_threads: int = 1
model_max_batch_size: int = 8
edge_buffer_size: int = 128

# Class labels to convert class index to label.
Expand All @@ -220,6 +220,29 @@ class Config(ConfigBase):
ae: ConfigAutoEncoder = dataclasses.field(default=None)
fil: ConfigFIL = dataclasses.field(default=None)

@property
def pipeline_batch_size(self):
return self._pipeline_batch_size

@pipeline_batch_size.setter
def pipeline_batch_size(self, value: int):
self._pipeline_batch_size = value
self._validate_config()

@property
def model_max_batch_size(self):
return self._model_max_batch_size

@model_max_batch_size.setter
def model_max_batch_size(self, value: int):
self._model_max_batch_size = value
self._validate_config()

def _validate_config(self):
if self._pipeline_batch_size < self._model_max_batch_size:
logging.warning("Config has `pipeline_batch_size < model_max_batch_size` which effectively limits "
"`model_max_batch_size`. This may reduce performance.")

def save(self, filename: str):
"""
Save Config to file.
Expand Down
23 changes: 23 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
# limitations under the License.

import json
import logging
import os
from unittest import mock

import pytest

import morpheus
import morpheus.config
from _utils import assert_path_exists
Expand Down Expand Up @@ -104,3 +107,23 @@ def test_to_string(config):
conf_str = config.to_string()
assert isinstance(conf_str, str)
assert isinstance(json.loads(conf_str), dict)


def test_warning_model_batch_size_less_than_pipeline_batch_size(caplog: pytest.LogCaptureFixture):
config = morpheus.config.Config()
config.pipeline_batch_size = 256
with caplog.at_level(logging.WARNING):
config.model_max_batch_size = 257
assert len(caplog.records) == 1
import re
assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None


def test_warning_pipeline_batch_size_less_than_model_batch_size(caplog: pytest.LogCaptureFixture):
config = morpheus.config.Config()
config.model_max_batch_size = 8
with caplog.at_level(logging.WARNING):
config.pipeline_batch_size = 7
assert len(caplog.records) == 1
import re
assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None
Loading