diff --git a/crates/vetta-infer-ld/src/layer.rs b/crates/vetta-infer-ld/src/layer.rs index 1ee6056..baf0c05 100644 --- a/crates/vetta-infer-ld/src/layer.rs +++ b/crates/vetta-infer-ld/src/layer.rs @@ -763,6 +763,8 @@ fn moe_batched( cache: &WeightCache, ip: usize, mlpin: &DeviceBuf, ids: &DeviceBuf, weights: &DeviceBuf, d: &Dims, h: usize, b: i32, ) -> Result { let t0 = std::time::Instant::now(); + let prof = std::env::var("VETTA_PROF").is_ok(); + if prof { vetta_infer_hip::synchronize()?; } // isolate real MoE GPU time (drain prior work) let w13 = cache.expert_arena(ip, "w13")?; let w2 = cache.expert_arena(ip, "w2")?; let top_k = d.top_k; @@ -791,6 +793,7 @@ fn moe_batched( // Scatter-back + weighted reduce per token. let moeout = DeviceBuf::alloc((b as usize) * h * 4)?; vetta_infer_hip::moe_reduce_buckets_masked(&y_part, &ds2b, weights, &moeout, b, top_k as i32, h as i32)?; + if prof { vetta_infer_hip::synchronize()?; } EXPERT_NS.with(|c| c.set(c.get() + t0.elapsed().as_nanos())); Ok(moeout) }