Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
[AINode] Integrate Sundial as built-in model#15586
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f10651f
temporary
CRZbulabula b4c3427
Merge branch 'master' into hf-timerxl
CRZbulabula a20dc89
preview
CRZbulabula b0d1d8d
Update pyproject.toml
CRZbulabula b4fb974
Merge branch 'master' into hf-timerxl
CRZbulabula 305044f
runnable
CRZbulabula 8bf44a2
Update pyproject.toml
CRZbulabula 29acd7d
Fix IT bug
CRZbulabula ff73531
Merge branch 'master' into hf-timerxl
CRZbulabula 0d8b40d
spotless
CRZbulabula aef6a47
Update IoTDBDatabaseIT.java
CRZbulabula f78ca05
Update ModelInfo.java
CRZbulabula b69869e
Update IoTDBDatabaseIT.java
CRZbulabula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2 integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13 iotdb-core/ainode/ainode/core/manager/inference_manager.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 102 additions & 2 deletions
104 iotdb-core/ainode/ainode/core/model/built_in_model_factory.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,12 +30,14 @@ | ||
| from ainode.TimerXL.models import timer_xl | ||
| from ainode.TimerXL.models.configuration_timer import TimerxlConfig | ||
| from ainode.core.model.sundial import modeling_sundial | ||
| from ainode.core.config import AINodeDescriptor | ||
| from ainode.core.constant import AttributeName, BuiltInModelType | ||
| from ainode.core.exception import InferenceModelInternalError | ||
| from ainode.core.exception import WrongAttributeTypeError, NumericalRangeException, StringRangeException, \ | ||
| ListRangeException, BuiltInModelNotSupportError | ||
| from ainode.core.log import Logger | ||
| from ainode.core.model.sundial.configuration_sundial import SundialConfig | ||
| logger = Logger() | ||
| @@ -57,6 +59,8 @@ def get_model_attributes(model_id: str): | ||
| attribute_map = stray_attribute_map | ||
| elif model_id == BuiltInModelType.TIMER_XL.value: | ||
| attribute_map = timerxl_attribute_map | ||
| elif model_id == BuiltInModelType.SUNDIAL.value: | ||
| attribute_map = sundial_attribute_map | ||
| else: | ||
| raise BuiltInModelNotSupportError(model_id) | ||
| return attribute_map | ||
| @@ -99,6 +103,8 @@ def fetch_built_in_model(model_id, inference_attributes): | ||
| model = STRAYModel(attributes) | ||
| elif model_id == BuiltInModelType.TIMER_XL.value: | ||
| model = timer_xl.Model(TimerxlConfig.from_dict(attributes)) | ||
| elif model_id == BuiltInModelType.SUNDIAL.value: | ||
| model = modeling_sundial.SundialForPrediction(SundialConfig.from_dict(attributes)) | ||
| else: | ||
| raise BuiltInModelNotSupportError(model_id) | ||
| @@ -321,6 +327,100 @@ def parse_attribute(input_attributes: Dict[str, str], attribute_map: Dict[str, A | ||
| raise e | ||
| return attributes | ||
| sundial_attribute_map = { | ||
| AttributeName.INPUT_TOKEN_LEN.value: IntAttribute( | ||
| name=AttributeName.INPUT_TOKEN_LEN.value, | ||
| default_value=16, | ||
| default_low=1, | ||
| default_high=5000 | ||
| ), | ||
| AttributeName.HIDDEN_SIZE.value: IntAttribute( | ||
| name=AttributeName.HIDDEN_SIZE.value, | ||
| default_value=768, | ||
| default_low=1, | ||
| default_high=5000 | ||
| ), | ||
| AttributeName.INTERMEDIATE_SIZE.value: IntAttribute( | ||
| name=AttributeName.INTERMEDIATE_SIZE.value, | ||
| default_value=3072, | ||
| default_low=1, | ||
| default_high=5000 | ||
| ), | ||
| AttributeName.OUTPUT_TOKEN_LENS.value: ListAttribute( | ||
| name=AttributeName.OUTPUT_TOKEN_LENS.value, | ||
| default_value=[720], | ||
| value_type=int | ||
| ), | ||
| AttributeName.NUM_HIDDEN_LAYERS.value: IntAttribute( | ||
| name=AttributeName.NUM_HIDDEN_LAYERS.value, | ||
| default_value=12, | ||
| default_low=1, | ||
| default_high=16 | ||
| ), | ||
| AttributeName.NUM_ATTENTION_HEADS.value: IntAttribute( | ||
| name=AttributeName.NUM_ATTENTION_HEADS.value, | ||
| default_value=12, | ||
| default_low=1, | ||
| default_high=192 | ||
| ), | ||
| AttributeName.HIDDEN_ACT.value: StringAttribute( | ||
| name=AttributeName.HIDDEN_ACT.value, | ||
| default_value="silu", | ||
| value_choices=["relu", "gelu", "silu", "tanh"], | ||
| ), | ||
| AttributeName.USE_CACHE.value: BooleanAttribute( | ||
| name=AttributeName.USE_CACHE.value, | ||
| default_value=True, | ||
| ), | ||
| AttributeName.ROPE_THETA.value: IntAttribute( | ||
| name=AttributeName.ROPE_THETA.value, | ||
| default_value=10000, | ||
| default_low=1000, | ||
| default_high=50000 | ||
| ), | ||
| AttributeName.DROPOUT_RATE.value: FloatAttribute( | ||
| name=AttributeName.DROPOUT_RATE.value, | ||
| default_value=0.1, | ||
| default_low=0.0, | ||
| default_high=1.0 | ||
| ), | ||
| AttributeName.INITIALIZER_RANGE.value: FloatAttribute( | ||
| name=AttributeName.INITIALIZER_RANGE.value, | ||
| default_value=0.02, | ||
| default_low=0.0, | ||
| default_high=1.0 | ||
| ), | ||
| AttributeName.MAX_POSITION_EMBEDDINGS.value: IntAttribute( | ||
| name=AttributeName.MAX_POSITION_EMBEDDINGS.value, | ||
| default_value=10000, | ||
| default_low=1, | ||
| default_high=50000 | ||
| ), | ||
| AttributeName.FLOW_LOSS_DEPTH.value: IntAttribute( | ||
| name=AttributeName.FLOW_LOSS_DEPTH.value, | ||
| default_value=3, | ||
| default_low=1, | ||
| default_high=50 | ||
| ), | ||
| AttributeName.NUM_SAMPLING_STEPS.value: IntAttribute( | ||
| name=AttributeName.NUM_SAMPLING_STEPS.value, | ||
| default_value=50, | ||
| default_low=1, | ||
| default_high=5000 | ||
| ), | ||
| AttributeName.DIFFUSION_BATCH_MUL.value: IntAttribute( | ||
| name=AttributeName.DIFFUSION_BATCH_MUL.value, | ||
| default_value=4, | ||
| default_low=1, | ||
| default_high=5000 | ||
| ), | ||
| AttributeName.CKPT_PATH.value: StringAttribute( | ||
| name=AttributeName.CKPT_PATH.value, | ||
| default_value=os.path.join(os.getcwd(), AINodeDescriptor().get_config().get_ain_models_dir(), 'weights', | ||
| 'sundial'), | ||
| value_choices=[''] | ||
| ) | ||
| } | ||
| timerxl_attribute_map = { | ||
| AttributeName.INPUT_TOKEN_LEN.value: IntAttribute( | ||
| @@ -391,8 +491,8 @@ def parse_attribute(input_attributes: Dict[str, str], attribute_map: Dict[str, A | ||
| default_low=1, | ||
| default_high=50000 | ||
| ), | ||
| AttributeName.TIMERXL_CKPT_PATH.value: StringAttribute( | ||
| name=AttributeName.TIMERXL_CKPT_PATH.value, | ||
| AttributeName.CKPT_PATH.value: StringAttribute( | ||
| name=AttributeName.CKPT_PATH.value, | ||
ycycse marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| default_value=os.path.join(os.getcwd(), AINodeDescriptor().get_config().get_ain_models_dir(), 'weights', | ||
| 'timerxl', 'model.safetensors'), | ||
| value_choices=[''] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # 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. | ||
| # |
66 changes: 66 additions & 0 deletions
66 iotdb-core/ainode/ainode/core/model/sundial/configuration_sundial.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # 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. | ||
| # | ||
| from typing import List | ||
| from transformers import PretrainedConfig | ||
| class SundialConfig(PretrainedConfig): | ||
| model_type = "sundial" | ||
| keys_to_ignore_at_inference = ["past_key_values"] | ||
| def __init__( | ||
| self, | ||
| input_token_len: int = 16, | ||
| hidden_size: int = 768, | ||
| intermediate_size: int = 3072, | ||
| output_token_lens: List[int] = [720], | ||
| num_hidden_layers: int = 12, | ||
| num_attention_heads: int = 12, | ||
| hidden_act: str = "silu", | ||
| use_cache: bool = True, | ||
| rope_theta: int = 10000, | ||
| dropout_rate: float = 0.1, | ||
| initializer_range: float = 0.02, | ||
| max_position_embeddings: int = 10000, | ||
| flow_loss_depth: int = 3, | ||
| num_sampling_steps: int = 50, | ||
| diffusion_batch_mul: int = 4, | ||
| ckpt_path: str = None, # weight path | ||
| **kwargs, | ||
| ): | ||
| self.input_token_len = input_token_len | ||
| self.hidden_size = hidden_size | ||
| self.intermediate_size = intermediate_size | ||
| self.num_hidden_layers = num_hidden_layers | ||
| self.num_attention_heads = num_attention_heads | ||
| self.hidden_act = hidden_act | ||
| self.output_token_lens = output_token_lens | ||
| self.use_cache = use_cache | ||
| self.rope_theta = rope_theta | ||
| self.dropout_rate = dropout_rate | ||
| self.initializer_range = initializer_range | ||
| self.max_position_embeddings = max_position_embeddings | ||
| self.flow_loss_depth = flow_loss_depth | ||
| self.num_sampling_steps = num_sampling_steps | ||
| self.diffusion_batch_mul = diffusion_batch_mul | ||
| self.ckpt_path = ckpt_path | ||
| super().__init__( | ||
| **kwargs, | ||
| ) |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.