[RT][HIP] GPU executor core + first composed trunk forward verified on gfx1150

- rt::executor (feature `hip`): the bridge from the arena-validated plan to
  GPU compute. ExecOp { op, reads, writes, params } + OpParams (concrete
  shapes) + execute() dispatching the verified microkernels (embed, rms_norm,
  gemm_bf16, flash_gqa, moe_router, vec_add, cast). Lowering CompiledPlans+IR
  -> ExecOp lands with the packer; this core proves dispatch + composition.
- First COMPOSED GPU forward: embed gather -> rms_norm -> cast f32->bf16 ->
  gemm(unembed), verified end-to-end vs a CPU oracle (<1e-4). The composition
  test caught a real dtype-transition bug (f32 activation fed to a BF16 GEMM)
  — fixed by adding the cast kernel the reference also inserts before matmul.
- kernels/hip: k_cast_f32_bf16 (f32 activation -> BF16 truncate) + C ABI +
  wrapper. abi::vplan: CastF32Bf16 opcode (31 total).
- rt: optional hip dependency, feature-gated (default workspace stays
  host-independent).

Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; GPU parity 7/7 + composed trunk
forward 1/1 (--features hip). Principle recorded: parity-first baseline, then
our own measured improvements (Federico).
This commit is contained in:
adm committed 2026-12-01 13:57:07 +01:00
1 parent b99d3a7a6a
commit 87a66aee37
8 files changed
+196 -6

No files matched your search

+4 -1
View File
@@ -33,6 +33,7 @@ pub enum VplanOp {
RelPosBias,
MoeRouterTopk,
VecAdd,
CastF32Bf16,
VitFlashAttnWmma,
GpuPenaltiesTopk,
// Encoder lane (M1.5 embedder, docs/ARCHITECTURE.md §4)
@@ -81,6 +82,7 @@ impl VplanOp {
Self::RelPosBias => "relpos_bias",
Self::MoeRouterTopk => "moe_router_topk",
Self::VecAdd => "vec_add",
Self::CastF32Bf16 => "cast_f32_bf16",
Self::VitFlashAttnWmma => "vit_flash_attn_wmma",
Self::GpuPenaltiesTopk => "gpu_penalties_topk",
Self::LayerNorm => "layer_norm",
@@ -118,6 +120,7 @@ impl VplanOp {
"relpos_bias" => Self::RelPosBias,
"moe_router_topk" => Self::MoeRouterTopk,
"vec_add" => Self::VecAdd,
"cast_f32_bf16" => Self::CastF32Bf16,
"vit_flash_attn_wmma" => Self::VitFlashAttnWmma,
"gpu_penalties_topk" => Self::GpuPenaltiesTopk,
"layer_norm" => Self::LayerNorm,
@@ -152,7 +155,7 @@ mod tests {
VplanOp::GdnRecurrentStep, VplanOp::MoeRouteBucket, VplanOp::MoeW13Wmma,
VplanOp::MoeW2Wmma, VplanOp::MoeReduce, VplanOp::VitFlashAttnWmma,
VplanOp::AttnResMix, VplanOp::ShortConv4, VplanOp::LoopCtrl, VplanOp::L2Clip,
VplanOp::KvStore, VplanOp::RelPosBias, VplanOp::MoeRouterTopk, VplanOp::VecAdd,
VplanOp::KvStore, VplanOp::RelPosBias, VplanOp::MoeRouterTopk, VplanOp::VecAdd, VplanOp::CastF32Bf16,
VplanOp::GpuPenaltiesTopk, VplanOp::LayerNorm, VplanOp::FlashFullAttn,
VplanOp::GeluErf, VplanOp::PoolL2norm, VplanOp::LoopLayer, VplanOp::BranchB,
];