This is an automated email from the ASF dual-hosted git repository.

CRZbulabula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 522c080122e Upgrade AINode security dependencies (#19153)
522c080122e is described below

commit 522c080122ef0dffb5c7ba6cfe01568ae24c1fde
Author: Yongzao <[email protected]>
AuthorDate: Fri Nov 6 00:17:24 2026 +0800

    Upgrade AINode security dependencies (#19153)
---
 .github/workflows/cluster-it-1c1d1a.yml            |  29 ++++++
 iotdb-core/ainode/README.md                        |  24 ++++-
 iotdb-core/ainode/pyproject.toml                   |  17 ++-
 .../ainode/tests/test_dependency_security.py       | 115 +++++++++++++++++++++
 4 files changed, 180 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/cluster-it-1c1d1a.yml 
b/.github/workflows/cluster-it-1c1d1a.yml
index 74ebcbebaac..111449fb335 100644
--- a/.github/workflows/cluster-it-1c1d1a.yml
+++ b/.github/workflows/cluster-it-1c1d1a.yml
@@ -49,6 +49,8 @@ jobs:
 
     steps:
       - uses: actions/checkout@v5
+      - name: Show GPU environment
+        run: nvidia-smi --query-gpu=name,driver_version --format=csv
       - name: IT Test
         shell: bash
         run: |
@@ -59,6 +61,26 @@ jobs:
           -pl integration-test,iotdb-core/ainode \
           -am \
           -PAIClusterIT
+      - name: Verify AINode dependencies and Python regressions
+        shell: bash
+        working-directory: iotdb-core/ainode
+        run: |
+          AINODE_VENV_PY="$HOME/.cache/iotdb-ainode-build/ainode/bin/python"
+          "$AINODE_VENV_PY" - <<'PY'
+          import importlib.metadata as metadata
+
+          import torch
+
+          print({name: metadata.version(name) for name in ("torch", 
"setuptools", "pyinstaller", "transformers")})
+          print({"cuda": torch.version.cuda, "cuda_available": 
torch.cuda.is_available()})
+          architectures = torch.cuda.get_arch_list()
+          assert "sm_70" in architectures, architectures
+          matrix = torch.eye(2, device="cuda")
+          torch.testing.assert_close((matrix @ matrix).cpu(), torch.eye(2))
+          print({"device": torch.cuda.get_device_name(), "architectures": 
architectures})
+          PY
+          "$AINODE_VENV_PY" -m unittest discover -v -s tests -p 
'test_dependency_security.py'
+          "$AINODE_VENV_PY" -m unittest discover -v -s tests -p 
'test_sundial_flow_loss.py'
       - name: Upload Artifact
         if: failure()
         uses: actions/upload-artifact@v6
@@ -66,3 +88,10 @@ jobs:
           name: cluster-log-ainode-${{ matrix.os }}
           path: integration-test/target/*-logs
           retention-days: 30
+      - name: Upload integration test reports
+        if: always()
+        uses: actions/upload-artifact@v6
+        with:
+          name: ainode-test-reports-${{ matrix.os }}
+          path: integration-test/target/failsafe-reports
+          retention-days: 30
diff --git a/iotdb-core/ainode/README.md b/iotdb-core/ainode/README.md
index 150ad93e499..1dd055006e5 100644
--- a/iotdb-core/ainode/README.md
+++ b/iotdb-core/ainode/README.md
@@ -19,4 +19,26 @@
 
 -->
 
-# Apache IoTDB AINode
\ No newline at end of file
+# Apache IoTDB AINode
+
+## Python dependencies
+
+AINode requires Python 3.11 and uses Torch 2.14.1, setuptools 84.2.1, and
+PyInstaller 6.22.3. Linux selects the official Torch CUDA 12.6 wheels from
+`https://download.pytorch.org/whl/cu126` to retain Volta GPU support. This 
source
+is explicit and applies only to Torch; other dependencies continue to resolve
+from PyPI. macOS and Windows use the Torch 2.14.1 wheels from PyPI.
+
+The dependency regression tests cover invalid PackedSequence and LSTM inputs,
+TorchScript annotations, and model serialization. Run them and the Sundial
+parameter and gradient tests from this directory in the AINode environment:
+
+```bash
+python -m unittest discover -s tests -p 'test_dependency_security.py'
+python -m unittest discover -s tests -p 'test_sundial_flow_loss.py'
+```
+
+These source tests do not validate the packaged executable or GPU support.
+The `Cluster IT - 1C1D1A` workflow builds and exercises the packaged AINode,
+runs the Python tests, checks the Torch wheel's `sm_70` support, and executes a
+CUDA tensor operation on the GPU runner.
diff --git a/iotdb-core/ainode/pyproject.toml b/iotdb-core/ainode/pyproject.toml
index 0dc630fb0ff..c82fd6c9827 100644
--- a/iotdb-core/ainode/pyproject.toml
+++ b/iotdb-core/ainode/pyproject.toml
@@ -79,7 +79,11 @@ exclude = [
 python = ">=3.11.0,<3.12.0"
 
 # ---- DL / HF stack ----
-torch = "^2.9.0,<2.10.0"
+# Keep CUDA 12.6 on Linux for Volta GPU support.
+torch = [
+    { version = "==2.14.1", markers = "platform_system != 'Linux'" },
+    { version = "==2.14.1+cu126", markers = "platform_system == 'Linux'", 
source = "pytorch-cu126" },
+]
 torchmetrics = "^1.8.0"
 transformers = "==4.56.2"
 tokenizers = ">=0.22.0,<=0.23.0"
@@ -110,10 +114,10 @@ tzlocal = "^5.3.1"
 hf_xet = ">=1.1.9"
 
 # ---- Tooling ----
-pyinstaller = "6.16.0"
+pyinstaller = "==6.22.3"
 black = ">=26.3.1"
 isort = "6.0.1"
-setuptools = ">=75.3.0"
+setuptools = "==84.2.1"
 joblib = ">=1.4.2"
 urllib3 = "2.6.3"
 jaxtyping = ">=0.2.24"
@@ -124,4 +128,9 @@ ainode = "iotdb.ainode.core.script:main"
 
 [tool.isort]
 profile = "black"
-skip = ["build", "dist", "target"]
\ No newline at end of file
+skip = ["build", "dist", "target"]
+
+[[tool.poetry.source]]
+name = "pytorch-cu126"
+url = "https://download.pytorch.org/whl/cu126";
+priority = "explicit"
diff --git a/iotdb-core/ainode/tests/test_dependency_security.py 
b/iotdb-core/ainode/tests/test_dependency_security.py
new file mode 100644
index 00000000000..7b09a2461d0
--- /dev/null
+++ b/iotdb-core/ainode/tests/test_dependency_security.py
@@ -0,0 +1,115 @@
+# 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 io
+import unittest
+
+import torch
+from torch.nn.utils.rnn import (
+    PackedSequence,
+    pack_padded_sequence,
+    pad_packed_sequence,
+    unpack_sequence,
+)
+
+
+def bare_list_annotation():
+    values: list = []
+    return values
+
+
+def bare_tuple_annotation():
+    values: tuple = ()
+    return values
+
+
+class DependencySecurityTest(unittest.TestCase):
+    def test_empty_packed_sequences_are_rejected(self):
+        # CVE-2025-2998 / CVE-2025-2999: reject empty batch_sizes before
+        # _pad_packed_sequence reads its first element.
+        packed = PackedSequence(torch.empty(0, 5), torch.empty(0, 
dtype=torch.int64))
+        for unpack in (pad_packed_sequence, unpack_sequence):
+            with self.subTest(unpack=unpack.__name__):
+                with self.assertRaisesRegex(
+                    RuntimeError, "batch_sizes can not be empty"
+                ):
+                    unpack(packed)
+
+    def test_valid_packed_sequences_round_trip(self):
+        values = torch.arange(24, dtype=torch.float32).reshape(2, 3, 4)
+        lengths = torch.tensor([3, 2])
+        packed = pack_padded_sequence(values, lengths, batch_first=True)
+        padded, actual_lengths = pad_packed_sequence(packed, batch_first=True)
+        torch.testing.assert_close(actual_lengths, lengths)
+        torch.testing.assert_close(padded[0], values[0])
+        torch.testing.assert_close(padded[1, :2], values[1, :2])
+        sequences = unpack_sequence(packed)
+        self.assertEqual(2, len(sequences))
+        torch.testing.assert_close(sequences[0], values[0])
+        torch.testing.assert_close(sequences[1], values[1, :2])
+
+    def test_lstm_rejects_inconsistent_gate_weights(self):
+        # CVE-2025-3001: all four LSTM gates must have hidden_size rows.
+        inputs = torch.zeros(2, 3)
+        hidden = (torch.zeros(2, 4), torch.zeros(2, 4))
+        weight_ih = torch.zeros(16, 3)
+        weight_hh = torch.zeros(16, 4)
+        for name, actual_ih, actual_hh in (
+            ("weight_ih", torch.zeros(17, 3), weight_hh),
+            ("weight_hh", weight_ih, torch.zeros(17, 4)),
+        ):
+            with self.subTest(weight=name):
+                with self.assertRaisesRegex(RuntimeError, name):
+                    torch.lstm_cell(inputs, hidden, actual_ih, actual_hh)
+        output_hidden, output_cell = torch.lstm_cell(
+            inputs, hidden, weight_ih, weight_hh
+        )
+        torch.testing.assert_close(output_hidden, hidden[0])
+        torch.testing.assert_close(output_cell, hidden[1])
+
+    def test_jit_rejects_bare_container_annotations(self):
+        # CVE-2025-3000: reject bare container value annotations at compile 
time.
+        for container, function in (
+            ("list", bare_list_annotation),
+            ("tuple", bare_tuple_annotation),
+        ):
+            with self.subTest(container=container):
+                with self.assertRaisesRegex(
+                    RuntimeError,
+                    f"Attempted to use {container} without a contained type",
+                ):
+                    torch.jit.script(function)
+
+    def test_torchscript_model_save_load_preserves_inference(self):
+        # AINode loads TorchScript models with torch.jit.load. Exercise the
+        # real serialization and inference path without downloading a model.
+        model = torch.nn.Linear(3, 2).eval()
+        with torch.no_grad():
+            model.weight.copy_(torch.arange(6, dtype=torch.float32).reshape(2, 
3))
+            model.bias.copy_(torch.tensor([1.0, -1.0]))
+        inputs = torch.tensor([[1.0, 2.0, 3.0], [3.0, 2.0, 1.0]])
+        buffer = io.BytesIO()
+        torch.jit.save(torch.jit.script(model), buffer)
+        buffer.seek(0)
+        restored = torch.jit.load(buffer, map_location="cpu")
+        with torch.no_grad():
+            torch.testing.assert_close(restored(inputs), model(inputs))
+
+
+if __name__ == "__main__":
+    unittest.main()

Reply via email to