打开文档导航

stratum:Agent 生成 Python pipeline 的 logical optimizer

Primary source: stratum: A System Infrastructure for Massive Agent-Centric ML Workloads

一句话

stratum 是当前最接近 Pysolate pass 方向的工作:它把 Agent 生成的 Python ML pipeline 变成 declarative graph,再做 read sharing、CSE、constant folding、predicate pushdown 和 vectorization。

原工作做了什么

stratum 面向大量相似的 Agent-generated ML pipelines。每个 pipeline 由 DataOps 和 UDFs 组成,系统在多个 variant 之间发现共享工作,并选择逻辑和物理优化。论文还讨论 cache、copy-on-write、approximate operator 和 lower-fidelity execution。

它比纯 serving scheduler 更相关,因为一部分收益确实来自 program rewrite,而不是只改变请求顺序。

可以吸收的 pass

  • pure_region_fold:提前计算 exact pure expression;
  • effectful_cse:共享 exact pure operation 或 frozen-root read;
  • capability_projection_pushdown:把 filter、slice 或 projection 下推到 Host capability;
  • batch_map_fusion:把已知逐项 API 调用改写为等价 batch/vectorized API。

Pysolate 不需要采用 DataOp DSL。Exact target-CPython AST 和 semantic effect facts可以发现较窄的 rewrite candidate,再由 Host adapter 提供 versioned rewrite law。

Correctness 与副作用

论文使用 semantic-equivalence 表述 logical rewrite,也会把没有稳定 seed 的 nondeterministic operation 排除出 cache。这比只看任务成功率更接近 compiler correctness。

边界仍然明显:

  • arbitrary Python UDF 对 optimizer 是 black box;
  • vectorized implementation 可能改变 exception order、floating-point reduction、aliasing 和 in-place behavior;
  • cache correctness依赖 operation implementation、seed 和 data identity;
  • approximate operator 与 lower-fidelity execution明确允许结果变化;
  • 论文没有给出外部 effect rollback contract。

Pysolate 结论

Pysolate 可以吸收 stratum 的 exact logical rewrite kernels,但不能把它的 approximate execution、cache policy、backend selection 或 physical scheduler都叫 pass。每条 rewrite law 需要绑定 capability版本、参数、freshness、workspace root、exception semantics 和 detached-result behavior。

最适合的首个对照是 effectful_cse。同一个 frozen workspace root 上的 exact read 可以只做一次 physical observation,同时保留多个 logical occurrences、预算和 receipts。Live reads、mutable return identity 和 external writes 必须拒绝。

当前吸收状态

pure_scalar_cse 已吸收纯重复计算的极窄子集;pure_scalar_fold 进一步吸收了 constant folding kernel:仅对完整 final source 中的 closed top-level scalar program,折叠 bool/signed-int64 +-* 表达式;出现 import、call、control flow、 unsupported assignment 或 compiled-code introspection 时整条 pass not_applicable。 两者都通过 exact Guest 产生并重推导 source patch,不拥有 Broker、workspace 或 external authority。

这只证明两个 bounded logical kernels 已被实现,不代表复现了 stratum 的 DataOp optimizer。新的 fold fixture 在两次 matched exact-Guest 运行中仍为负收益;保留的 一轮 treatment 比 baseline 慢 4.49%,因此不能推出一般性能收益。