Add: support dynamic Graph boundary scalars - #1732
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughGraph execution now supports dynamic boundary scalars. Scalar provenance is recorded in graph definitions, submitted separately, materialized with validation, and refreshed during affine replay. Cacheability, storage sizing, orchestration, documentation, and tests now cover scalar bindings. ChangesDynamic boundary scalar execution
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
建议:放宽"边界 scalar 传了必须全部被绑定"这条约束
recording.boundary_scalar_used.size() != recording.boundary_args->scalar_count() ||
std::any_of(boundary_scalar_used.begin(), boundary_scalar_used.end(),
[](bool used) { return !used; }) ||失败后在 debug_assert(false && "The recorded Graph contains a construct that Graph Execution does not support");
LOG_WARN("[GraphExecution] unsupported construct observed; definition was not cached");
return;即 debug 构建直接 assert 中止,release 退回普通提交、永不缓存。 问题:这条"传了必须全用"缺乏既有惯例支撑,且与本特性内部不一致。
于是出现同一特性内部的不对称:边界 tensor 传了不用没事,边界 scalar 传了不用就 assert。而技术上,一个未绑定的边界 scalar 与一个未消费的边界 tensor 等价——都只是 wire 镜像里的一份 dead data,不构成正确性风险。 建议放宽为:未被任何内部 task 绑定的边界 scalar 直接当静态数据处理 / 忽略,对齐边界 tensor 的行为,不再据此拒绝缓存,也移除 这么做的收益:允许"为统一不同 variant 的边界签名而携带某些 variant 用不到的 scalar"这类合理写法;避免调用方在 debug 下因为多传一个暂未使用的 scalar 而被 assert 打断,却无法从当前文档( |
- preserve boundary scalar provenance through direct and copied args - serialize current scalar bindings and refresh them during Graph replay - allow unused boundary scalars without creating node patches - document that host-derived plain scalar values become static Definition data - keep construction config in the cache key and reject mutable tracked scalars Refs hw-native-sys#1712
114188a to
eca540b
Compare
|
@ChaoZheng109 Addressed the latest feedback:
|
Ports a2a3 host_build_graph PR #1732 to A5. The A5 runtime was ported in #1733 from an a2a3 snapshot predating #1732; the parity follow-ups #1736/#1737 it promised were never opened, so A5 has been missing dynamic Graph boundary scalar support. Mirrors #1732 line-for-line (the two trees are structurally identical on this surface): - Arg tracks scalar provenance (source pointer + invalidation flag) across add_scalars/add_scalars_i32/add_scalar_one/copy_scalars_from; a mutable scalar() access invalidates a forwarded boundary source so it is re-read at replay. - New wire/POD types GraphScalarSource, GraphScalarSourceRef, GraphScalarPatch; GraphDefinition gains boundary_scalar_count and off_scalar_sources; GraphSubmission replaces its reserved pad with scalars_offset + scalar_count. - graph_execution_storage_layout/_bytes gain a scalar_patch_capacity argument; all call sites updated together. - Recording classifies each scalar as static or boundary; the Definition stores boundary provenance, and first materialization plus affine replay refresh only the dynamic scalar slots. - rt_graph_args_cacheable and rt_submit_graph_impl drop the scalar_count()==0 rejection that previously forbade boundary scalars. Verified: full no-hardware C++ unit suite (92/92, including new test_a5_graph_cache boundary-scalar cases) and the A5 graph_execution a5sim scenes (3/3).
Summary
Testing
test_graph_cache: 8 passedtask-submit: 3 passedtask-submit: 1 passedClose [Feature] hbg: Support dynamic boundary scalars in Graph Execution (Step 2) #1712