CRZbulabula commented on code in PR #17322: URL: https://github.com/apache/iotdb/pull/17322#discussion_r2986010023
########## iotdb-core/ainode/iotdb/ainode/core/model/toto/pipeline_toto.py: ########## @@ -0,0 +1,131 @@ +# 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 logging +import warnings + +import torch + +from iotdb.ainode.core.inference.pipeline.basic_pipeline import ForecastPipeline + +from .data.util.dataset import MaskedTimeseries +from .inference.forecaster import TotoForecaster + +logger = logging.getLogger(__name__) Review Comment: Use the logger in `iotdb.ainode.core.log` ########## iotdb-core/ainode/iotdb/ainode/core/model/toto/pipeline_toto.py: ########## @@ -0,0 +1,131 @@ +# 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 logging +import warnings + +import torch + +from iotdb.ainode.core.inference.pipeline.basic_pipeline import ForecastPipeline + +from .data.util.dataset import MaskedTimeseries +from .inference.forecaster import TotoForecaster + +logger = logging.getLogger(__name__) + + +class TotoPipeline(ForecastPipeline): + """ + Inference pipeline for the Toto time series foundation model. + + Converts raw input tensors into ``MaskedTimeseries`` objects and delegates + autoregressive decoding to ``TotoForecaster``. The forecaster is created + lazily on the first call to ``forecast()`` so that pipeline construction + does not require a live model (useful during import / registration time). + """ + + def __init__(self, model_info, **model_kwargs): + super().__init__(model_info, **model_kwargs) + # Forecaster is created lazily to avoid issues at construction time. + self._forecaster: TotoForecaster | None = None + + def _get_forecaster(self) -> TotoForecaster: + """Return the cached forecaster, creating it on first call.""" + if self._forecaster is None: + self._forecaster = TotoForecaster(self.model.backbone) + return self._forecaster + + def preprocess(self, inputs, **infer_kwargs): + super().preprocess(inputs, **infer_kwargs) Review Comment: Please sync the latest codebase, we have refactored the inherit policy. ########## iotdb-core/ainode/.gitignore: ########## @@ -20,3 +20,7 @@ poetry.lock # generated by pyinstaller /dist/ /build/ + +# Un-ignore toto source data/ package (Python source, not data files) +!iotdb/ainode/core/model/toto/data/ +!iotdb/ainode/core/model/toto/data/** Review Comment: Why should modify the `.gitignore`? Seems this is unnecessary. -- 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]
