[LD][HIP] Device-resident MoE path (opt-in VETTA_DEVICE_MOE): no host ids/output round-trip
moe_device runs the whole MoE on device: router ids/weights stay on device, the arena indirect GEMV selects experts on device, per-expert outputs accumulate in a device y_part via a STATIC y_offset=kk*hidden (added to both indirect kernels). No ids D2H, no per-expert output D2H/H2D => the MoE block is now graph-capturable. WeightCache gains a memoized expert_arena(ip,mat) accessor. Both SWA and full-attn MoE blocks dispatch to moe_device under VETTA_DEVICE_MOE=1; the default f32 host path is unchanged (parity baseline preserved). Parity: 16/16 greedy tokens IDENTICAL between VETTA_DEVICE_MOE=1 and the VETTA_F16_EXPERT=1 host path (same kernels/data). Arena indirect bit-exact vs direct on real weights (NVFP4 layer 0 + MXFP8 layer 20). Verified: ld GPU 19 + hip GPU 19 green, workspace CPU -D warnings green, 6 Lean proofs 0 sorryAx. Next: device-resident depth-block/bank machinery, then HIP graph capture of the decode step.
This commit is contained in:
1 parent
752edeaade
commit
0914fae8c8
4 files changed
+87
-34
No files matched your search
@@ -190,11 +190,11 @@ pub fn load_expert_arena(ar: &SafetensorsArchive, layer: usize, mat: &str) -> Re
|
||||
|
||||
/// Device-routed expert GEMV from an arena: expert id read from `ids[slot]` on
|
||||
/// device. Dispatches NVFP4 / MXFP8. Bit-identical math to expert_gemv_f16.
|
||||
pub fn expert_arena_gemv_f16(a: &ExpertArena, ids: &DeviceBuf, slot: i32, x: &DeviceBuf, y: &DeviceBuf) -> Result<(), String> {
|
||||
pub fn expert_arena_gemv_f16(a: &ExpertArena, ids: &DeviceBuf, slot: i32, x: &DeviceBuf, y: &DeviceBuf, y_offset: i64) -> Result<(), String> {
|
||||
if a.mxfp8 {
|
||||
vetta_infer_hip::mxfp8_gemv_f16_indirect(&a.packed, &a.scales, ids, slot, x, y, a.n, a.k, a.w_stride, a.sc_stride)
|
||||
vetta_infer_hip::mxfp8_gemv_f16_indirect(&a.packed, &a.scales, ids, slot, x, y, a.n, a.k, a.w_stride, a.sc_stride, y_offset)
|
||||
} else {
|
||||
vetta_infer_hip::nvfp4_gemv_f16_indirect(&a.packed, &a.scales, &a.outer, ids, slot, x, y, a.n, a.k, a.w_stride, a.sc_stride)
|
||||
vetta_infer_hip::nvfp4_gemv_f16_indirect(&a.packed, &a.scales, &a.outer, ids, slot, x, y, a.n, a.k, a.w_stride, a.sc_stride, y_offset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
let yi = DeviceBuf::alloc(n * 4).unwrap();
|
||||
let yd = DeviceBuf::alloc(n * 4).unwrap();
|
||||
for slot in 0..ids_vec.len() {
|
||||
expert_arena_gemv_f16(&arena, &dids, slot as i32, &dx16, &yi).unwrap();
|
||||
expert_arena_gemv_f16(&arena, &dids, slot as i32, &dx16, &yi, 0).unwrap();
|
||||
let em = load_expert_matrix(&ar, layer, ids_vec[slot] as usize, "w13").unwrap();
|
||||
expert_gemv_f16(&em, &dx16, &yd).unwrap();
|
||||
let mut gi = vec![0f32; n]; yi.d2h(&mut gi).unwrap();
|
||||
|
||||
Reference in new issue
Block a user