Skip to content

[AINode] Add Timestral as a built-in forecasting model, with weights provided by the user - #19272

Open
kotselidis wants to merge 11 commits into
apache:masterfrom
kotselidis:ainode-timestral
Open

kotselidis wants to merge 11 commits into
apache:masterfrom
kotselidis:ainode-timestral

Conversation

@kotselidis

@kotselidis kotselidis commented Nov 13, 2026 •

Copy link
Copy Markdown

Description

This PR adds Timestral (Mistral AI) to AINode's built-in forecasting models, next to timer_xl, sundial, chronos2, moirai2, toto and moment. Timestral is a patch-based transformer for multivariate probabilistic forecasting. It forecasts 21 quantiles (0.01 to 0.99) from a context of up to 32,768 steps, and it can use past-only and future-known covariates. The model is registered as timestral, with the weights of mistralai/Timestral-209M. The 209M model is the largest of the four published sizes (5M, 28M, 123M, 209M) and the one Timestral's own documentation uses.

Unlike the other built-in models, AINode neither includes nor downloads Timestral's weights. Each user obtains the checkpoint independently and places its files in AINode's model directory; timestral stays inactive until then. The reason is the weights' licence, below.

Weights licence

Timestral's code is under the Apache License 2.0. Its weights are not. Every published size is under a "Modified MIT" licence (licence text), whose second condition reads:

You are not authorized to exercise any rights under this license if the global consolidated monthly revenue of your company (or that of your employer) exceeds $20 million (or its equivalent in another currency) for the preceding month.

IoTDB's source and binary distributions do not include the weights, and AINode never fetches, mirrors or proxies them: not at startup, and not on LOAD MODEL. Users who install them obtain them themselves and must have the right to use them. The Apache-2.0 attribution in LICENSE and NOTICE covers the adapted code only, and says so.

Usage

SHOW MODELS
-- timestral | timestral | builtin | inactive   (files not installed)

LOAD MODEL timestral TO DEVICES 'cpu'
-- 1509: Model [timestral] is not installed: config.json, model.safetensors, LICENSE not found. AINode does not download or include its weights. Place config.json, model.safetensors, LICENSE in /path/to/ainode/data/ainode/models/builtin/timestral. Obtain config.json, model.safetensors and LICENSE of a Timestral checkpoint yourself, for example https://huggingface.co/mistralai/Timestral-209M. Its weights are under a Modified MIT licence that grants no rights if the global consolidated monthly revenue of your company, or of your employer, exceeded USD 20 million in the preceding month: make sure you may use them.

FORECAST and CALL INFERENCE on timestral fail in the same way, with error 1504. After the user has placed config.json, model.safetensors and LICENSE of the checkpoint in that directory:

LOAD MODEL timestral TO DEVICES 'cpu'
-- checks the three local files, then loads the model

SHOW MODELS
-- timestral | timestral | builtin | active

SELECT * FROM FORECAST(model_id => 'timestral', targets => (SELECT time, s FROM db.t) ORDER BY time, output_length => 24)
-- 24 forecast rows

The model is active from the next start on, as long as the files stay in place. iotdb-core/ainode/README.md has the setup instructions for users: the checkpoint, the three files, the directory, and the licence's revenue condition.

Example: the input is 1024 points of 50 + 10·sin(2πt/24) + 0.01·t. The request is a TForecastReq with outputLength = 24, sent to AINode's inference manager on CPU with the Timestral-209M checkpoint. The response is 24 values (the median forecast). The first six:

step forecast true value
1 51.507 51.580
2 50.514 50.591
3 50.168 50.260
4 50.564 50.611
5 51.589 51.620
6 53.205 53.219

The mean absolute error is 0.031 over 24 steps and 0.049 over 96 steps.

Built-in models with user-provided weights

  • ModelInfo gets an optional user_provided_weights, the text that tells users where to obtain the weights and under which licence. Only timestral sets it. For every other model it is None, and their discovery, download at startup, loading and forecasts are unchanged.
  • At startup, ModelStorage registers such a model without any download: it is active if config.json, model.safetensors and LICENSE are in <ain_models_dir>/builtin/timestral/ and readable (config.json parses, model.safetensors has a safetensors header), and inactive otherwise.
  • LOAD MODEL checks the files again with ModelStorage.validate_user_provided_model, so files placed after startup are found. If they are missing or unreadable, it returns error 1509 with the message shown above, naming the problem, the directory and the licence, and nothing is queued.
  • FORECAST and CALL INFERENCE on an inactive model of this kind do the same check and return error 1504 with that message.
  • TimestralForPrediction.from_pretrained loads only from an existing local directory, with local_files_only=True, so the loader cannot fall back to the Hugging Face Hub.

Ordering of LOAD and UNLOAD MODEL

LOAD MODEL and UNLOAD MODEL decide which devices need work, mark that work pending and queue it in one step under a lock in the pool controller (PoolController.request_load and request_unload). Before, InferenceManager checked the pools and queued the task separately, so an UNLOAD MODEL right after a LOAD MODEL could be skipped because the pool did not exist yet, and a LOAD MODEL right after an UNLOAD MODEL could be skipped because the pool still existed. Requests are now applied in the order they take the lock. This part applies to all models.

Model code

iotdb/ainode/core/model/timestral/ contains the inference code from mistralai/timestral 1.0.0 (Apache License 2.0), in the same way as chronos2/ contains the code from chronos-forecasting. The model, forecaster, layers, masks, scaler, covariate encoding and configuration are unchanged except for these points:

  • Imports use the iotdb.ainode.core.model.timestral package, and files carry the ASF header followed by Mistral AI's copyright notice.
  • The Hugging Face download helper (loading.py) and TimestralForecaster.from_pretrained are left out. AINode loads the checkpoint only from the local model directory.

AINode integration

  • modeling_timestral.TimestralForPrediction is the model, loaded through PyTorchModelHubMixin (hub_mixin_cls in ModelInfo), a loading path AINode already supports. config.json is read into Timestral's own TimestralConfig, which rejects unknown keys. The weights load with strict=True. The rotary-embedding frequencies are recomputed whenever the model is moved to a device, as Timestral's own loader does after moving the model.
  • pipeline_timestral.TimestralPipeline runs Timestral's TimestralForecaster with its default settings:
    • Each input is one series, and its targets are forecast jointly.
    • A covariate that appears only in past_covariates becomes a past covariate. A covariate that also appears in future_covariates becomes a known covariate, built from its past and future values.
    • Inputs of the same shape without covariates run in batches of up to 64 targets. Timestral forecasts a batch as one set of rows, one per target, and its variate-attention mask grows with the square of the number of rows. With the bound, the memory of a batch of requests grows linearly with the number of requests.
    • Forecasts are averaged with the reflected forecast of the negated series, and are clipped at 0 for series whose context is non-negative.
    • Horizons longer than one decode block (1024 steps) are forecast block by block, so any output_length that AINode accepts (up to 2880) works.
    • The pipeline returns the 0.5 quantile.

Dependencies

There are no new dependencies. Timestral needs only PyTorch, NumPy, safetensors and huggingface_hub, which AINode already pins. pyproject.toml, ainode.spec and ainode.xml are unchanged. ainode.spec already collects every module under iotdb.ainode.core.

Licences

The code is under the Apache License 2.0 (licence). This PR adds it to LICENSE, NOTICE and AINode's NOTICE-binary. See the note above about the licence of the weights.

Tests

  • tests/test_timestral.py (unittest, CPU only, no downloads) uses a two-layer Timestral with random weights. The tests:
    • save it as a checkpoint and check that it reloads with identical weights;
    • check that a checkpoint with a missing weight, or a config with an unknown key, is rejected;
    • check that the rotary-embedding frequencies are rebuilt when the model is cast;
    • load it through AINode's built-in loader and the TimestralPipeline, and check the output shapes for 1-D and 2-D targets over more than one decode block, and that the result is the forecaster's median;
    • check that inputs of the same shape are split into batches by the number of targets, and that each forecast equals the forecast of its own series;
    • check how covariates are assembled and that covariates change the forecast.
  • tests/test_timestral_local_files.py (unittest; no network: socket connections and hf_hub_download fail the test) checks that:
    • Timestral is inactive at startup without its files and is never downloaded, while the other built-in models still go through their download at startup;
    • missing files, a config.json that cannot be read and a file that is not a safetensors file give the setup message, naming the files, the directory, the checkpoint and the revenue condition;
    • a small checkpoint placed by hand after startup passes LOAD MODEL's check, loads through AINode's loader and forecasts, and is active at the next startup;
    • the loader does not fall back to the Hub for a missing directory;
    • LOAD MODEL and forecasts are rejected without the files and pass with them, while other models are not checked at all.
  • tests/test_builtin_model_load.py (unittest) checks the ordering through InferenceManager: an UNLOAD MODEL right after a LOAD MODEL runs after it, a LOAD MODEL after a pending UNLOAD MODEL is queued after it, and a request issued while another is between its check and its queueing waits for it. Each of these fails on the code before the change.
  • The AINode CI job runs these three test files, next to test_dependency_security.py and test_sundial_flow_loss.py. None of them downloads a checkpoint.
  • Integration tests: AINodeTestUtils.USER_PROVIDED_BUILTIN_MODEL_MAP lists timestral as inactive. The SHOW MODELS test checks that state, and the new userProvidedBuiltInModelNotInstalledTest checks that LOAD MODEL timestral and FORECAST fail with the setup message, so CI never downloads the real checkpoint.
  • The forecast example above was computed with the Timestral-209M checkpoint, before the switch to local files; the model and pipeline code it ran is unchanged.
  • With the published checkpoints on CPU, the forecasts are bit-identical to the unmodified Timestral 1.0.0 code for a multivariate series, a 1100-step forecast spanning two decode blocks, and a series with past and known covariates.

This PR has:

  • been self-reviewed.
  • added or updated version, license, or notice information
  • added comments explaining the "why" and the intent of the code wherever would not be obvious
    for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold
    for code coverage.
  • added integration tests.
  • added documentation for new or modified features or behaviors.

Key changed/added classes (or packages if there are too many classes) in this PR
  • iotdb/ainode/core/model/timestral/ (new): the Timestral model and forecaster, TimestralForPrediction, TimestralPipeline
  • iotdb/ainode/core/model/model_info.py: ModelInfo.user_provided_weights; timestral entry in BUILTIN_HF_TRANSFORMERS_MODEL_MAP
  • iotdb/ainode/core/model/model_storage.py: such a model is never downloaded; validate_user_provided_model checks its local files
  • iotdb/ainode/core/rpc/handler.py: LOAD MODEL and forecasts on such a model without its files return the setup message
  • iotdb/ainode/core/inference/pool_controller.py, iotdb/ainode/core/manager/inference_manager.py: LOAD MODEL and UNLOAD MODEL are decided and queued in one step
  • iotdb-core/ainode/README.md: setup instructions for Timestral's weights
  • iotdb-core/ainode/tests/test_timestral.py, tests/test_timestral_local_files.py, tests/test_builtin_model_load.py (new)
  • .github/workflows/cluster-it-1c1d1a.yml: runs the new test files
  • integration-test/.../ainode/utils/AINodeTestUtils.java, .../it/AINodeSharedClusterIT.java: USER_PROVIDED_BUILTIN_MODEL_MAP and its tests
  • LICENSE, NOTICE, iotdb-core/ainode/src/assembly/resources/NOTICE-binary

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Malformed metadata can still trigger inference-pool creation, combined-series attention can exhaust memory, and slow downloads block management operations and delay shutdown.

3 open issues
What changed in this PR

Adds Timestral-209M as an AINode built-in forecasting model. Its restricted-license weights are downloaded explicitly through LOAD MODEL, rather than automatically at startup.

Changes:

  • Adds Timestral inference code and a median-forecast pipeline supporting multivariate inputs, covariates, and multi-block horizons.
  • Introduces on-request downloads, model-state handling, and RPC checks for unavailable weights.
  • Adds unit and integration coverage and updates third-party license notices.
File Description
NOTICE Adds Timestral attribution.
LICENSE Records the vendored code’s Apache license.
iotdb-core/​ainode/​tests/​test_timestral.py Tests checkpoint loading, forecasts, and covariates.
iotdb-core/​ainode/​tests/​test_builtin_model_download.py Tests download states, retries, and pre-download rejection.
iotdb-core/​ainode/​src/​assembly/​resources/​NOTICE-binary Adds attribution to AINode binary notices.
iotdb-core/​ainode/​iotdb/​ainode/​core/​rpc/​handler.py Rejects inference before on-request weights are available.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​scaler.py Implements normalization and forecast rescaling.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​pipeline_timestral.py Adapts AINode inputs and returns median forecasts.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​modeling_timestral.py Integrates strict checkpoint loading and device transitions.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​model.py Implements the Timestral network and quantile prediction.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​masks.py Defines attention masks and temporal positions.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​layers.py Adds transformer layers and rotary embeddings.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​forecaster.py Handles block decoding, covariates, and forecast adjustments.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​covariate_encoding.py Encodes categorical covariates numerically.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​config.py Defines and validates checkpoint configuration.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​timestral/​__init__.py Adds the package initializer and attribution.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​model_storage.py Manages deferred downloads and stored-model states.
iotdb-core/​ainode/​iotdb/​ainode/​core/​model/​model_info.py Registers Timestral and adds the startup-download flag.
iotdb-core/​ainode/​iotdb/​ainode/​core/​manager/​model_manager.py Exposes built-in model downloads to callers.
iotdb-core/​ainode/​iotdb/​ainode/​core/​inference/​pool_controller.py Downloads deferred weights before loading inference pools.
integration-test/​src/​test/​java/​org/​apache/​iotdb/​ainode/​utils/​AINodeTestUtils.java Defines expected on-request built-in models.
integration-test/​src/​test/​java/​org/​apache/​iotdb/​ainode/​it/​AINodeSharedClusterIT.java Covers model listing and load/inference/forecast flow.

Review effort: Balanced

@CRZbulabula CRZbulabula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed e3475fa. I independently reproduced the three issues in the existing review threads and added the evidence there: synchronous downloads block the shared controller, failed configuration processing still reports download success, and batching independent series causes quadratic mask-memory growth across requests. These should be addressed before merging.

All ten new Python tests pass locally (six model tests and four download tests), using Python 3.11 / PyTorch 2.11.0 on CPU. This does not validate the pinned PyTorch 2.14.1 or GPU behavior. The current AINode CI job is green, but its explicit Python test commands only select test_dependency_security.py and test_sundial_flow_loss.py; please include both new regression suites in CI as well.

I replied separately in #19270 about the optional download design and the remaining weights-license question.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@CRZbulabula CRZbulabula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the follow-up commits. The malformed-config result and unbounded cross-request batching issues are fixed, and the new test suites now run in CI. All 15 new Python tests and the 19 packaged integration tests pass in the latest AINode job.

Besides the pending-load/unload issue noted in the lifecycle thread, the weights-license question remains open. The restriction is documented in the PR description, but there are still no user-facing setup instructions explaining the eligibility condition before LOAD MODEL downloads the weights. Please add those instructions with a link to the exact checkpoint license. We also need to close the maintainer/PMC assessment of this optional download workflow; an explicit download does not itself resolve the license restriction.

After #19273 lands, please rebase this PR: the two changes conflict in model_info.py and the license/notice files. Both model registrations and the max_output_length / download_on_start fields need to be retained and tested together.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 09:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

device_id_list (list[torch.device]): List of device_ids where the model should be loaded.
"""
with self._pending_loads_lock:
self._pending_loads.update((model_id, d) for d in device_id_list)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is still a LOAD-to-UNLOAD ordering race here. load_model() publishes the pending counter, releases the lock, and only then enqueues the load. If another request runs in that gap, InferenceManager.unload_model() sees is_loading() == True and enqueues unload first; the worker finds no pool and drops it, then the load proceeds and leaves the model loaded. Please make publishing the pending state and enqueueing the load atomic (or otherwise preserve FIFO ordering), and add an event-controlled test through InferenceManager that forces this interleaving.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in d04aa5d: load_model() now publishes the pending load and puts it on the task queue inside the same _pending_loads_lock block, so an unload_model() that sees is_loading() == True is always queued after the load (FIFO on the controller's queue). The new test_unload_racing_a_load_through_inference_manager_runs_after_it in test_builtin_model_load.py forces the interleaving through InferenceManager: the queue holds the load's put() open, UNLOAD MODEL is issued in that gap, and the test checks that it cannot overtake and that the controller runs the load before the unload. It fails on the previous commit and passes now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also fixed the mirror case in c177c9b: a LOAD MODEL issued while an UNLOAD MODEL is still queued used to be skipped, because the pool was still listed, and the unload then left the model unloaded. Unloads are now tracked as pending in the same way (published and queued in one step under the lock), and InferenceManager.load_model() no longer counts pools that a pending unload is about to remove, so the load is queued after the unload. test_load_after_a_pending_unload_through_inference_manager_runs_after_it covers it; it fails before this commit.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

if self._pool_controller.has_request_pools(
model_id=existing_model_id, device_id=device_id
):
) and not self._pool_controller.is_unloading(existing_model_id, device_id):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new pending counters close the queue-insertion races, but the manager's state check and forwarding call are still separate. For example, with an existing pool, LOAD can observe has_request_pools=True and is_unloading=False, then pause before returning; a concurrent UNLOAD can enqueue and remove the pool, while the LOAD is skipped, leaving the model unloaded even though LOAD arrived during the operation. The inverse window exists between UNLOAD's checks at lines 124-126 and its call to PoolController.unload_model(): a later LOAD can observe the pool and no pending unload, skip enqueueing, then the unload removes it. Could you make the state decision and enqueue one serialized controller operation (or add event-controlled tests for both check-to-forward interleavings)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in efb62dc by making the decision and the enqueue one serialised controller operation, as you suggested.

PoolController.request_load() and request_unload() each run as one block under _pending_lock:

  1. They read the pools and the pending loads and unloads.
  2. They pick the devices that need the work: a LOAD goes to a device with no pool, or one that a pending unload is about to clear; an UNLOAD goes to a device with a pool, or with a load still pending.
  3. They mark that work pending and put it on the task queue.

InferenceManager.load_model() and unload_model() now only call these methods and report the devices they return, so no check is left outside the lock.

Requests are therefore serialised in the order they take the lock, and each one sees every earlier request. If the earlier request's task has already run, its effect is in the pools; if not, it is still marked pending, because a task clears its pending mark only after it has changed the pools.

Two event-controlled tests through InferenceManager cover the check-to-forward interleavings. In each, the first request is held inside its pool check while the second is issued.

  • UNLOAD during a LOAD's check: the UNLOAD cannot complete while the LOAD is held. Afterwards the outcome is that of LOAD then UNLOAD: the load is skipped, then the model is unloaded.
  • LOAD during an UNLOAD's check: the LOAD waits, then sees the pending unload and queues itself after it. The model ends up loaded.

Both tests fail on the previous commit and pass now; test_builtin_model_load.py passes all 10 tests, in five consecutive runs.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@CRZbulabula

Copy link
Copy Markdown
Contributor

I checked the published ASF optional-feature guidance and the checkpoint license. To keep the weights entirely user-provided and out of IoTDB distribution/download flows, please revise this PR along these lines:

  • Remove the Timestral Hugging Face download path, including the repo_id/hf_hub_download fallback triggered by LOAD MODEL. Startup and LOAD MODEL should never fetch Timestral files from the network.
  • Keep Timestral inactive unless the user has manually placed the required files in the local AINode model directory (models_dir/builtin/timestral/). LOAD MODEL should only validate and load those local files; if they are missing, return an actionable setup error and do not fall back to a download.
  • Add user setup instructions identifying the upstream checkpoint and exact files (config.json, model.safetensors, and the full upstream LICENSE), the local installation path, and the Modified MIT revenue restriction. Make clear that users obtain the weights independently and must have rights to use them.
  • Keep the weights out of IoTDB source/binary distributions and avoid mirroring/proxying them. Keep the Apache-2.0 attribution for the adapted Timestral code separate from the weights license.
  • Update unit and integration tests so CI never downloads the real checkpoint; cover missing-local-files failure, loading a manually supplied local fixture, and that Timestral startup/LOAD MODEL make no network request.

This follows the ASF policy path for an optional feature that relies on non-included work more directly. The public policy text does not specifically address model checkpoints, so this change is intended to ensure the weights are obtained and installed independently by each user.

Copilot AI balanced review requested due to automatic review settings November 27, 2026 08:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@kotselidis kotselidis changed the title [AINode] Add Timestral as a built-in forecasting model, downloaded on load [AINode] Add Timestral as a built-in forecasting model, with weights provided by the user Nov 27, 2026
@kotselidis

kotselidis commented Nov 27, 2026 •

Copy link
Copy Markdown
Author

Thanks for checking the ASF guidance. This PR is now revised along those lines, rebased onto the current master (54db6e7) and force-pushed as a4ad922. Point by point:

  • No download. The Timestral download path is removed, with repo_id, download_on_start, download_builtin_model and the download thread in the pool controller. Startup and LOAD MODEL never fetch Timestral files. TimestralForPrediction.from_pretrained also loads only from an existing local directory, with local_files_only=True, so the loader cannot fall back to the Hub.

  • Local files only. A new ModelInfo.user_provided_weights marks the model; only timestral sets it.

    • Timestral is active only if config.json, model.safetensors and LICENSE are in models_dir/builtin/timestral/ and readable.
    • LOAD MODEL checks them again (ModelStorage.validate_user_provided_model), so files placed after startup are found.
    • If they are missing or unreadable, LOAD MODEL returns 1509, and FORECAST and CALL INFERENCE return 1504. The message names the missing or bad file, the directory, the checkpoint and the licence condition, and nothing falls back to a download.
  • Setup instructions. iotdb-core/ainode/README.md has a new section on Timestral's weights. It covers the upstream checkpoint (mistralai/Timestral-209M), the exact files (config.json, model.safetensors, and the full upstream LICENSE), and the installation path. It also states the Modified MIT revenue restriction, and that users obtain the weights independently and must have the rights to use them.

  • Distribution and attribution. The weights stay out of IoTDB's source and binary distributions, and AINode neither mirrors nor proxies them. The Apache-2.0 attribution in LICENSE, NOTICE and NOTICE-binary stays for the adapted code. LICENSE now states that it covers the code only, and that the weights are under their own licence.

  • Tests. tests/test_builtin_model_download.py is replaced by tests/test_timestral_local_files.py, which fails on any socket connection or hf_hub_download call. It covers:

    • startup with no Timestral download, while the other built-in models are unchanged;
    • missing and unreadable files giving the setup message;
    • a small checkpoint placed by hand passing LOAD MODEL's check, loading and forecasting;
    • LOAD MODEL and forecasts rejected without the files, and other models not checked.

    The IT now expects timestral to be inactive, and userProvidedBuiltInModelNotInstalledTest checks that LOAD MODEL and FORECAST fail with the setup message, so CI never downloads the real checkpoint. All 31 AINode Python tests pass locally. On a machine with an NVIDIA A10 (torch 2.9.1+cu128), the 19 tests of test_timestral.py (7), test_timestral_local_files.py (7) and test_builtin_model_load.py (5) also pass at a4ad922; these tests run on the CPU.

Every new check is gated on user_provided_weights, so the other built-in models keep their current behaviour. The one change that does apply to all models is the LOAD/UNLOAD ordering from the earlier review rounds, which I kept: PoolController.request_load and request_unload decide and queue each request in one locked step.

The title and description are updated to match. The workflows on the new head will need a maintainer's approval to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants