已合并
【feat】: JIT 调度与切图解耦,开启自动融合时整图jit执行 #4566
chengyutao3创建于 10 天前
【feat】: JIT 调度与切图解耦,开启自动融合时整图jit执行 #4566
已合并
chengyutao3创建于 10 天前
chengyutao3
chengyutao3成员
10 天前

Pull Request

描述

本 PR 将 AutoFuse JIT 执行能力从“支持切片调度的图”扩展为“整图 JIT”模式。

主要变更内容如下:

  1. 新增 EnableAutoFuse(),统一判断 AutoFuse 是否启用,并将 AutoFuse 模式下的图管理、编译、加载、执行及运行模式设置统一路由至 UserGraphsManager
  2. 扩展 UserGraphControl,支持整图的动态添加、编译、加载和执行:
    • 支持 ge::Tensorgert::Tensor 两类输入输出。
    • 支持普通执行和带 Stream 的异步执行。
    • 支持保存、获取和设置 RunGraphMode
    • 在控制器结束时清理临时创建的整图实例。
  3. 调整执行顺序生成逻辑:
    • 支持切片调度的图继续执行符号推导和二分切图。
    • 不支持切片调度的图直接以整图方式编译执行。
    • 整图模式下提前创建或更新 NetOutput,确保输出大小信息能够正确校正。
    • 增加 WholeGraph_SlicedGraph_ 图 Dump 前缀,便于区分调试产物。
  4. 调整 Session 和 GeSession V2 的接口调用:
    • AutoFuse 模式下,RunGraphRunGraphWithStreamAsync、编译及加载流程统一使用 JIT 图管理路径。
    • AutoFuse 模式下禁止设置或更新图常量内存、Feature 内存,并将错误提示从“slice scheduler”更新为“JIT executor”。
    • 避免在 AutoFuse 模式下重复执行传统图加载逻辑。
  5. 移除原有“不支持 Slice Schedule 图”的黑名单逻辑,改为在 AutoFuse 模式下统一创建 UserGraphControl,由执行顺序决定采用切片编译或整图编译。
  6. 更新 AutoFuse 系统测试,使其通过真实的 CompileGraph 流程触发编译,并从 JIT 编译缓存中的图副本检查融合结果。
  7. 新增和完善相关单元测试,覆盖:
    • 整图静态 Shape 执行。
    • GeTensorgert::Tensor 输入输出执行。
    • Stream 异步执行。
    • AutoFuse 模式下 RunGraphMode 的获取与设置。
    • AutoFuse 模式下图内存接口不支持场景。
  8. 调整测试图输入尺寸及相关测试构建头文件路径,以适配整图 JIT 流程。

变更类型

请选择本次引入的变更类型:

关联的Issue

暂无关联 Issue。

如何测试

描述测试此变更的步骤和前提条件:

前提条件:

  • 已完成 GE 项目依赖和编译环境配置。
  • 测试环境支持 GE UT/ST 构建。
  • AutoFuse 测试需要设置 AUTOFUSE_FLAGS,启用 --enable_autofuse=true;涉及切片调度的测试还需要启用 --experimental_enable_jit_executor_v2=true
  1. 编译 GE 相关组件及测试目标:

    bash build.sh --ge_compiler --ge_executor
    
  2. 编译并运行 JIT Execution 相关单元测试,重点检查以下测试文件:

    • tests/ge/ut/ge/jit_execution/execution_order_unittest.cc
    • tests/ge/ut/ge/jit_execution/jit_executor_unittest.cc
    • tests/ge/ut/ge/jit_execution/user_graph_ctrl_unittest.cc
    • tests/ge/ut/ge/jit_execution/user_graph_manager_unittest.cc
  3. 运行 Session V2 API 单元测试,重点验证 AutoFuse 模式下图执行及图内存接口行为:

    • tests/ge/ut/ge/session_v2/ge_api_v2_unittest.cc
    • SliceSchedule_UnsupportedPaths
  4. 运行 AutoFuse 系统测试:

    • tests/ge/st/testcase/autofuse/autofuse_canfuse_test.cc

    验证水平融合、垂直融合以及不同算子组合的融合结果,并确认测试通过 Session::CompileGraph 触发真实 JIT 编译,从 JIT 编译图副本中检查 AscBackend 和融合属性。

  5. 重点验证以下场景:

    • 支持 Slice Schedule 的图仍可正常切片编译。
    • 不支持 Slice Schedule 的图可以通过整图 JIT 路径完成编译、加载和执行。
    • 普通 RunGraphRunGraphAsync 以及 RunGraphWithStreamAsync 路径均能正确路由。
    • AutoFuse 模式下设置图常量内存或 Feature 内存时返回 UNSUPPORTED,且日志提示为 JIT executor 不支持。

核对清单

其他信息

  • 本次提交共修改 19 个文件,新增约 495 行代码,删除约 187 行代码。
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chengyutao3 的贡献)
chengyutao3chengyutao3成员
10 天前 添加了label:enhancement
chengyutao3chengyutao3成员
10 天前 创建了 pull request,commit 2e3e1d89
atomgit-bot
atomgit-bot
10 天前 评论:

变更摘要

本 PR 将 AutoFuse JIT 执行能力从「仅支持切片调度图」扩展为「整图 JIT」模式:新增统一的 EnableAutoFuse() 判断入口,AutoFuse 开启时所有图统一路由至 UserGraphsManager,由执行顺序决定走切片编译还是整图编译;扩展 UserGraphControl 以支持整图动态添加、编译、加载与执行,并在 Session/GeSession 接口层将相关路径统一收敛到 JIT 图管理,同时移除「不支持 Slice Schedule」的黑名单回退逻辑。

主要改动

  • 新增 EnableAutoFuse() 统一开关:在 option_utils.cc/h 中新增 EnableAutoFuse()(仅判断 --enable_autofuse=true),UserGraphsManagerUserGraphControl 及 Session 接口的判断由 EnableSliceSchedule()/黑名单切换为 EnableAutoFuse(),AutoFuse 模式下图管理、编译、加载、执行统一走 UserGraphsManager
  • 扩展 UserGraphControl 支持整图 JIT:新增 EnsureWholeGraphAddedEnsureWholeGraphCompiledEnsureWholeGraphLoaded 以及 ge::Tensor/gert::Tensor 两个 RunGraph 重载和 RunGraphWithStreamAsync,并支持 RunGraphMode 的获取与设置;Finalize() 结束时清理临时创建的整图实例。
  • 调整执行顺序生成逻辑ExecutionOrder::AddNewSliceslice_supported 为 true 的图继续符号推导与二分切图,对不支持切片的图直接以整图编译,并提前调用 CreateOrUpdateNetoutput() 校正输出大小;Dump 前缀区分 WholeGraph_SlicedGraph_UserGraph.slice_supported 字段在 execution_order.h 中新增。
  • 移除黑名单并路由 Session 接口:删除 UserGraphsManager 中的 slice_schedule_unsupported_set_ 黑名单,新增 RunGraphRunGraphWithStreamAsyncGetRunGraphModeSetRunGraphMode 接口;InnerSessionRunGraphRunGraphWithStreamAsyncGetRunGraphModeSetRunGraphMode 均改经 user_graphs_manager_ 分发。
  • 更新图内存接口限制与错误提示ge_api.cc/ge_api_v2.ccSetGraphConstMemoryBaseUpdateGraphFeatureMemoryBaseSetGraphFixedFeatureMemoryBaseWithTypeUpdateGraphRefreshableFeatureMemoryBase 的判断由 EnableSliceSchedule() 改为 EnableAutoFuse(),返回 UNSUPPORTED 时的提示信息由「slice scheduler」更新为「JIT executor」;GeSession::RunGraph 在 AutoFuse 模式下跳过传统 LoadGraph 加载逻辑。
likedislike
atomgit-bot
atomgit-bot
10 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:cann-cla/yes
此处折叠了51条消息 查看更多
chengyutao3
chengyutao3成员
10 天前 评论:

/check-pr

likedislike
CANN-robot
CANN-robot成员
10 天前 评论:

The following label is not ready.

approved: Please wait for committers to review the code.

likedislike
yangyongqiang
yangyongqiang成员
10 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:approved
CANN-robotCANN-robot成员
10 天前 合入了pull request