Skip to content

Prefer E2B layouts for group broadcast loads - #1334

Draft
mouliangyu wants to merge 1 commit into
hw-native-sys:mainfrom
mouliangyu:codex/e2b-broadcast-layout
Draft

Prefer E2B layouts for group broadcast loads#1334
mouliangyu wants to merge 1 commit into
hw-native-sys:mainfrom
mouliangyu:codex/e2b-broadcast-layout

Conversation

@mouliangyu

@mouliangyu mouliangyu commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

背景

E2B-compatible 的 group_broadcast_load 之前仍可在 support table 中选择 contiguous layout。这样 assignment 无法表达 E2B producer 的真实物理 layout,也会让 contiguous 决策继续影响下游 cast 链;部分形态会回退到 vsldb + vselr,而 issue 原始整核则因此生成带 vor 合并的 FP8 carrier 路径。

Closes #1320

修改

  • 将 G=8、group block=1 的 E2B direct producer layout 从 contiguous 改为 deinterleaved-by-four。
  • group_broadcast_load 满足 E2B 条件时,从候选 layout 中移除 contiguous;只有无法使用 E2B 时才继续允许 contiguous fallback,并增加 b8 反向回归覆盖该条件。
  • 让 layout propagation 即使面对输入 IR 上已有的默认 layout,也通过 op support table 验证 producer 能力。
  • group_broadcast_load 保持为低优先级 preferred producer:consumer 可先选择 contiguous,producer 随后选择 d4,并由 assignment 显式插入 ensure_layout(d4 -> c)
  • 对直接进入 widening cast 的 E2B broadcast load 提前 producer seed,避免下游 lane-stride narrowing 把 f16 producer 锁成不可物化的 d2 -> ls2 冲突;普通 broadcast load 仍保持 consumer 优先。
  • 增加最小优化回归用例,并更新 E2B layout matrix,检查 E2B_B16/E2B_B32 且禁止 E2B case 回退到 vselr

性能

使用 issue 原始完整 vmi_kernel.input.pto,在同一个 origin/main@ca7ccb40 上分别构建 baseline 和本 PR,使用相同 VPTO flags 与 A5 CA model harness 测试:

  • baseline:block [15, 8238],kernel 区间 8223 cycles
  • 本 PR:block [17, 7876],kernel 区间 7859 cycles
  • 减少 364 cycles,约 4.43%

两边整核都没有 vselr,因此这里的收益不能归因于 vselr。完整 popped instruction 统计从 4107 条降到 4057 条;其中 RV_VOR 从 192 条降到 0。当前热点使用 E2B_B32 + 3 x vintlv 显式完成 d4 -> c,fp32 -> fp8 -> fp32 roundtrip 保持四条独立 P0 路径,不再通过 3 个 vor 合并共享 FP8 carrier。该整核使用 in-place scratch harness,模拟器执行通过,框架按既有设置跳过数值 compare。

验证

  • ninja -C .work/issue_1320/build-llvm19 pto-test-opt PTOAS_Python
  • 相关 E2B、non-E2B fallback、scalar BRC、group-store、ComputeY1 用例:8/8 passed
  • ninja -C .work/issue_1320/build-llvm19 check-pto:1830 passed,1 unsupported,0 failed
  • python3 .codex/skills/enforce-ptoas-code-compliance/scripts/check_changed_code.py --repo . --base origin/main:0 errors,0 warnings
  • 原始完整 kernel 在同基线 baseline/PR 上分别完整编译并运行 A5 CA model:8223 -> 7859 cycles

@mouliangyu
mouliangyu force-pushed the codex/e2b-broadcast-layout branch from d1a9f13 to 71bf21c Compare August 25, 2026 04:06
@mouliangyu mouliangyu changed the title Prefer E2B layout for group broadcast loads Prefer E2B layouts for group broadcast loads Aug 25, 2026
@mouliangyu
mouliangyu force-pushed the codex/e2b-broadcast-layout branch from 71bf21c to 00890b8 Compare August 25, 2026 04:45
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.

VMI FP32 d4 ↔ FP8 roundtrip:以 d4 lane-stride 路径替代 contiguous 打包

1 participant