Skip to content

Add: strengthen TMR kernel-mode eager and ACLGraph scene tests - #2253

Open
Leaf-Salix wants to merge 1 commit into
hw-native-sys:feat/kernel-mode-integration-testfrom
Leaf-Salix:test/tmr-kernel-st-strengthening
Open

Leaf-Salix wants to merge 1 commit into
hw-native-sys:feat/kernel-mode-integration-testfrom
Leaf-Salix:test/tmr-kernel-st-strengthening

Conversation

@Leaf-Salix

Copy link
Copy Markdown
Contributor

Motivation

feat/kernel-mode-integration-test255915991d3e05d9290b056b822040b1e81fbeb6 基础上,补强 TMR kernel-mode eager / ACLGraph 真机 ST。继承 #2242 的正式 kernel C API 场景及 #2249 的同步 prepare 契约,仅修改测试,不修改生产 runtime、公开 ABI 或 program 模式

相对目标分支,场景由 24 项增加至 34 项:新增 10 项,同时加强原有 A/B/A、DAG 和资源检查。不是把重复 replay 次数当作新的覆盖面。

Kernel-mode ST construction

真实 TMR orchestration + 真实 AIV CoreCallable
  → simpler_kernel_mode_init
  → caller-owned Device tensor
  → simpler_kernel_mode_prepare_callable(同步完成注册)
  ├─ eager:simpler_kernel_mode_launch
  └─ graph:capture kernel launch → replay
  → 外部同步 → Device 数值 / 调度状态 / 资源检查
  → graph 销毁 → context finalize → caller 资源释放

全部新增场景经真实 kernel-mode C API 和 CANN 执行,不使用 program Worker.run,不是 UT 或 fake-runtime 验证。

Coverage matrix

场景 本 PR 变化 构造及独立验收点
multi_callable, eager_multi_callable 加强已有 2 项 A/B/A 使用相同 func_id=0、不同 child 二进制(add 与 reflect);数值区分函数表串用,graph 保留独立执行计数
tmr_dag, eager_dag 加强已有 2 项 线性链改为真实分叉/汇合,使用 runtime intermediate tensor,验证分支依赖及复用
mixed_stream_eager, mixed_stream_graph 新增 2 项 同 caller stream 上普通 AIV → TMR → 普通 AIV,无中间 Host 同步,校验三个阶段结果
geometry_snapshot 新增 1 项 两张图分别固定合法 shape 128/257,中间穿插 shape 65 的 eager;检查描述符快照隔离及输出尾部不越写,不宣称单图动态 shape
graph_survivor 新增 1 项 G1/G2 共存,销毁 G1 后 G2 继续执行,再创建 G3,与 G2 交替使用
context_lifecycle 新增 1 项 拒绝冲突 context 不影响已有 context;销毁图并关闭旧 context 后,重建 context、prepare、capture/replay
ring_wrap_eager, ring_wrap_graph 新增 2 项 单次 invocation 257 个 task,ring window=64;合法分段 scope 控制存活量,验证窗口回绕、回收与重复复用
early_dispatch_eager, early_dispatch_graph 新增 2 项 延迟 producer+依赖 consumer;scope 保住 task,读取真实 payload 的 early_dispatch_launch_state=COMPLETE 并输出标记,同时校验数值。普通路径也会写的 early_dispatch_state=DISPATCHED 不作命中证明
callable_growth 新增 1 项 根据镜像实际大小计算越过 2 MiB 分配块的最少注册次数;验证 committed 增加后,旧捕获图及最新 cid 串接仍正确
同步及资源 observer 加强共同检查 prepare 确认私有注册 stream 成功同步;launch 内仍禁止同步。拦截受测接口中直接来自 libhost_runtime 的 alloc/free、stream/event 创建、H2D 请求;不把 CANN 内部保存 graph 参数的分配算作 Simpler 违规

其余冷捕获、输入内容变化、反馈批提交、graph/eager 混用、换流准入、Host 拒绝及 prepare 失败场景继续回归。保留 #2249blocked_same / stream_busy:门闩阻塞实际 launch,不再要求 prepare 异步返回。

Test isolation and sensitivity

  • 每个场景独立进程,真实设备数值校验;输出 poison、非交换算术、执行计数和专属调度状态分别用于检测不同错误,不依赖超时或 sleep 推断成功。
  • KernelArgs 设备地址稳定、context committed memory 稳定及成功 close 后归零继续检查;资源增长场景仅在 prepare 后更新期望容量。
  • native enqueue 后复用 Host 参数描述,Device tensor、callable 和图可见资源保持有效至消费者结束;先销毁图,再关闭 context。
  • early-dispatch 命中证据仅在测试 orchestration 内读取现有协议,不增加生产热路径日志或新协议。
  • observer 的保证限于明确拦截的 API 和调用来源,不宣称覆盖 CANN 内部全部资源操作。

Validation

基线 25591599,A2/A3 真机、CANN 9.0.0、独占单卡、隔离 checkout/venv;复用已有依赖,未安装 Torch。

验证 结果
最小 cold capture smoke 1 passed,11.16 秒
最新基线完整 kernel-mode ST 34 passed,415.00 秒
本地/实测 ST 源码 SHA256 18 个源文件逐项一致
增量 pre-commit / diff 检查 通过
python -m pytest tests/st/a2a3/tensormap_and_ringbuffer/kernel_mode_capture \
  --platform a2a3 --runtime tensormap_and_ringbuffer \
  --device <allocated-device> -s -v --forked

遵循架构预检和独占设备工作流。以上结果不是 A5、HBG 或 vLLM/PyPTO 整网验收。

Known limitations

  • 总容量耗尽未验收。 当前 callable 数量上限为 8192,字节预算为 2 GiB。callable_growth 验证真实分配块增长及旧图保活,不冒充数量/字节上限拒绝和失败回滚测试,也不降低生产上限伪造边界。
  • 设备错误传播与失败恢复未验收。 独立真机诊断(不纳入本 PR 常规 ST)使用 config 返回 expected_arg_count=4,实际提交两个 tensor 加一个 scalar:AICPU 日志报告 invocation argument count does not match callablesimpler_aicpu_kernel_exec 返回 -1,但 caller 的 aclrtSynchronizeStreamWithTimeout 返回 0。在 25591599 重建后仍复现。该失败没有改为 pass/xfail,也没有据此声称同一 context 可安全恢复;本 PR 不修改错误传播生产协议。
  • 不覆盖任意 stride/offset、单图动态 shape、多卡、无序并发 context/replay、A5 或整网算子性能。重复执行验证功能复用,不是性能基准。

Cover distinct callable tables, fan-out/fan-in dependencies, ordinary
kernel composition, graph lifetime and geometry snapshot isolation.

Exercise single-invocation ring reuse, assert actual early-dispatch
completion, and preserve old graphs across callable cache growth.
Check synchronous prepare and prohibit direct launch-time resource
operations without changing the production runtime.

Validate all 34 scenes on A2/A3 hardware against feat 2559159.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: addffe44-c6f2-4a19-a54e-be7277970b24

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant