From 4bc01315cd2cdf5d75fef9dfdfeee4fc801ab6f9 Mon Sep 17 00:00:00 2001 From: Sooyoung Kim Date: Mon, 23 Feb 2026 09:52:13 +0900 Subject: [PATCH 1/3] feat: add internal ID attribute to Device class This update introduces a new readonly attribute 'id' to the Device class, which corresponds to the internal ID used for matching with deployable.device_id in Horizon. This enhancement improves the API representation of devices. --- cyborg/api/controllers/v2/devices.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cyborg/api/controllers/v2/devices.py b/cyborg/api/controllers/v2/devices.py index 2eebdbf..03aabba 100644 --- a/cyborg/api/controllers/v2/devices.py +++ b/cyborg/api/controllers/v2/devices.py @@ -41,6 +41,9 @@ class Device(base.APIBase): This class enforces type checking and value constraints, and converts between the internal object model and the API representation. """ + id = wsme.wsattr(types.integer, readonly=True) + """The internal ID (matches deployable.device_id)""" + uuid = types.uuid """The UUID of the device""" From cf4b584c91e0f122679d161297bad5ecef879a24 Mon Sep 17 00:00:00 2001 From: Sooyoung Kim Date: Mon, 23 Feb 2026 16:06:41 +0900 Subject: [PATCH 2/3] chore: update tox.ini to use kcloud upper constraints - Changed the upper constraints file URL in tox.ini to point to the kcloud repository for version 2024.1. - Ensures compatibility with the latest requirements for the kcloud project. --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 6e4c25d..bee10a6 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ setenv = VIRTUAL_ENV={envdir} OS_TEST_PATH=cyborg/tests/unit deps = - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1} + -c{env:TOX_CONSTRAINTS_FILE:https://raw.githubusercontent.com/openkcloud/kcloud-requirements/refs/heads/kcloud/2024.1/upper-constraints.txt} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt @@ -94,7 +94,7 @@ allowlist_externals = sphinx-build rm deps = - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1} + -c{env:TOX_CONSTRAINTS_FILE:https://raw.githubusercontent.com/openkcloud/kcloud-requirements/refs/heads/kcloud/2024.1/upper-constraints.txt} -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build/html From b4c452689e63f1c38cbb99e22686d1d211940f35 Mon Sep 17 00:00:00 2001 From: Sooyoung Kim Date: Fri, 20 Feb 2026 16:36:58 +0900 Subject: [PATCH 3/3] feat: implement Rebellions AICHIP driver Add RebellionsAICHIPDriver (vendor ID: 1eff) following the Furiosa driver pattern. Includes PCI device discovery, trait generation, driver object construction, unit tests, and entry point registration in setup.cfg. --- .../drivers/aichip/rebellions/driver.py | 41 +++++ .../drivers/aichip/rebellions/sysinfo.py | 167 ++++++++++++++++++ .../drivers/aichip/rebellions/__init__.py | 0 .../drivers/aichip/rebellions/test_driver.py | 66 +++++++ .../accelerator/drivers/aichip/test_base.py | 2 +- setup.cfg | 1 + 6 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 cyborg/accelerator/drivers/aichip/rebellions/driver.py create mode 100644 cyborg/accelerator/drivers/aichip/rebellions/sysinfo.py create mode 100644 cyborg/tests/unit/accelerator/drivers/aichip/rebellions/__init__.py create mode 100644 cyborg/tests/unit/accelerator/drivers/aichip/rebellions/test_driver.py diff --git a/cyborg/accelerator/drivers/aichip/rebellions/driver.py b/cyborg/accelerator/drivers/aichip/rebellions/driver.py new file mode 100644 index 0000000..e6747f7 --- /dev/null +++ b/cyborg/accelerator/drivers/aichip/rebellions/driver.py @@ -0,0 +1,41 @@ +# Copyright 2025 Electronics and Telecommunications Research Institute. +# +# This software was supported by the Institute of Information & Communications +# Technology Planning & Evaluation(IITP) grant funded by the Korea government +# (MSIT) (No.RS-2025-02263869, Development of AI Semiconductor Cloud Platform +# Establishment and Optimization Technology) +# +# Modifications Copyright (C) 2020 ZTE Corporation +# Copyright 2018 Beijing Lenovo Software Ltd. +# +# Licensed 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. + + +""" +Cyborg Rebellions AICHIP driver implementation. +""" + +from cyborg.accelerator.drivers.aichip.base import AICHIPDriver +from cyborg.accelerator.drivers.aichip.rebellions import sysinfo + + +class RebellionsAICHIPDriver(AICHIPDriver): + """Class for Rebellions AICHIP drivers. + Vendor should implement their specific drivers in this class. + """ + + VENDOR = "rebellions" + VENDOR_ID = "1eff" + + def discover(self): + return sysinfo.discover(self.VENDOR_ID) diff --git a/cyborg/accelerator/drivers/aichip/rebellions/sysinfo.py b/cyborg/accelerator/drivers/aichip/rebellions/sysinfo.py new file mode 100644 index 0000000..60a9680 --- /dev/null +++ b/cyborg/accelerator/drivers/aichip/rebellions/sysinfo.py @@ -0,0 +1,167 @@ +# Copyright 2025 Electronics and Telecommunications Research Institute. +# +# This software was supported by the Institute of Information & Communications +# Technology Planning & Evaluation(IITP) grant funded by the Korea government +# (MSIT) (No.RS-2025-02263869, Development of AI Semiconductor Cloud Platform +# Establishment and Optimization Technology) +# +# Modifications Copyright (C) 2021 ZTE Corporation +# Copyright 2018 Beijing Lenovo Software Ltd. +# +# Licensed 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. + + +""" +Cyborg Rebellions AICHIP driver implementation. +""" + +from oslo_log import log as logging +from oslo_serialization import jsonutils + + +from cyborg.accelerator.common import utils +from cyborg.accelerator.drivers.aichip import utils as aichip_utils +from cyborg.common import constants +from cyborg.conf import CONF +from cyborg.objects.driver_objects import driver_attach_handle +from cyborg.objects.driver_objects import driver_attribute +from cyborg.objects.driver_objects import driver_controlpath_id +from cyborg.objects.driver_objects import driver_deployable +from cyborg.objects.driver_objects import driver_device + +LOG = logging.getLogger(__name__) + + +def _get_traits(vendor_id, product_id): + """Generate traits for AICHIPs. + : param vendor_id: vendor_id of AICHIP, eg."1eff" + : param product_id: product_id of AICHIP, eg."0000". + Example AICHIP traits: + {traits:["OWNER_CYBORG", "CUSTOM_REBELLION_0000"]} + """ + traits = ["OWNER_CYBORG"] + # AICHIP trait + aichip_trait = "_".join( + ( + "CUSTOM", + aichip_utils.VENDOR_MAPS.get(vendor_id, "").upper(), + product_id.upper(), + ) + ) + traits.append(aichip_trait) + return {"traits": traits} + + +def _generate_attribute_list(aichip): + attr_list = [] + index = 0 + for k, v in aichip.items(): + if k == "rc": + driver_attr = driver_attribute.DriverAttribute() + driver_attr.key, driver_attr.value = k, v + attr_list.append(driver_attr) + if k == "traits": + values = aichip.get(k, []) + for val in values: + driver_attr = driver_attribute.DriverAttribute( + key="trait" + str(index), value=val + ) + index = index + 1 + attr_list.append(driver_attr) + return attr_list + + +def _generate_attach_handle(aichip, num=None): + driver_ah = driver_attach_handle.DriverAttachHandle() + driver_ah.in_use = False + if aichip["rc"] == "CUSTOM_AICHIP": + driver_ah.attach_type = constants.AH_TYPE_PCI + driver_ah.attach_info = utils.pci_str_to_json(aichip["devices"]) + return driver_ah + + +def _generate_dep_list(aichip): + driver_dep = driver_deployable.DriverDeployable() + driver_dep.attribute_list = _generate_attribute_list(aichip) + driver_dep.attach_handle_list = [] + # NOTE(wangzhh): The name of deployable should be unique, its format is + # under disscussion, may looks like + # ___ + # NOTE(yumeng) Since Wallaby release, the deplpyable_name is named as + # _ + driver_dep.name = aichip.get("hostname", "") + "_" + aichip["devices"] + driver_dep.driver_name = aichip_utils.VENDOR_MAPS.get( + aichip["vendor_id"], "" + ).upper() + # if it is AICHIP, num_accelerators = 1 + if aichip["rc"] == constants.RESOURCES["AICHIP"]: + driver_dep.num_accelerators = 1 + driver_dep.attach_handle_list = [_generate_attach_handle(aichip)] + return [driver_dep] + + +def _generate_controlpath_id(aichip): + driver_cpid = driver_controlpath_id.DriverControlPathID() + driver_cpid.cpid_type = "PCI" + driver_cpid.cpid_info = utils.pci_str_to_json(aichip["devices"]) + return driver_cpid + + +def _generate_driver_device(aichip): + driver_device_obj = driver_device.DriverDevice() + driver_device_obj.vendor = aichip["vendor_id"] + driver_device_obj.model = aichip.get("model", "miss model info") + std_board_info = { + "product_id": aichip.get("product_id"), + "controller": aichip.get("controller"), + } + vendor_board_info = { + "vendor_info": aichip.get("vendor_info", "aichip_vb_info") + } + driver_device_obj.std_board_info = jsonutils.dumps(std_board_info) + driver_device_obj.vendor_board_info = jsonutils.dumps(vendor_board_info) + driver_device_obj.type = constants.DEVICE_AICHIP + driver_device_obj.stub = aichip.get("stub", False) + driver_device_obj.controlpath_id = _generate_controlpath_id(aichip) + driver_device_obj.deployable_list = _generate_dep_list(aichip) + return driver_device_obj + + +def _discover_aichips(vendor_id): + """param: vendor_id=VENDOR_ID means only discover Rebellions AICHIP + on the host + """ + # discover aichip devices by "lspci" + aichip_list = [] + aichips = aichip_utils.get_pci_devices( + aichip_utils.AICHIP_FLAGS, vendor_id + ) + # report trait,rc and generate driver object + for aichip in aichips: + m = aichip_utils.AICHIP_INFO_PATTERN.match(aichip) + if m: + aichip_dict = m.groupdict() + # get hostname for deployable_name usage + aichip_dict["hostname"] = CONF.host + aichip_dict["rc"] = constants.RESOURCES["AICHIP"] + traits = _get_traits( + aichip_dict["vendor_id"], aichip_dict["product_id"] + ) + aichip_dict.update(traits) + aichip_list.append(_generate_driver_device(aichip_dict)) + return aichip_list + + +def discover(vendor_id): + devs = _discover_aichips(vendor_id) + return devs diff --git a/cyborg/tests/unit/accelerator/drivers/aichip/rebellions/__init__.py b/cyborg/tests/unit/accelerator/drivers/aichip/rebellions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cyborg/tests/unit/accelerator/drivers/aichip/rebellions/test_driver.py b/cyborg/tests/unit/accelerator/drivers/aichip/rebellions/test_driver.py new file mode 100644 index 0000000..a96d817 --- /dev/null +++ b/cyborg/tests/unit/accelerator/drivers/aichip/rebellions/test_driver.py @@ -0,0 +1,66 @@ +# Copyright 2025 Electronics and Telecommunications Research Institute. +# +# This software was supported by the Institute of Information & Communications +# Technology Planning & Evaluation(IITP) grant funded by the Korea government +# (MSIT) (No.RS-2025-02263869, Development of AI Semiconductor Cloud Platform +# Establishment and Optimization Technology) +# +# Licensed 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 json +from unittest import mock + +from cyborg.accelerator.drivers.aichip.rebellions.driver import ( + RebellionsAICHIPDriver +) +from cyborg.tests import base + +rebellions_pci_res = ( + '0000:00:0c.0 Processing accelerators [1200]: ' + 'Rebellions NPU [1eff:0000] (rev 01)\n' + '0000:00:0d.0 Processing accelerators [1200]: ' + 'Rebellions NPU [1eff:0000] (rev 01)\n',) + + +class TestRebellionsAICHIPDriver(base.TestCase): + """Test Rebellions AICHIP driver.""" + + @mock.patch('cyborg.accelerator.drivers.aichip.utils.lspci_privileged', + return_value=rebellions_pci_res) + def test_discover(self, mock_pci): + self.set_defaults(host='host-192-168-32-195', debug=True) + + rebellions_driver = RebellionsAICHIPDriver() + npu_list = rebellions_driver.discover() + + self.assertEqual(2, len(npu_list)) + for rebellions in npu_list: + self.assertEqual('AICHIP', rebellions.type) + self.assertEqual('PCI', rebellions.controlpath_id.cpid_type) + self.assertEqual( + json.loads('{"controller": "Processing accelerators", ' + '"product_id": "0000"}'), + json.loads(rebellions.std_board_info)) + self.assertEqual('1eff', rebellions.vendor) + + self.assertEqual( + {"bus": "00", "device": "0c", "domain": "0000", "function": "0"}, + json.loads(npu_list[0].controlpath_id.cpid_info)) + self.assertEqual( + {"bus": "00", "device": "0d", "domain": "0000", "function": "0"}, + json.loads(npu_list[1].controlpath_id.cpid_info)) + + self.assertEqual('host-192-168-32-195_0000:00:0c.0', + npu_list[0].deployable_list[0].name) + self.assertEqual('host-192-168-32-195_0000:00:0d.0', + npu_list[1].deployable_list[0].name) diff --git a/cyborg/tests/unit/accelerator/drivers/aichip/test_base.py b/cyborg/tests/unit/accelerator/drivers/aichip/test_base.py index 8dedc27..8f70ce0 100644 --- a/cyborg/tests/unit/accelerator/drivers/aichip/test_base.py +++ b/cyborg/tests/unit/accelerator/drivers/aichip/test_base.py @@ -31,7 +31,7 @@ class TestAICHIPDriver(base.TestCase): def test_create(self): # FuriosaAICHIPDriver.VENDOR == 'furiosa' AICHIPDriver.create(FuriosaAICHIPDriver.VENDOR) - self.assertRaises(LookupError, AICHIPDriver.create, "rebellions") + self.assertRaises(LookupError, AICHIPDriver.create, "unknown_vendor") def test_discover(self): d = AICHIPDriver() diff --git a/setup.cfg b/setup.cfg index 2ec4c7e..b7527c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -58,6 +58,7 @@ cyborg.accelerator.driver = intel_nic_driver = cyborg.accelerator.drivers.nic.intel.driver:IntelNICDriver inspur_nvme_ssd_driver = cyborg.accelerator.drivers.ssd.inspur.driver:InspurNVMeSSDDriver furiosa_aichip_driver = cyborg.accelerator.drivers.aichip.furiosa.driver:FuriosaAICHIPDriver + rebellions_aichip_driver = cyborg.accelerator.drivers.aichip.rebellions.driver:RebellionsAICHIPDriver oslo.config.opts = cyborg = cyborg.conf.opts:list_opts