From 75405a9f3068dded382666eb336166d83241f467 Mon Sep 17 00:00:00 2001 From: ChaoZheng109 Date: Wed, 8 Apr 2026 15:42:38 +0800 Subject: [PATCH] tmp --- .../kernels/aic/aic_hub.cpp | 24 --- .../kernels/aiv/aiv_hub.cpp | 24 --- .../kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../kernels/kernel_config.py | 14 -- .../paged_attention/kernels/aic/aic_hub.cpp | 28 --- .../paged_attention/kernels/aiv/aiv_hub.cpp | 28 --- .../paged_attention/kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../paged_attention/kernels/aic/aic_hub.cpp | 28 --- .../paged_attention/kernels/aiv/aiv_hub.cpp | 28 --- .../paged_attention/kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../orchestration/pto_orchestration_api.h | 14 ++ .../runtime/pto_orchestrator.cpp | 185 ++++++++++++++++++ .../runtime/pto_orchestrator.h | 12 ++ .../runtime/pto_runtime2.cpp | 5 + .../aicpu_build_graph/runtime/pto_runtime2.h | 13 ++ .../docs/RUNTIME_LOGIC.md | 3 +- .../orchestration/pto_orchestration_api.h | 16 ++ .../runtime/pto_orchestrator.cpp | 181 ++++++++++++++++- .../runtime/pto_orchestrator.h | 12 ++ .../runtime/pto_runtime2.cpp | 5 + .../runtime/pto_runtime2.h | 14 ++ .../docs/RUNTIME_LOGIC.md | 3 +- .../orchestration/pto_orchestration_api.h | 16 ++ .../runtime/pto_orchestrator.cpp | 171 ++++++++++++++++ .../runtime/pto_orchestrator.h | 12 ++ .../runtime/pto_runtime2.cpp | 5 + .../runtime/pto_runtime2.h | 14 ++ .../paged_attention/kernels/aic/aic_hub.cpp | 28 --- .../paged_attention/kernels/aiv/aiv_hub.cpp | 28 --- .../paged_attention/kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 16 +- .../kernels/aic/aic_hub.cpp | 28 --- .../kernels/aiv/aiv_hub.cpp | 28 --- .../kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 14 +- .../kernels/aic/aic_hub.cpp | 24 --- .../kernels/aiv/aiv_hub.cpp | 24 --- .../kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../paged_attention/kernels/aic/aic_hub.cpp | 28 --- .../paged_attention/kernels/aiv/aiv_hub.cpp | 28 --- .../paged_attention/kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../kernels/kernel_config.py | 14 -- .../kernels/aic/aic_hub.cpp | 28 --- .../kernels/aiv/aiv_hub.cpp | 28 --- .../kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../orchestration/scalar_data_orch.cpp | 11 +- .../paged_attention/kernels/aic/aic_hub.cpp | 28 --- .../paged_attention/kernels/aiv/aiv_hub.cpp | 28 --- .../paged_attention/kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- .../kernels/aic/aic_hub.cpp | 28 --- .../kernels/aiv/aiv_hub.cpp | 28 --- .../kernels/kernel_config.py | 14 -- .../orchestration/paged_attention_orch.cpp | 10 +- 60 files changed, 719 insertions(+), 795 deletions(-) delete mode 100644 examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp delete mode 100644 tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp delete mode 100644 tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp diff --git a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 28ba31a32..000000000 --- a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 28ba31a32..000000000 --- a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py index 7fdd3f1f2..dd705550f 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py +++ b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp index 0a7555ea7..dca342d2f 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -32,8 +32,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 extern "C" { @@ -122,10 +120,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_hub.add_output(tile2d_ci); params_hub.add_output(scalar_ci); params_hub.add_output(scalar_ci); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_hub); - const Tensor &oi_batch = hub_outs.get_ref(0); - const Tensor &li_batch = hub_outs.get_ref(1); - const Tensor &mi_batch = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_hub); + const Tensor &oi_batch = state_outs.get_ref(0); + const Tensor &li_batch = state_outs.get_ref(1); + const Tensor &mi_batch = state_outs.get_ref(2); for (uint64_t bn = 0; bn < max_bn; bn++) { Arg params_qk; diff --git a/examples/a2a3/tensormap_and_ringbuffer/multi-round-paged-attention/kernels/kernel_config.py b/examples/a2a3/tensormap_and_ringbuffer/multi-round-paged-attention/kernels/kernel_config.py index 73b8d46bf..72c99616f 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/multi-round-paged-attention/kernels/kernel_config.py +++ b/examples/a2a3/tensormap_and_ringbuffer/multi-round-paged-attention/kernels/kernel_config.py @@ -43,13 +43,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_PA_KERNELS / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, { "func_id": 1, "name": "SF", @@ -64,13 +57,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_PA_KERNELS / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py index 7fdd3f1f2..dd705550f 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py +++ b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index 76fc90a76..4dc0d9bce 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -34,8 +34,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 extern "C" { @@ -125,10 +123,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(tile2d_ci); params_inplace.add_output(scalar_ci); params_inplace.add_output(scalar_ci); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); for (uint64_t bn = 0; bn < bn_this_batch; bn++) { uint32_t bt_idx[2] = {static_cast(b_idx), static_cast(bn)}; diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py index 7fdd3f1f2..dd705550f 100644 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py +++ b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index 54488cf6e..1509ff853 100644 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -34,8 +34,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 extern "C" { @@ -125,10 +123,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(tile2d_ci); params_inplace.add_output(scalar_ci); params_inplace.add_output(scalar_ci); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); for (uint64_t bn = 0; bn < bn_this_batch; bn++) { uint32_t bt_idx[2] = {static_cast(b_idx), static_cast(bn)}; diff --git a/src/a2a3/runtime/aicpu_build_graph/orchestration/pto_orchestration_api.h b/src/a2a3/runtime/aicpu_build_graph/orchestration/pto_orchestration_api.h index 557924a8e..02c17d8b7 100644 --- a/src/a2a3/runtime/aicpu_build_graph/orchestration/pto_orchestration_api.h +++ b/src/a2a3/runtime/aicpu_build_graph/orchestration/pto_orchestration_api.h @@ -65,6 +65,7 @@ typedef struct PTO2Runtime PTO2Runtime; */ typedef struct PTO2RuntimeOps { SubmitResult (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + SubmitResult (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*add_dependency)(PTO2Runtime *rt, PTO2TaskId producer, PTO2TaskId consumer); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); @@ -98,6 +99,19 @@ static inline SubmitResult pto2_rt_submit_task(PTO2Runtime *rt, const MixedKerne return rt->ops->submit_task(rt, mixed_kernels, args); } +/** + * Materialize runtime-created OUTPUT tensors without dispatching a kernel. + * + * Returns SubmitResult so the pseudo task can still participate in explicit + * dependency wiring through task_id. + * + * Only OUTPUT tensor args are accepted. Inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +static inline SubmitResult pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args) { + return rt->ops->materialize_output_tensors(rt, args); +} + /** * Convenience wrapper: submit an AIC-only task. */ diff --git a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.cpp b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.cpp index 209ef9288..faa9cc4c2 100644 --- a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.cpp +++ b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.cpp @@ -226,6 +226,9 @@ void pto2_scope_end(PTO2OrchestratorState *orch) { for (int32_t i = 0; i < count; i++) { PTO2TaskSlotState *slot = tasks[i]; if (!slot) continue; + if (slot->task_state.load(std::memory_order_acquire) >= PTO2_TASK_COMPLETED) { + continue; + } // task_state is already PENDING from submit_task (defensive store) slot->task_state.store(PTO2_TASK_PENDING, std::memory_order_relaxed); @@ -446,6 +449,188 @@ SubmitResult pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKern return result; } +SubmitResult pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args) { + CYCLE_COUNT_START(); + + SubmitResult result; + + if (orch->fatal) { + return result; + } + + auto fail_invalid_arg = [&](const char *title, const char *detail) { + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: %s", title); + LOG_ERROR("========================================"); + LOG_ERROR("Error: %s", detail); + LOG_ERROR(" tensor_count: %d, scalar_count: %d", args.tensor_count(), args.scalar_count()); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_INVALID_ARGS, std::memory_order_release); + orch->fatal = true; + }; + + if (args.has_error) { + fail_invalid_arg("Invalid Arg Detected!", args.error_msg ? args.error_msg : "(unknown)"); + return result; + } + + if (args.scalar_count() != 0) { + fail_invalid_arg( + "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports OUTPUT tensors and no scalars" + ); + return result; + } + + for (int32_t i = 0; i < args.tensor_count(); i++) { + if (args.tag(i) != TensorArgType::OUTPUT) { + fail_invalid_arg( + "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports add_output(TensorCreateInfo)" + ); + return result; + } + } + + if (args.tensor_count() == 0) { + return result; + } + + uint8_t ring_id = orch->current_ring_id(); + auto &task_ring = orch->rings[ring_id].task_ring; + PTO2SchedulerState *sched = orch->scheduler; + + always_assert(orch->scope_stack_top >= 0 && "Cannot materialize output tensors outside a scope"); + + { + int32_t scope_task_count = orch->scope_tasks_size - orch->scope_begins[orch->scope_stack_top]; + if (scope_task_count >= task_ring.window_size - 1) { + int32_t total_submitted = task_ring.current_index_ptr->load(std::memory_order_acquire); + int32_t last_alive = task_ring.last_alive_ptr->load(std::memory_order_acquire); + int32_t active_count = total_submitted - last_alive; + + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: Scope Deadlock Detected! (ring %d)", ring_id); + LOG_ERROR("========================================"); + LOG_ERROR("Tasks in current scope (%d) >= task_window_size (%d).", scope_task_count, task_ring.window_size); + LOG_ERROR(" scope_depth: %d", orch->scope_stack_top + 1); + LOG_ERROR(" ring_id: %d", ring_id); + LOG_ERROR(" scope_task_count: %d", scope_task_count); + LOG_ERROR(" total_submitted: %d", total_submitted); + LOG_ERROR(" last_task_alive: %d", last_alive); + LOG_ERROR(" active_tasks: %d / %d", active_count, task_ring.window_size); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_SCOPE_DEADLOCK, std::memory_order_release); + orch->fatal = true; + return result; + } + } + + int32_t local_id = task_ring.pto2_task_ring_alloc(); + if (local_id < 0) { + orch->fatal = true; + return result; + } + int32_t slot = task_ring.get_task_slot(local_id); + PTO2TaskId task_id = pto2_make_task_id(ring_id, static_cast(local_id)); + + PTO2TaskDescriptor &task = task_ring.get_task_by_slot(slot); + PTO2TaskPayload *payload = &orch->sm_handle->task_payloads[ring_id][slot]; + + for (int32_t i = 0; i < args.tensor_count(); i++) { + __builtin_prefetch(&payload->tensors[i], 1, 3); + __builtin_prefetch(reinterpret_cast(&payload->tensors[i]) + 64, 1, 3); + } + __builtin_prefetch(payload, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 64, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 128, 1, 3); + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.fanin_count = 0; + slot_state.fanout_head = nullptr; + slot_state.fanout_lock.store(0, std::memory_order_relaxed); + slot_state.fanout_count = 1; + slot_state.fanout_refcount.store(0, std::memory_order_release); + slot_state.fanin_refcount.store(0, std::memory_order_release); + slot_state.payload = payload; + slot_state.task = &task; + slot_state.active_mask = 0; + slot_state.subtask_done_mask.store(0, std::memory_order_relaxed); + slot_state.ring_id = ring_id; + slot_state.task_state.store(PTO2_TASK_PENDING, std::memory_order_relaxed); + scope_tasks_push(orch, &slot_state); + } else { + scope_tasks_push(orch, nullptr); + } + + CYCLE_COUNT_LAP_RECORD(g_orch_alloc_cycle, AicpuPhaseId::ORCH_ALLOC, task_id.raw); + + int32_t total_output_size = 0; + for (int32_t i = 0; i < args.tensor_count(); i++) { + total_output_size += PTO2_ALIGN_UP(args.tensor(i).create_info.buffer_size_bytes(), PTO2_PACKED_OUTPUT_ALIGN); + } + + void *local_packed_base = nullptr; + void *local_packed_end = nullptr; + if (total_output_size > 0) { + local_packed_base = orch->pto2_alloc_packed_buffer(total_output_size); + if (!local_packed_base) { + orch->fatal = true; + return result; + } + local_packed_end = reinterpret_cast(local_packed_base) + total_output_size; + } + + int32_t offset = 0; + for (int32_t i = 0; i < args.tensor_count(); i++) { + const TensorCreateInfo &ci = args.tensor(i).create_info; + uint64_t buffer_size = ci.buffer_size_bytes(); + uint64_t alloc_addr = reinterpret_cast(reinterpret_cast(local_packed_base) + offset); + offset += PTO2_ALIGN_UP(buffer_size, PTO2_PACKED_OUTPUT_ALIGN); + result.outputs.materialize_output(ci, reinterpret_cast(alloc_addr), /*version=*/0); + } + + CYCLE_COUNT_LAP_RECORD(g_orch_heap_cycle, AicpuPhaseId::ORCH_HEAP, task_id.raw); + + if (sched) { + int32_t sm_last_task_alive = task_ring.last_alive_ptr->load(std::memory_order_acquire); + orch->rings[ring_id].dep_pool.reclaim(*sched, ring_id, sm_last_task_alive); + } + + __builtin_prefetch(&task, 1, 1); + task.task_id = task_id; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIC)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV0)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV1)] = INVALID_KERNEL_ID; + task.packed_buffer_base = local_packed_base; + task.packed_buffer_end = local_packed_end; + + payload->fanin_actual_count = 0; + payload->init(args, result.outputs); + + CYCLE_COUNT_LAP_RECORD(g_orch_args_cycle, AicpuPhaseId::ORCH_PARAMS, task_id.raw); + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.task_state.store(PTO2_TASK_COMPLETED, std::memory_order_release); + slot_state.dep_pool_mark = orch->rings[ring_id].dep_pool.top; + } + +#if PTO2_PROFILING + orch->tasks_submitted++; +#if PTO2_ORCH_PROFILING + g_orch_submit_count++; +#endif + g_orch_submit_idx++; +#endif + + result.task_id = task_id; + return result; +} + // ============================================================================= // Explicit Dependency Management // ============================================================================= diff --git a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.h b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.h index dfeb8b604..ce7224a19 100644 --- a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.h +++ b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_orchestrator.h @@ -195,6 +195,18 @@ void pto2_scope_end(PTO2OrchestratorState *orch); */ SubmitResult pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_kernels, const Arg &args); +/** + * Materialize runtime-created OUTPUT tensors without dispatching a worker + * kernel. + * + * This creates an orchestration-only pseudo task that is already in COMPLETED + * state, so returned tensors still participate in scope lifetime management and + * the returned task_id can be used in explicit dependency wiring. + * + * Only OUTPUT tensor args are supported. + */ +SubmitResult pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args); + // ============================================================================= // Explicit Dependency Management // ============================================================================= diff --git a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.cpp b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.cpp index b0507025a..2e38ebddd 100644 --- a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.cpp +++ b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.cpp @@ -33,6 +33,10 @@ static SubmitResult submit_task_impl(PTO2Runtime *rt, const MixedKernels &mixed_ return pto2_submit_mixed_task(&rt->orchestrator, mixed_kernels, args); } +SubmitResult pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args) { + return pto2_materialize_output_tensors(&rt->orchestrator, args); +} + static void add_dependency_impl(PTO2Runtime *rt, PTO2TaskId producer, PTO2TaskId consumer) { pto2_add_dependency(&rt->orchestrator, producer, consumer); } @@ -47,6 +51,7 @@ static bool is_fatal_impl(PTO2Runtime *rt) { return rt->orchestrator.fatal; } static const PTO2RuntimeOps s_runtime_ops = { .submit_task = submit_task_impl, + .materialize_output_tensors = pto2_rt_materialize_output_tensors, .add_dependency = add_dependency_impl, .scope_begin = pto2_rt_scope_begin, .scope_end = pto2_rt_scope_end, diff --git a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.h b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.h index e6f52d386..e87359cee 100644 --- a/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.h +++ b/src/a2a3/runtime/aicpu_build_graph/runtime/pto_runtime2.h @@ -67,6 +67,7 @@ typedef struct PTO2Runtime PTO2Runtime; // forward declare for ops signatures struct PTO2RuntimeOps { SubmitResult (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + SubmitResult (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*add_dependency)(PTO2Runtime *rt, PTO2TaskId producer, PTO2TaskId consumer); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); @@ -162,6 +163,18 @@ void pto2_runtime_set_mode(PTO2Runtime *rt, PTO2RuntimeMode mode); // Orchestration API (called by orchestration function) // ============================================================================= +/** + * Materialize runtime-managed output tensors without dispatching a kernel. + * + * Intended for orchestration-side accumulator/state allocation that previously + * required submitting an empty hub kernel. The returned SubmitResult preserves + * both runtime-managed outputs and a task_id for explicit dependency wiring. + * + * Only OUTPUT tensor args are supported; inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +SubmitResult pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args); + /** * Begin a new scope * diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md index e22cf4e0e..73f088f71 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md @@ -636,7 +636,6 @@ KERNELS = [ {"func_id": 1, "name": "SF", "source": "aiv/aiv_softmax_prepare.cpp", "core_type": "aiv"}, {"func_id": 2, "name": "PV", "source": "aic/aic_pv_matmul.cpp", "core_type": "aic"}, {"func_id": 3, "name": "UP", "source": "aiv/aiv_online_update.cpp", "core_type": "aiv"}, - {"func_id": 5, "name": "AIV_HUB", "source": "aiv/aiv_hub.cpp", "core_type": "aiv"}, ] ORCHESTRATION = { @@ -660,7 +659,7 @@ void aicpu_orchestration_entry(uint64_t* args, int arg_count) { for (batch_start = 0; batch_start < batch; batch_start += IN_CORE_BATCH) { PTO2_SCOPE() { // Describe accumulator tensors (oi, li, mi) with TensorCreateInfo - // Submit AIV_HUB to initialize accumulators + // Materialize accumulator tensors without dispatching a kernel for (bn = 0; bn < max_bn; bn++) { // Allocate intermediate tensors (sij, pij, mij, lij, oi_new) // Submit QK (CUBE) → SF (VECTOR) → PV (CUBE) → UP (VECTOR) diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h b/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h index b45cc0b88..c65adfe06 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h @@ -113,6 +113,7 @@ void pto2_framework_bind_runtime(PTO2Runtime *rt); */ typedef struct PTO2RuntimeOps { TaskOutputTensors (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + TaskOutputTensors (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); void (*orchestration_done)(PTO2Runtime *rt); @@ -155,6 +156,21 @@ static inline TaskOutputTensors pto2_rt_submit_task(const MixedKernels &mixed_ke return rt->ops->submit_task(rt, mixed_kernels, args); } +/** + * Materialize runtime-created OUTPUT tensors without dispatching a kernel. + * + * Use this for orchestration-managed state tensors such as accumulators that + * need normal runtime ownership/lifetime semantics but do not require any + * InCore computation to initialize. + * + * Only OUTPUT tensor args are accepted. Inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +static inline TaskOutputTensors pto2_rt_materialize_output_tensors(const Arg &args) { + PTO2Runtime *rt = pto2_current_runtime(); + return rt->ops->materialize_output_tensors(rt, args); +} + /** * Convenience wrapper: submit an AIC-only task. */ diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp index 5e754f9e0..c88ed5caa 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp @@ -362,6 +362,20 @@ void pto2_scope_end(PTO2OrchestratorState *orch) { // ============================================================================= // Task Submission // ============================================================================= +static bool +pto2_fail_invalid_arg_usage(PTO2OrchestratorState *orch, const Arg &args, const char *header, const char *detail) { + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: %s", header); + LOG_ERROR("========================================"); + LOG_ERROR("Error: %s", detail); + LOG_ERROR(" tensor_count: %d, scalar_count: %d", args.tensor_count(), args.scalar_count()); + LOG_ERROR("This is a bug in the orchestration code."); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_INVALID_ARGS, std::memory_order_release); + orch->fatal = true; + return false; +} + TaskOutputTensors pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_kernels, const Arg &args) { CYCLE_COUNT_START(); @@ -375,15 +389,7 @@ pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_ke // Validate Arg construction (errors recorded by add_input/add_output/etc.) if (args.has_error) { - LOG_ERROR("========================================"); - LOG_ERROR("FATAL: Invalid Arg Detected!"); - LOG_ERROR("========================================"); - LOG_ERROR("Error: %s", args.error_msg ? args.error_msg : "(unknown)"); - LOG_ERROR(" tensor_count: %d, scalar_count: %d", args.tensor_count(), args.scalar_count()); - LOG_ERROR("This is a bug in the orchestration code."); - LOG_ERROR("========================================"); - orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_INVALID_ARGS, std::memory_order_release); - orch->fatal = true; + pto2_fail_invalid_arg_usage(orch, args, "Invalid Arg Detected!", args.error_msg ? args.error_msg : "(unknown)"); return result; } @@ -737,6 +743,163 @@ pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_ke return result; } +TaskOutputTensors pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args) { + TaskOutputTensors result; + + if (orch->fatal) { + return result; + } + + if (args.has_error) { + pto2_fail_invalid_arg_usage(orch, args, "Invalid Arg Detected!", args.error_msg ? args.error_msg : "(unknown)"); + return result; + } + + if (args.scalar_count() != 0) { + pto2_fail_invalid_arg_usage( + orch, args, "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports OUTPUT tensors and no scalars" + ); + return result; + } + + for (int32_t i = 0; i < args.tensor_count(); i++) { + if (args.tag(i) != TensorArgType::OUTPUT) { + pto2_fail_invalid_arg_usage( + orch, args, "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports add_output(TensorCreateInfo)" + ); + return result; + } + } + + if (args.tensor_count() == 0) { + return result; + } + + uint8_t ring_id = orch->current_ring_id(); + auto &allocator = orch->rings[ring_id].task_allocator; + PTO2SchedulerState *sched = orch->scheduler; + + always_assert(orch->scope_stack_top >= 0 && "Cannot materialize outputs outside a scope"); + + { + int32_t scope_task_count = orch->scope_tasks_size - orch->scope_begins[orch->scope_stack_top]; + if (scope_task_count >= allocator.window_size() - 1) { + int32_t active_count = allocator.active_count(); + + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: Scope Deadlock Detected! (ring %d)", ring_id); + LOG_ERROR("========================================"); + LOG_ERROR( + "Tasks in current scope (%d) >= task_window_size (%d).", scope_task_count, allocator.window_size() + ); + LOG_ERROR(" scope_depth: %d", orch->scope_stack_top + 1); + LOG_ERROR(" ring_id: %d", ring_id); + LOG_ERROR(" scope_task_count: %d", scope_task_count); + LOG_ERROR(" active_tasks: %d / %d", active_count, allocator.window_size()); + LOG_ERROR("Root Cause:"); + LOG_ERROR(" Tasks within a scope hold a fanout_count reference that is only"); + LOG_ERROR(" released at scope_end. When scope task count >= window_size,"); + LOG_ERROR(" no slots can be reclaimed -> deadlock."); + LOG_ERROR("Solution:"); + LOG_ERROR(" 1. Reduce tasks per scope (use batching/unroll)"); + LOG_ERROR(" 2. Increase task window (current: %d)", allocator.window_size()); + LOG_ERROR(" Compile-time: PTO2_TASK_WINDOW_SIZE in pto_runtime2_types.h"); + LOG_ERROR(" Runtime env: PTO2_RING_TASK_WINDOW="); + LOG_ERROR(" 3. Split work across multiple scopes"); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_SCOPE_DEADLOCK, std::memory_order_release); + orch->fatal = true; + return result; + } + } + + uint64_t offsets[MAX_TENSOR_ARGS] = {}; + uint64_t buffer_sizes[MAX_TENSOR_ARGS] = {}; + int32_t total_output_size = 0; + for (int32_t i = 0; i < args.tensor_count(); i++) { + offsets[i] = total_output_size; + buffer_sizes[i] = PTO2_ALIGN_UP(args.tensor(i).create_info->buffer_size_bytes(), PTO2_PACKED_OUTPUT_ALIGN); + total_output_size += buffer_sizes[i]; + } + + PTO2TaskAllocResult alloc_result = allocator.alloc(total_output_size); + if (alloc_result.failed()) { + orch->fatal = true; + return result; + } + + int32_t local_id = alloc_result.task_id; + int32_t slot = alloc_result.slot; + PTO2TaskId task_id = PTO2TaskId::make(ring_id, static_cast(local_id)); + + PTO2TaskDescriptor &task = allocator.task_by_slot(slot); + PTO2TaskPayload *payload = &orch->sm_handle->task_payloads[ring_id][slot]; + + for (int32_t i = 0; i < args.tensor_count(); i++) { + __builtin_prefetch(&payload->tensors[i], 1, 3); + __builtin_prefetch(reinterpret_cast(&payload->tensors[i]) + 64, 1, 3); + } + __builtin_prefetch(payload, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 64, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 128, 1, 3); + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.fanin_count = 0; + slot_state.fanout_head = nullptr; + slot_state.fanout_lock.store(0, std::memory_order_relaxed); + slot_state.fanout_count = 1; + slot_state.fanout_refcount.store(0, std::memory_order_release); + slot_state.fanin_refcount.store(0, std::memory_order_release); + slot_state.payload = payload; + slot_state.task = &task; + slot_state.active_mask = 0; + slot_state.subtask_done_mask.store(0, std::memory_order_relaxed); + slot_state.ring_id = ring_id; + scope_tasks_push(orch, &slot_state); + } else { + scope_tasks_push(orch, nullptr); + } + +#if PTO2_PROFILING + if (total_output_size > 0) { + orch->buffers_allocated++; + orch->bytes_allocated += total_output_size; + } +#endif + + task.task_id = task_id; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIC)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV0)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV1)] = INVALID_KERNEL_ID; + task.packed_buffer_base = alloc_result.packed_base; + task.packed_buffer_end = alloc_result.packed_end; + + payload->init(args, result, alloc_result.packed_base, offsets, buffer_sizes); + payload->fanin_actual_count = 0; + payload->fanin_spill_start = 0; + payload->fanin_spill_pool = nullptr; + for (int32_t i = 0; i < args.tensor_count(); i++) { + payload->tensors[i].owner_task_id = task_id; + } + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.task_state.store(PTO2_TASK_COMPLETED, std::memory_order_release); + slot_state.completed_subtasks.store(0, std::memory_order_relaxed); + slot_state.total_required_subtasks = 0; + slot_state.block_num = 1; + slot_state.next_block_idx = 0; + slot_state.dep_pool_mark = orch->rings[ring_id].dep_pool.top; + } + + return result; +} + // ============================================================================= // Flow Control // ============================================================================= diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h index 0d9d94276..904651969 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h @@ -177,6 +177,18 @@ void pto2_scope_end(PTO2OrchestratorState *orch); TaskOutputTensors pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_kernels, const Arg &args); +/** + * Materialize runtime-created OUTPUT tensors without dispatching a worker + * kernel. + * + * This creates an orchestration-only pseudo task that is already in COMPLETED + * state, so returned tensors still participate in scope lifetime management and + * creator-dependency tracking. + * + * Only OUTPUT tensor args are supported. + */ +TaskOutputTensors pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args); + // ============================================================================= // Flow Control // ============================================================================= diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp index 18dc64bda..05c85886e 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp @@ -41,6 +41,10 @@ static TaskOutputTensors submit_task_impl(PTO2Runtime *rt, const MixedKernels &m return pto2_submit_mixed_task(&rt->orchestrator, mixed_kernels, args); } +TaskOutputTensors pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args) { + return pto2_materialize_output_tensors(&rt->orchestrator, args); +} + void pto2_rt_scope_begin(PTO2Runtime *rt) { pto2_scope_begin(&rt->orchestrator); } void pto2_rt_scope_end(PTO2Runtime *rt) { pto2_scope_end(&rt->orchestrator); } @@ -177,6 +181,7 @@ void pto2_set_tensor_data( static const PTO2RuntimeOps s_runtime_ops = { .submit_task = submit_task_impl, + .materialize_output_tensors = pto2_rt_materialize_output_tensors, .scope_begin = pto2_rt_scope_begin, .scope_end = pto2_rt_scope_end, .orchestration_done = pto2_rt_orchestration_done, diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h index f77a3226a..fd2bd0bcf 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h @@ -67,6 +67,7 @@ typedef struct PTO2Runtime PTO2Runtime; // forward declare for ops signatures struct PTO2RuntimeOps { TaskOutputTensors (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + TaskOutputTensors (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); void (*orchestration_done)(PTO2Runtime *rt); @@ -168,6 +169,19 @@ void pto2_runtime_set_mode(PTO2Runtime *rt, PTO2RuntimeMode mode); // Orchestration API (called by orchestration function) // ============================================================================= +/** + * Materialize runtime-managed output tensors without dispatching a kernel. + * + * Intended for orchestration-side accumulator/state allocation that previously + * required submitting an empty hub kernel. The returned tensors keep the same + * scope lifetime and creator-dependency semantics as normal runtime-created + * OUTPUT tensors. + * + * Only OUTPUT tensor args are supported; inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +TaskOutputTensors pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args); + /** * Begin a new scope * diff --git a/src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md b/src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md index e22cf4e0e..73f088f71 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md +++ b/src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md @@ -636,7 +636,6 @@ KERNELS = [ {"func_id": 1, "name": "SF", "source": "aiv/aiv_softmax_prepare.cpp", "core_type": "aiv"}, {"func_id": 2, "name": "PV", "source": "aic/aic_pv_matmul.cpp", "core_type": "aic"}, {"func_id": 3, "name": "UP", "source": "aiv/aiv_online_update.cpp", "core_type": "aiv"}, - {"func_id": 5, "name": "AIV_HUB", "source": "aiv/aiv_hub.cpp", "core_type": "aiv"}, ] ORCHESTRATION = { @@ -660,7 +659,7 @@ void aicpu_orchestration_entry(uint64_t* args, int arg_count) { for (batch_start = 0; batch_start < batch; batch_start += IN_CORE_BATCH) { PTO2_SCOPE() { // Describe accumulator tensors (oi, li, mi) with TensorCreateInfo - // Submit AIV_HUB to initialize accumulators + // Materialize accumulator tensors without dispatching a kernel for (bn = 0; bn < max_bn; bn++) { // Allocate intermediate tensors (sij, pij, mij, lij, oi_new) // Submit QK (CUBE) → SF (VECTOR) → PV (CUBE) → UP (VECTOR) diff --git a/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h b/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h index 1c7e8a8be..b55207641 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h @@ -113,6 +113,7 @@ void pto2_framework_bind_runtime(PTO2Runtime *rt); */ typedef struct PTO2RuntimeOps { TaskOutputTensors (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + TaskOutputTensors (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); void (*orchestration_done)(PTO2Runtime *rt); @@ -155,6 +156,21 @@ static inline TaskOutputTensors pto2_rt_submit_task(const MixedKernels &mixed_ke return rt->ops->submit_task(rt, mixed_kernels, args); } +/** + * Materialize runtime-created OUTPUT tensors without dispatching a kernel. + * + * Use this for orchestration-managed state tensors such as accumulators that + * need normal runtime ownership/lifetime semantics but do not require any + * InCore computation to initialize. + * + * Only OUTPUT tensor args are accepted. Inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +static inline TaskOutputTensors pto2_rt_materialize_output_tensors(const Arg &args) { + PTO2Runtime *rt = pto2_current_runtime(); + return rt->ops->materialize_output_tensors(rt, args); +} + /** * Convenience wrapper: submit an AIC-only task. */ diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp index 940deb886..1bb22b5db 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp @@ -362,6 +362,20 @@ void pto2_scope_end(PTO2OrchestratorState *orch) { // ============================================================================= // Task Submission // ============================================================================= +static bool +pto2_fail_invalid_arg_usage(PTO2OrchestratorState *orch, const Arg &args, const char *header, const char *detail) { + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: %s", header); + LOG_ERROR("========================================"); + LOG_ERROR("Error: %s", detail); + LOG_ERROR(" tensor_count: %d, scalar_count: %d", args.tensor_count(), args.scalar_count()); + LOG_ERROR("This is a bug in the orchestration code."); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_INVALID_ARGS, std::memory_order_release); + orch->fatal = true; + return false; +} + TaskOutputTensors pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_kernels, const Arg &args) { CYCLE_COUNT_START(); @@ -736,6 +750,163 @@ pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_ke return result; } +TaskOutputTensors pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args) { + TaskOutputTensors result; + + if (orch->fatal) { + return result; + } + + if (args.has_error) { + pto2_fail_invalid_arg_usage(orch, args, "Invalid Arg Detected!", args.error_msg ? args.error_msg : "(unknown)"); + return result; + } + + if (args.scalar_count() != 0) { + pto2_fail_invalid_arg_usage( + orch, args, "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports OUTPUT tensors and no scalars" + ); + return result; + } + + for (int32_t i = 0; i < args.tensor_count(); i++) { + if (args.tag(i) != TensorArgType::OUTPUT) { + pto2_fail_invalid_arg_usage( + orch, args, "Invalid materialize_output_tensors Arg!", + "pto2_rt_materialize_output_tensors only supports add_output(TensorCreateInfo)" + ); + return result; + } + } + + if (args.tensor_count() == 0) { + return result; + } + + uint8_t ring_id = orch->current_ring_id(); + auto &allocator = orch->rings[ring_id].task_allocator; + PTO2SchedulerState *sched = orch->scheduler; + + always_assert(orch->scope_stack_top >= 0 && "Cannot materialize output tensors outside a scope"); + + { + int32_t scope_task_count = orch->scope_tasks_size - orch->scope_begins[orch->scope_stack_top]; + if (scope_task_count >= allocator.window_size() - 1) { + int32_t active_count = allocator.active_count(); + + LOG_ERROR("========================================"); + LOG_ERROR("FATAL: Scope Deadlock Detected! (ring %d)", ring_id); + LOG_ERROR("========================================"); + LOG_ERROR( + "Tasks in current scope (%d) >= task_window_size (%d).", scope_task_count, allocator.window_size() + ); + LOG_ERROR(" scope_depth: %d", orch->scope_stack_top + 1); + LOG_ERROR(" ring_id: %d", ring_id); + LOG_ERROR(" scope_task_count: %d", scope_task_count); + LOG_ERROR(" active_tasks: %d / %d", active_count, allocator.window_size()); + LOG_ERROR("Root Cause:"); + LOG_ERROR(" Tasks within a scope hold a fanout_count reference that is only"); + LOG_ERROR(" released at scope_end. When scope task count >= window_size,"); + LOG_ERROR(" no slots can be reclaimed -> deadlock."); + LOG_ERROR("Solution:"); + LOG_ERROR(" 1. Reduce tasks per scope (use batching/unroll)"); + LOG_ERROR(" 2. Increase task window (current: %d)", allocator.window_size()); + LOG_ERROR(" Compile-time: PTO2_TASK_WINDOW_SIZE in pto_runtime2_types.h"); + LOG_ERROR(" Runtime env: PTO2_RING_TASK_WINDOW="); + LOG_ERROR(" 3. Split work across multiple scopes"); + LOG_ERROR("========================================"); + orch->sm_handle->header->orch_error_code.store(PTO2_ERROR_SCOPE_DEADLOCK, std::memory_order_release); + orch->fatal = true; + return result; + } + } + + uint64_t offsets[MAX_TENSOR_ARGS] = {}; + uint64_t buffer_sizes[MAX_TENSOR_ARGS] = {}; + int32_t total_output_size = 0; + for (int32_t i = 0; i < args.tensor_count(); i++) { + offsets[i] = total_output_size; + buffer_sizes[i] = PTO2_ALIGN_UP(args.tensor(i).create_info->buffer_size_bytes(), PTO2_PACKED_OUTPUT_ALIGN); + total_output_size += buffer_sizes[i]; + } + + PTO2TaskAllocResult alloc_result = allocator.alloc(total_output_size); + if (alloc_result.failed()) { + orch->fatal = true; + return result; + } + + int32_t local_id = alloc_result.task_id; + int32_t slot = alloc_result.slot; + PTO2TaskId task_id = PTO2TaskId::make(ring_id, static_cast(local_id)); + + PTO2TaskDescriptor &task = allocator.task_by_slot(slot); + PTO2TaskPayload *payload = &orch->sm_handle->task_payloads[ring_id][slot]; + + for (int32_t i = 0; i < args.tensor_count(); i++) { + __builtin_prefetch(&payload->tensors[i], 1, 3); + __builtin_prefetch(reinterpret_cast(&payload->tensors[i]) + 64, 1, 3); + } + __builtin_prefetch(payload, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 64, 1, 3); + __builtin_prefetch(reinterpret_cast(payload) + 128, 1, 3); + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.fanin_count = 0; + slot_state.fanout_head = nullptr; + slot_state.fanout_lock.store(0, std::memory_order_relaxed); + slot_state.fanout_count = 1; + slot_state.fanout_refcount.store(0, std::memory_order_release); + slot_state.fanin_refcount.store(0, std::memory_order_release); + slot_state.payload = payload; + slot_state.task = &task; + slot_state.active_mask = 0; + slot_state.subtask_done_mask.store(0, std::memory_order_relaxed); + slot_state.ring_id = ring_id; + scope_tasks_push(orch, &slot_state); + } else { + scope_tasks_push(orch, nullptr); + } + +#if PTO2_PROFILING + if (total_output_size > 0) { + orch->buffers_allocated++; + orch->bytes_allocated += total_output_size; + } +#endif + + task.task_id = task_id; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIC)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV0)] = INVALID_KERNEL_ID; + task.kernel_id[static_cast(PTO2SubtaskSlot::AIV1)] = INVALID_KERNEL_ID; + task.packed_buffer_base = alloc_result.packed_base; + task.packed_buffer_end = alloc_result.packed_end; + + payload->init(args, result, alloc_result.packed_base, offsets, buffer_sizes); + payload->fanin_actual_count = 0; + payload->fanin_spill_start = 0; + payload->fanin_spill_pool = nullptr; + for (int32_t i = 0; i < args.tensor_count(); i++) { + payload->tensors[i].owner_task_id = task_id; + } + + if (sched) { + auto &rs = sched->ring_sched_states[ring_id]; + PTO2TaskSlotState &slot_state = rs.get_slot_state_by_slot(slot); + slot_state.task_state.store(PTO2_TASK_COMPLETED, std::memory_order_release); + slot_state.completed_subtasks.store(0, std::memory_order_relaxed); + slot_state.total_required_subtasks = 0; + slot_state.block_num = 1; + slot_state.next_block_idx = 0; + slot_state.dep_pool_mark = orch->rings[ring_id].dep_pool.top; + } + + return result; +} + // ============================================================================= // Flow Control // ============================================================================= diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h index 0d9d94276..904651969 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.h @@ -177,6 +177,18 @@ void pto2_scope_end(PTO2OrchestratorState *orch); TaskOutputTensors pto2_submit_mixed_task(PTO2OrchestratorState *orch, const MixedKernels &mixed_kernels, const Arg &args); +/** + * Materialize runtime-created OUTPUT tensors without dispatching a worker + * kernel. + * + * This creates an orchestration-only pseudo task that is already in COMPLETED + * state, so returned tensors still participate in scope lifetime management and + * creator-dependency tracking. + * + * Only OUTPUT tensor args are supported. + */ +TaskOutputTensors pto2_materialize_output_tensors(PTO2OrchestratorState *orch, const Arg &args); + // ============================================================================= // Flow Control // ============================================================================= diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp index 18dc64bda..05c85886e 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp @@ -41,6 +41,10 @@ static TaskOutputTensors submit_task_impl(PTO2Runtime *rt, const MixedKernels &m return pto2_submit_mixed_task(&rt->orchestrator, mixed_kernels, args); } +TaskOutputTensors pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args) { + return pto2_materialize_output_tensors(&rt->orchestrator, args); +} + void pto2_rt_scope_begin(PTO2Runtime *rt) { pto2_scope_begin(&rt->orchestrator); } void pto2_rt_scope_end(PTO2Runtime *rt) { pto2_scope_end(&rt->orchestrator); } @@ -177,6 +181,7 @@ void pto2_set_tensor_data( static const PTO2RuntimeOps s_runtime_ops = { .submit_task = submit_task_impl, + .materialize_output_tensors = pto2_rt_materialize_output_tensors, .scope_begin = pto2_rt_scope_begin, .scope_end = pto2_rt_scope_end, .orchestration_done = pto2_rt_orchestration_done, diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h index f77a3226a..fd2bd0bcf 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h @@ -67,6 +67,7 @@ typedef struct PTO2Runtime PTO2Runtime; // forward declare for ops signatures struct PTO2RuntimeOps { TaskOutputTensors (*submit_task)(PTO2Runtime *rt, const MixedKernels &mixed_kernels, const Arg &args); + TaskOutputTensors (*materialize_output_tensors)(PTO2Runtime *rt, const Arg &args); void (*scope_begin)(PTO2Runtime *rt); void (*scope_end)(PTO2Runtime *rt); void (*orchestration_done)(PTO2Runtime *rt); @@ -168,6 +169,19 @@ void pto2_runtime_set_mode(PTO2Runtime *rt, PTO2RuntimeMode mode); // Orchestration API (called by orchestration function) // ============================================================================= +/** + * Materialize runtime-managed output tensors without dispatching a kernel. + * + * Intended for orchestration-side accumulator/state allocation that previously + * required submitting an empty hub kernel. The returned tensors keep the same + * scope lifetime and creator-dependency semantics as normal runtime-created + * OUTPUT tensors. + * + * Only OUTPUT tensor args are supported; inputs, inouts, and scalars are + * rejected as orchestration bugs. + */ +TaskOutputTensors pto2_rt_materialize_output_tensors(PTO2Runtime *rt, const Arg &args); + /** * Begin a new scope * diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aic/aic_hub.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aiv/aiv_hub.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/kernel_config.py b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/kernel_config.py index d41b5e595..6e251a567 100644 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/kernel_config.py +++ b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/kernel_config.py @@ -50,13 +50,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, { "func_id": 1, "name": "SF", @@ -71,13 +64,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] RUNTIME_CONFIG = { diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp index 0a99494f3..9a88d2501 100644 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/aicpu_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -22,7 +22,7 @@ * QK → Softmax → PV → Update * └──────────→ Update * Update(prev block) ──→ Update(this block) - * Hub(init) ────────────→ Update(first block) + * Materialize(init) ────→ Update(first block) */ #include @@ -35,8 +35,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 extern "C" { @@ -112,17 +110,17 @@ aicpu_orchestration_entry(PTO2Runtime *rt, const ChipStorageTaskArgs &orch_args) uint32_t out_view_offsets[2] = {static_cast(cur_offset), 0}; Tensor out_view = out.view(out_view_shapes, out_view_offsets); - // Hub task: zero-initialize accumulators + // Materialize accumulator tensors with runtime-managed lifetime. Arg args_inplace; args_inplace.add_output(TensorCreateInfo(oi_shapes, 2, DataType::FLOAT32)); args_inplace.add_output(TensorCreateInfo(li_shapes, 1, DataType::FLOAT32)); args_inplace.add_output(TensorCreateInfo(mi_shapes, 1, DataType::FLOAT32)); - SubmitResult r_hub = pto2_rt_submit_aiv_task(rt, FUNC_AIV_HUB, args_inplace); - const Tensor &oi = r_hub.outputs.get_ref(0); - const Tensor &li_update = r_hub.outputs.get_ref(1); - const Tensor &mi_update = r_hub.outputs.get_ref(2); + SubmitResult r_state = pto2_rt_materialize_output_tensors(rt, args_inplace); + const Tensor &oi = r_state.outputs.get_ref(0); + const Tensor &li_update = r_state.outputs.get_ref(1); + const Tensor &mi_update = r_state.outputs.get_ref(2); - PTO2TaskId prev_update_task = r_hub.task_id; + PTO2TaskId prev_update_task = r_state.task_id; for (uint64_t bn = 0; bn < bn_this_batch; bn++) { uint64_t cur_block_idx = host_block_table[b_idx * block_num + bn]; diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aic/aic_hub.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aiv/aiv_hub.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/kernel_config.py b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/kernel_config.py index d6f67730a..51dcc0040 100644 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/kernel_config.py +++ b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/kernel_config.py @@ -50,13 +50,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, { "func_id": 1, "name": "SF", @@ -71,13 +64,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] RUNTIME_CONFIG = { diff --git a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp index de395858b..b53c3c544 100644 --- a/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/aicpu_build_graph/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp @@ -37,8 +37,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 constexpr uint64_t PLATFORM_PROF_SYS_CNT_FREQ = 50000000; // 50 MHz @@ -188,16 +186,16 @@ aicpu_orchestration_entry(PTO2Runtime *rt, const ChipStorageTaskArgs &orch_args) prof_view_count += 2; CYCLE_COUNT_LAP(prof_tensor_view); #endif - // Hub task: zero-initialize oi, li_update, mi_update + // Materialize accumulator tensors with runtime-managed lifetime. Arg args_inplace; args_inplace.add_output(TensorCreateInfo(oi_shapes, 2, DataType::FLOAT32)); args_inplace.add_output(TensorCreateInfo(li_shapes, 1, DataType::FLOAT32)); args_inplace.add_output(TensorCreateInfo(mi_shapes, 1, DataType::FLOAT32)); CYCLE_COUNT_LAP(prof_param_setup); - SubmitResult r_hub = pto2_rt_submit_aiv_task(rt, FUNC_AIV_HUB, args_inplace); - const Tensor &oi = r_hub.outputs.get_ref(0); - const Tensor &li_update = r_hub.outputs.get_ref(1); - const Tensor &mi_update = r_hub.outputs.get_ref(2); + SubmitResult r_state = pto2_rt_materialize_output_tensors(rt, args_inplace); + const Tensor &oi = r_state.outputs.get_ref(0); + const Tensor &li_update = r_state.outputs.get_ref(1); + const Tensor &mi_update = r_state.outputs.get_ref(2); #ifdef ENABLE_PROFILING prof_submit_count++; CYCLE_COUNT_LAP(prof_submit_task); @@ -207,7 +205,7 @@ aicpu_orchestration_entry(PTO2Runtime *rt, const ChipStorageTaskArgs &orch_args) // repeated stack-frame construction in the inner loop. Arg args_qk, args_sf, args_pv, args_up; - PTO2TaskId prev_update_task = r_hub.task_id; + PTO2TaskId prev_update_task = r_state.task_id; for (uint64_t bn = 0; bn < bn_this_batch; bn += N_UNROLL) { uint64_t n_blocks = std::min(static_cast(N_UNROLL), bn_this_batch - bn); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 28ba31a32..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 28ba31a32..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py index e66b5139a..2c65cfe7b 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py +++ b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/kernel_config.py @@ -51,13 +51,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -73,13 +66,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp index 2afa93b4b..40715f762 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -49,8 +49,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 extern "C" { @@ -134,10 +132,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_hub.add_output(oi_batch_ci); params_hub.add_output(scalar_acc_ci); params_hub.add_output(scalar_acc_ci); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_hub); - const Tensor &oi_batch = hub_outs.get_ref(0); - const Tensor &li_batch = hub_outs.get_ref(1); - const Tensor &mi_batch = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_hub); + const Tensor &oi_batch = state_outs.get_ref(0); + const Tensor &li_batch = state_outs.get_ref(1); + const Tensor &mi_batch = state_outs.get_ref(2); // Inner-loop create infos: shapes are loop-invariant, hoist out of bn loop uint32_t sij_shapes[2] = {static_cast(chunk_bc * q_tile), static_cast(block_size)}; diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py index 68813533f..85f9f6c0e 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index a3c5ed5a8..734fd1a64 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -31,8 +31,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 constexpr uint64_t PLATFORM_PROF_SYS_CNT_FREQ = 50000000; // 50 MHz @@ -160,10 +158,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(scalar_ci); params_inplace.add_output(scalar_ci); CYCLE_COUNT_LAP(prof_param_setup); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); prof_submit_count++; CYCLE_COUNT_LAP(prof_submit_task); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/kernels/kernel_config.py b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/kernels/kernel_config.py index f4d3da4a6..38a799a6d 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/kernels/kernel_config.py +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/kernels/kernel_config.py @@ -50,13 +50,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_PA_KERNELS / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, { "func_id": 1, "name": "SF", @@ -71,13 +64,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_PA_KERNELS / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] RUNTIME_CONFIG = { diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py index 68813533f..85f9f6c0e 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp index f3284f494..48f50b658 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp @@ -35,8 +35,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 constexpr uint64_t PLATFORM_PROF_SYS_CNT_FREQ = 50000000; // 50 MHz @@ -180,10 +178,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(scalar_noinit_ci); params_inplace.add_output(scalar_noinit_ci); CYCLE_COUNT_LAP(prof_param_setup); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); #ifdef ENABLE_PROFILING prof_submit_count++; CYCLE_COUNT_LAP(prof_submit_task); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp index 841bca95d..9de9a3ebd 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp @@ -18,7 +18,7 @@ * 1. c = a + b (kernel_add, runtime-created tensor) * 2. get_tensor_data(c, {0}) → check[0] = 2.0 * 3. get_tensor_data(c, {100}) → check[1] = 102.0 - * 4. scalar_tensor = add_output(TensorCreateInfo, 77.0f), submit noop + * 4. scalar_tensor = materialize output TensorCreateInfo(77.0f) * 5. get_tensor_data(scalar_tensor, {0}) → check[2] = 77.0 * 6. add_inout(scalar_tensor) (INOUT path), submit noop * 7. get_tensor_data(scalar_tensor, {0}) → check[3] = 77.0 @@ -96,6 +96,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip // ========================================================= // Step 4: Runtime-created scalar output with initial value // Runtime allocates HeapRing buffer, writes 77.0 to element [0] + // without dispatching a worker kernel. // ========================================================= uint32_t scalar_shapes[1] = {1}; TensorCreateInfo scalar_ci(scalar_shapes, 1, DataType::FLOAT32); @@ -103,7 +104,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip Arg params_scalar; params_scalar.add_output(scalar_ci); - TaskOutputTensors scalar_outs = pto2_rt_submit_aiv_task(FUNC_NOOP, params_scalar); + TaskOutputTensors scalar_outs = pto2_rt_materialize_output_tensors(params_scalar); const Tensor &scalar_tensor = scalar_outs.get_ref(0); // ========================================================= @@ -164,12 +165,12 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip // ========================================================= // Step 10: Orch→AICore RAW (set_tensor_data → kernel reads) - // Orchestration writes d[0]=10.0 via set_tensor_data, then - // kernel_add reads d as input: e[0] = d[0] + a[0] = 12.0 + // Orchestration materializes d, writes d[0]=10.0 via set_tensor_data, + // then kernel_add reads d as input: e[0] = d[0] + a[0] = 12.0 // ========================================================= Arg params_d; params_d.add_output(inter_ci); - TaskOutputTensors d_outs = pto2_rt_submit_aiv_task(FUNC_NOOP, params_d); + TaskOutputTensors d_outs = pto2_rt_materialize_output_tensors(params_d); const Tensor &d = d_outs.get_ref(0); idx[0] = 0; diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py index 68813533f..85f9f6c0e 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py +++ b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index ac3006fe0..86ffc5444 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -31,8 +31,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 constexpr uint64_t PLATFORM_PROF_SYS_CNT_FREQ = 50000000; // 50 MHz @@ -160,10 +158,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(scalar_ci); params_inplace.add_output(scalar_ci); CYCLE_COUNT_LAP(prof_param_setup); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); prof_submit_count++; CYCLE_COUNT_LAP(prof_submit_task); diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aic/aic_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp deleted file mode 100644 index 45f90aab3..000000000 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/aiv/aiv_hub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) PyPTO Contributors. - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of - * CANN Open Software License Agreement Version 2.0 (the "License"). - * Please refer to the License for details. You may not use this file except in compliance with the License. - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. - * See LICENSE in the root of the software repository for the full text of the License. - * ----------------------------------------------------------------------------------------------------------- - */ -#include -#include - -using namespace pto; - -#ifndef __gm__ -#define __gm__ -#endif - -#ifndef __aicore__ -#define __aicore__ [aicore] -#endif - -constexpr int M = 16; -constexpr int K = 16; -constexpr int N = 16; - -extern "C" __aicore__ void kernel_entry(__gm__ int64_t *args) {} diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py index 9bae1cacf..0b840a04e 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py +++ b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/kernel_config.py @@ -53,13 +53,6 @@ "core_type": "aic", "signature": [D.IN, D.IN, D.OUT], }, - { - "func_id": 4, - "name": "AIC_HUB", - "source": str(_KERNELS_ROOT / "aic" / "aic_hub.cpp"), - "core_type": "aic", - "signature": [], - }, # AIV kernels (vector operations) { "func_id": 1, @@ -75,13 +68,6 @@ "core_type": "aiv", "signature": [D.IN, D.IN, D.IN, D.INOUT, D.INOUT, D.INOUT, D.INOUT], }, - { - "func_id": 5, - "name": "AIV_HUB", - "source": str(_KERNELS_ROOT / "aiv" / "aiv_hub.cpp"), - "core_type": "aiv", - "signature": [], - }, ] # Runtime configuration diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp index 81b7e2ca8..2225cff81 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp @@ -35,8 +35,6 @@ #define FUNC_SOFTMAX_PREPARE 1 #define FUNC_PV_MATMUL 2 #define FUNC_ONLINE_UPDATE 3 -#define FUNC_AIC_HUB 4 -#define FUNC_AIV_HUB 5 constexpr uint64_t PLATFORM_PROF_SYS_CNT_FREQ = 50000000; // 50 MHz @@ -179,10 +177,10 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const Chip params_inplace.add_output(scalar_noinit_ci); params_inplace.add_output(scalar_noinit_ci); CYCLE_COUNT_LAP(prof_param_setup); - TaskOutputTensors hub_outs = pto2_rt_submit_aiv_task(FUNC_AIV_HUB, params_inplace); - const Tensor &oi = hub_outs.get_ref(0); - const Tensor &li_update = hub_outs.get_ref(1); - const Tensor &mi_update = hub_outs.get_ref(2); + TaskOutputTensors state_outs = pto2_rt_materialize_output_tensors(params_inplace); + const Tensor &oi = state_outs.get_ref(0); + const Tensor &li_update = state_outs.get_ref(1); + const Tensor &mi_update = state_outs.get_ref(2); #ifdef ENABLE_PROFILING prof_submit_count++; CYCLE_COUNT_LAP(prof_submit_task);