[Core] VETTA_PROF: sync-isolated real MoE GPU time in moe_batched (profile aid)
Under VETTA_PROF, sync before/after moe_batched so EXPERT_NS measures real GPU MoE time, not async launch. Measured: MoE = 2727ms of 4176ms/chunk = 65% of batched prefill (the dominant hotspot; trunk GEMM + flash are minority). Production path (no VETTA_PROF) unchanged.
This commit is contained in:
1 parent
45d039dcb4
commit
0f0bb42949
1 file changed
+3
@@ -763,6 +763,8 @@ fn moe_batched(
|
||||
cache: &WeightCache, ip: usize, mlpin: &DeviceBuf, ids: &DeviceBuf, weights: &DeviceBuf, d: &Dims, h: usize, b: i32,
|
||||
) -> Result<DeviceBuf, String> {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user