diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 23eaf1dd..e0dda24b 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -1025,7 +1025,9 @@ bool Prefill::carve(size_t T, void* alloc) { m.xn16 = o.take(T * (D + (hc_pad() ? XN_PAD : 0)), ok); m.lo = o.take(T * LR, ok); m.lo16 = o.take(T * LR, ok); m.gated = o.take(T * D, ok); m.inj = o.take(T * HC, ok); m.mixed = o.take(T * N, ok); m.mixed_bf = o.take(T * N, ok); - m.mixed_h = o.take(T * N, ok); m.bo = o.take(T * N, ok); + m.mixed_h = o.take(T * N, ok); + // Embedding rows are dead after gr_broadcast on m.cs; subsequent half outputs use the same stream. + m.bo = m.emb; if (bf16x2_hc(m.f16_io)) { m.xn16_lo = o.take(T * D, ok); m.lo16_lo = o.take(T * LR, ok); } if (bf16x2(m.f16_io)) m.mixed_bf_lo = o.take(T * N, ok); m.steps_dev = o.take(T * strata::kernels::kStepCount, ok); @@ -1571,7 +1573,7 @@ uint64_t Prefill::bytes_needed_impl(const core::ModelGeometry& g, const core::Se o.take(GEMM_WS, ok); auto f = [&](size_t n) { o.take(n, ok); }; // `carve`'s order, buffer for buffer: emb, R, xn, grs, xn16, lo, lo16, gated, inj, mixed, mixed_bf, mixed_h, - // bo. This counted `xn` unconditionally (carve takes it only under STRATA_GR_UNFUSED) and never counted + // bo aliases emb. This counted `xn` unconditionally (carve takes it only under STRATA_GR_UNFUSED) and never counted // `grs`. Net over-count T*(D-HC)*4 bytes: 42 MB at a 1024-token chunk, 252 MB (48 Q8_0 slots) at 6144 - the // prompt path was told it had less room than it did. Safe - the direction is over-estimating, and `take` // still bounds-checks - but it under-sizes every loan, so every chunk the scan picks is one step smaller. @@ -1583,7 +1585,7 @@ uint64_t Prefill::bytes_needed_impl(const core::ModelGeometry& g, const core::Se f(T * N); f(T * D); f(T * D); } o.take(T * (D + (hc_pad() ? XN_PAD : 0)), ok); f(T * LR); o.take(T * LR, ok); - f(T * D); f(T * HC); f(T * N); o.take(T * N, ok); o.take(T * N, ok); f(T * N); + f(T * D); f(T * HC); f(T * N); o.take(T * N, ok); o.take(T * N, ok); const bool f16_io = prompt_f16(); // the current device's mode (the stage's), as Prefill::init will decide it if (bf16x2_hc(f16_io)) { o.take(T * D, ok); o.take(T * LR, ok); } if (bf16x2(f16_io)) o.take(T * N, ok);