CRZbulabula commented on code in PR #16131: URL: https://github.com/apache/iotdb/pull/16131#discussion_r2278263729
########## iotdb-core/ainode/ainode/core/inference/pool_scheduler.py: ########## @@ -0,0 +1,125 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +import threading + +import torch +import torch.multiprocessing as mp + +from ainode.core.exception import ( + InferenceModelInternalError, +) +from ainode.core.inference.inference_request_pool import InferenceRequestPool, PoolState +from ainode.core.inference.pool_manager import PoolManager +from ainode.core.log import Logger +from ainode.core.manager.utils import ( + _estimate_pool_size, +) +from ainode.core.model.sundial.configuration_sundial import SundialConfig +from ainode.core.model.timerxl.configuration_timer import TimerConfig +from ainode.core.util.decorator import synchronized + +logger = Logger() + + +class PoolScheduler: + """ + A Scheduler to init the request pools. + It initializes the first pool and starts a background thread to expand pools + as needed based on the model_id. + """ + + DEFAULT_DEVICE = torch.device("cpu") + # DEFAULT_DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") + + def __init__(self, pool_manager: PoolManager, result_queue: mp.Queue): + self._pool_manager = pool_manager + self._result_queue = result_queue + + @synchronized(threading.Lock()) Review Comment: Reconsider this comment, fix it or state ur reason for not ########## iotdb-core/ainode/ainode/core/inference/pool_scheduler.py: ########## @@ -0,0 +1,125 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +import threading + +import torch +import torch.multiprocessing as mp + +from ainode.core.exception import ( + InferenceModelInternalError, +) +from ainode.core.inference.inference_request_pool import InferenceRequestPool, PoolState +from ainode.core.inference.pool_manager import PoolManager +from ainode.core.log import Logger +from ainode.core.manager.utils import ( + _estimate_pool_size, +) +from ainode.core.model.sundial.configuration_sundial import SundialConfig +from ainode.core.model.timerxl.configuration_timer import TimerConfig +from ainode.core.util.decorator import synchronized + +logger = Logger() + + +class PoolScheduler: + """ + A Scheduler to init the request pools. + It initializes the first pool and starts a background thread to expand pools + as needed based on the model_id. + """ + + DEFAULT_DEVICE = torch.device("cpu") + # DEFAULT_DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") + + def __init__(self, pool_manager: PoolManager, result_queue: mp.Queue): + self._pool_manager = pool_manager + self._result_queue = result_queue + + @synchronized(threading.Lock()) Review Comment: Reconsider this comment, fix it or state ur reason for not -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
