# 動態計算路由 v0.1
## 多域、多範式與異質轉移律的 Runtime 組合

**Dynamic Computational Routing v0.1: Runtime Composition Across Domains, Computational Forms, and Transition Laws**

- 編號：EML-GCM-2026-03-v0.1
- 日期：2026-08-23
- 作者：Neo.K
- 協作：Aletheia / GPT
- 狀態：Runtime 方法論 / 工程形式化草案
- 邊界聲明：本文不是一個保證全域最優的 scheduling algorithm，而是提出一個可被多種 scheduler、planner、agent 或 optimizer 實作的 routing contract。

---

## 摘要

若計算 24/72 被重新定位為可尋址的 computational configuration space，下一個問題就是 Runtime 如何實際選擇與切換這些配置。本文提出「動態計算路由」（Dynamic Computational Routing, DCR）：對每個作用域、任務與 world state，Runtime 不只決定在哪個資源執行，也決定採用何種 computational form、transition law、resolution、materialization level 與 scheduling mode。

本文提出 routing map：

$$
\boxed{
\mathcal R_t:
(D_i,T_i,W_t,\mathcal C_t,\mathcal B_t)
\mapsto
(p_i,\ell_i,\lambda_i,r_i,\tau_i)
}
$$

其中 $p_i$ 為 computational form、 $\ell_i$ 為 transition law、 $\lambda_i$ 為 resolution/materialization policy、 $r_i$ 為 resource target、 $\tau_i$ 為 execution order/time slot。

本文進一步提出 Global Composition Contract：不同 domain 的 local executor 可以異質，但其 commit 必須通過 global constraint reconciliation。由此，全域 Runtime 被拆成 resolve、route、execute、reconcile、commit、observe 六個主要階段。

核心命題是：

$$
\boxed{
\text{Scheduling}
\subset
\text{Computational Routing}
}
$$

因為 routing 不只處理「when/where」，也處理「how」。

---

# 1. 從 scheduling 到 routing

傳統 scheduler 通常回答：

- 哪個 task 先跑？
- 跑在哪個 processor？
- 分配多少 resource？
- 是否需要 migration？

這些問題非常重要，且 heterogeneous computing、edge/cloud、task graph runtime 已有大量研究。

本文新增：

- task 應用何種 computational form？
- 應用何種 transition law？
- 需要何種 materialization？
- 是否需要 full precision？
- 是否可 retrieval 代替 recomputation？
- 是否可 coarse solver 先行？
- 是否需 observer-specific projection？

因此：

$$
\boxed{
\text{Routing}
=
\text{Form Selection}
+
\text{Law Binding}
+
\text{Resource Mapping}
+
\text{Resolution Selection}
+
\text{Scheduling}.
}
$$

---

# 2. Routing input

令 routing input：

$$
I_t
=
(D,T,W,C,B,H,O).
$$

其中：

- $D$：domain；
- $T$：task / transformation request；
- $W$：world state；
- $C$：constraints；
- $B$：budget；
- $H$：history；
- $O$：observer/request context。

Routing output：

$$
\boxed{
R_t
=
(p,\ell,\lambda,r,\tau,\kappa).
}
$$

其中 $\kappa$ 是 confidence / contract metadata。

---

# 3. Domain-specific routing

Runtime 不要求：

$$
p_1=p_2=\cdots=p_n.
$$

相反：

$$
\Gamma_t(D_i)=c_i.
$$

不同 domain 可以同時：

```text
Physics field
→ continuous + parallel + deterministic

Knowledge lookup
→ discrete + retrieval + deterministic/probabilistic

Agent planner
→ discrete + jump + probabilistic

Quantum subroutine
→ quantum-channel-like transition
```

全域的工作是管理 coupling，而不是消除差異。

---

# 4. Routing policy

定義：

$$
\boxed{
\mathcal R_t
=
\operatorname{Select}
\left(
I_t,
\mathfrak P,
\mathfrak L,
\mathcal Q_t
\right)
}
$$

其中 $\mathcal Q_t$ 是可用 resource/capability set。

Selection criterion 可以包含 latency、cost、energy、fidelity、risk 等：

$$
J
=
w_L L
+
w_C C
+
w_E E
+
w_F F
+
w_R R.
$$

但本文強調：

$$
\boxed{
\text{Routing}
\neq
\text{Optimization only}.
}
$$

有些條件是 legality，不可被 weighted score 抵消。

---

# 5. Admissibility First

令：

$$
\mathcal A(R)=1
$$

表示 route admissible。

先求：

$$
R\in\mathcal A_t.
$$

再：

$$
R_t^*
=
\arg\min_{R\in\mathcal A_t}
J(R).
$$

因此：

$$
\boxed{
\text{Admissibility First}
\rightarrow
\text{Optimization Second}.
}
$$

這避免一個低延遲但違反 invariant 的 route 因 score 較低而被採用。

---

# 6. Local Executor Contract

每個 executor 暴露：

```text
capabilities
input schema
output schema
cost model
precision model
side effects
required invariants
history semantics
failure modes
```

形式化：

$$
E_i
=
\langle
Cap_i,
In_i,
Out_i,
Cost_i,
Prec_i,
Side_i,
Inv_i,
Fail_i
\rangle.
$$

Runtime 不需要理解 executor 內部所有細節，只需要理解可組合 contract。

---

# 7. Compose 不等於 Concatenate

即使：

$$
E_a
$$

與：

$$
E_b
$$

各自成功，也不代表：

$$
E_b\circ E_a
$$

合法。

Reconciler 必須檢查：

- write/write conflict；
- resource conflict；
- invariant conflict；
- causal order；
- transaction boundary；
- state class compatibility；
- version compatibility。

因此：

$$
\boxed{
\operatorname{Compose}
\neq
\operatorname{Concatenate}.
}
$$

---

# 8. Runtime Pipeline

```text
1. Resolve Domain
2. Infer Task Semantics
3. Enumerate Candidate Configurations
4. Bind Transition Law
5. Select Resolution / Materialization
6. Map Resource
7. Schedule
8. Execute Local Solver
9. Reconcile Global Constraints
10. Commit State
11. Emit Receipt
12. Project to Observer
```

這裡最重要的是第 9 與第 10 步：local success 不等於 global commit。

---

# 9. Candidate generation

候選：

$$
\mathcal K_t
=
\{
(p,\ell,\lambda,r)
\mid
\operatorname{Compatible}(D,T,W)
\}.
$$

Runtime 可使用：

- rule-based filter；
- planner；
- learned router；
- bandit；
- search；
- heuristic；
- static compiler hint；
- theorem/proof constraint。

理論不綁死 selection algorithm。

---

# 10. Configuration Switching

若：

$$
c_i(t)=c_a
$$

而：

$$
c_i(t+1)=c_b,
$$

需建立：

$$
\boxed{
\operatorname{SwitchReceipt}
=
\langle
D_i,
c_a,
c_b,
reason,
epoch,
cost,
state\_bridge
\rangle.
}
$$

這使 configuration switching 成為可追溯事件。

---

# 11. Representation Bridge

假設 continuous field：

$$
u(x,t)
$$

切成 discrete mesh：

$$
\{u_i\},
$$

需要：

$$
B_{C\to D}.
$$

反向：

$$
B_{D\to C}.
$$

一般：

$$
\boxed{
B_{p\to q}
:
S_p
\to
S_q.
}
$$

沒有 bridge，就不能宣稱 computational-form switching 合法。

---

# 12. Lossy Bridge

某些 bridge 不可逆：

$$
B_{q\to p}
\circ
B_{p\to q}
\neq
I.
$$

因此 receipt 應記：

$$
\epsilon_{\mathrm{bridge}}
$$

或至少標記：

```text
lossless / lossy / unknown
```

這使 resolution change 不再只是 UI 細節，而是 computational semantics。

---

# 13. Resource-aware routing

異質硬體意味：

$$
Cost(T,r_1)
\neq
Cost(T,r_2).
$$

同時還有 communication：

$$
Comm(D_i,D_j,r_i,r_j).
$$

所以：

$$
C_G
=
\sum_i Cost_i
+
\sum_{i,j}Comm_{ij}
+
ReconcileCost.
$$

只優化 local kernel speed 可能反而讓 global system 更慢。

---

# 14. Edge / Cloud / Local AI

一個 AI-native Runtime 可路由：

- local device；
- edge；
- cloud；
- accelerator；
- retrieval service；
- remote model；
- specialized solver。

即：

$$
T
\to
\{
local,
edge,
cloud,
retrieval,
accelerator,
remote
\}.
$$

現代 edge/cloud 研究已顯示 heterogeneous resource scheduling、communication latency 與 workload uncertainty 是實際問題。DCR 將此再延伸到 computational form selection。

---

# 15. Asynchronous Routing

Global 不要求 global barrier。

允許：

$$
D_i(t_i)
$$

使用不同 local clock。

全域 commit 可以採：

- strong synchronization；
- bounded staleness；
- causal consistency；
- eventual reconciliation；
- transaction batch。

因此：

$$
\boxed{
\text{Global}
\neq
\text{Global Barrier}.
}
$$

---

# 16. Execute / Defer / Refuse / Idle / Escalate

Routing output 不必只有 Execute。

定義：

$$
a_t
\in
\{
Execute,
Defer,
Refuse,
Idle,
Escalate
\}.
$$

若：

- legality 不明；
- resource 不足；
- bridge 不存在；
- confidence 過低；

則 Defer 或 Escalate 可能比硬算更正確。

---

# 17. Observer-aware，但 Observer 不持有 World

Observer request 可以影響 projection resolution：

$$
\lambda_O.
$$

但不應默認改 canonical world：

$$
\boxed{
\Delta O
\not\Rightarrow
\Delta W.
}
$$

除非 Observer 發出明確 world-changing command。

---

# 18. Runtime Receipt

每次 route 應產生：

```text
domain
task
form
law
resolution
resource
schedule
inputs
outputs
constraints
bridge
commit status
cost
failure
parent receipt
```

因此：

$$
\mathcal H
=
\{R_0,R_1,\ldots,R_t\}.
$$

這使 Runtime 可 audit、replay、compare。

---

# 19. 與現有 scheduling research 的差異

近年的 OpenMP Cluster、dataflow runtime、edge-cloud scheduling、computing-aware routing 都在處理 heterogeneous resource scheduling。

本文的擴張是：

$$
\boxed{
\text{Device / Resource Selection}
\subset
\text{Computational Routing}.
}
$$

因為 routing 還包含：

- computational form；
- transition law；
- resolution；
- representation bridge。

---

# 20. AI-native Router

AI 可以成為 router policy 的一種實作：

輸入：

$$
(task,state,history,resource,constraint)
$$

輸出：

$$
(route,confidence,reason).
$$

但最後由 deterministic / formal validator 檢查 admissibility：

$$
\boxed{
\text{AI proposes}
\rightarrow
\text{Runtime validates}
\rightarrow
\text{World commits}.
}
$$

這避免把 AI inference 與 canonical commit 混成同一件事。

---

# 21. 失效模式

## 21.1 Thrashing

configuration 每 tick 來回切換。

可引入 hysteresis：

$$
Switch
\quad\text{only if}\quad
\Delta J>\tau.
$$

## 21.2 Bridge Explosion

form switching 太頻繁，轉譯成本大於計算收益。

## 21.3 Reconciliation Bottleneck

local execution 很快，但 global commit 太慢。

## 21.4 Hidden History Cost

active tasks 很少，但 Runtime 每 tick scan 全 history。

## 21.5 Observer-triggered Recomputation

UI/observer 變動造成不必要 world recomputation。

這些失效模式都應被 benchmark，而不能只停在概念層。

---

# 22. 最小演算法

```pseudo
Input:
    world W_t
    tasks T_t
    domains D_t
    resource state Q_t
    constraints C_t

For each task T_i:
    D_i = ResolveDomain(T_i, W_t)

    K_i = EnumerateConfigurations(
        D_i, T_i, P, L, Q_t
    )

    K_i = FilterAdmissible(K_i, C_t)

    route_i = Select(K_i)

Schedule routes with dependency constraints

For each ready route_i:
    output_i = Execute(route_i)

proposal = Aggregate(outputs)

if Reconcile(proposal, W_t, C_t) == PASS:
    W_{t+1} = Commit(proposal)
    EmitReceipt()
else:
    Refuse / Defer / Retry / Escalate

Project W_{t+1} to observers
```

---

# 23. 實驗路線

## Experiment A — Fixed vs Dynamic Configuration

同一 workload，比較固定 configuration 與 dynamic router。

## Experiment B — Resource Shift

運行中移除 GPU 或加入 accelerator，測試 router 是否能重配置。

## Experiment C — Resolution Shift

同一 domain 在 coarse / fine materialization 間切換，量測 bridge cost。

## Experiment D — Retrieval vs Recompute

已有結果時比較 retrieval path 與 recomputation。

## Experiment E — Heterogeneous Transition Laws

不同 domain 採 deterministic / stochastic update，測試 global reconciliation。

---

# 24. 結論

Dynamic Computational Routing 把 scheduler 放入更大的 Runtime 問題：

$$
\boxed{
\text{Routing}
=
\text{choose how, where, when, and at what resolution computation occurs}.
}
$$

它使 24/72 從分類學真正變成 Runtime configuration space，也把 Global Computation 從抽象命題接到工程控制面。

最終：

$$
\boxed{
\Gamma_t
\xrightarrow{\mathcal R_t}
\Gamma_{t+1}
}
$$

其中不只 world state 在演化，**計算世界的方法也在演化。**

---

## 參考文獻與相關工作

1. Boné, A. et al. *A task-based data-flow methodology for programming heterogeneous systems with multiple accelerator APIs*. 2026.
2. De Matteis, T. et al. *Streaming Task Graph Scheduling for Dataflow Architectures*. 2023.
3. *Towards an Optimized Heterogeneous Distributed Task Scheduler in OpenMP Cluster*. IEEE SC24-W, 2024.
4. *CaRCS: Joint Optimization of Computing-Aware Routing and Collaborative Scheduling in Computing Power Networks*. IEEE Network, 2025.
5. *Cloud-Edge System for Scheduling Unpredictable LLM Requests With Combinatorial Bandit*. IEEE Transactions on Services Computing, 2025.
6. Wang, Y. & Yang, X. *Research on Edge Computing and Cloud Collaborative Resource Scheduling Optimization Based on Deep Reinforcement Learning*. 2025.
