Archived
pipelined prefill past two ranks on request: RADIANCE_PREFILL_PIPELINE, narrow all-reduce at three and eight
- One switch for qwen35_fp8's and gemma3's pipelined prefill, RADIANCE_PREFILL_PIPELINE=auto|on|off (arch/common/rad_prefill_pipe.h), in place of RADIANCE_QWEN35_PIPE / RADIANCE_GEMMA3_PIPE. auto (or unset) pipelines at two ranks, where it is measured; on also at three, four and eight, with a declare note that it is not yet measured on such hardware; off never. Another value is noted and taken as auto. - libr4d: the narrow `overlap` all-reduce rows at three and eight ranks, as the four-rank ones are: the wide two-shot rows' entry points (exact at three and eight, ti8 at three) at tArTs4Lane's launch, so the collective beside the other piece's compute does not take the card (a wide one slows the GEMM beside it 1.45-2.1x and ate the whole gain at two). Bit-identical to the wide rows by construction; neither launch is tuned on three or eight cards, which this rig does not have. arch_test: at four and eight ranks a 2048-row step of one sequence is serial unless asked; asked, it runs in two pieces on every rank with every collective on the second lane at `overlap` 1 and the embedding's whole (failed before the change: the step stayed serial). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
28f1f2dd8c
commit
284feda3a6
5 files changed
+170
-19
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
// RADIANCE_PREFILL_PIPELINE: whether an architecture with a pipelined prefill (a prefill step of one
|
||||
// sequence in two pieces, the collectives between blocks on the second lane, beside the other piece's
|
||||
// compute) uses it.
|
||||
//
|
||||
// auto (or unset) at two ranks, where it was measured (Qwen3.8-27B 41k prefill -6.6 %,
|
||||
// TranslateGemma-27B 6k -12 %, bit for bit the serial step);
|
||||
// on also at three, four and eight ranks: libr4d has the narrow `overlap` all-reduce
|
||||
// there (the wide rows' entry points at a launch that leaves the CUs to compute),
|
||||
// but the step has not been measured on such hardware;
|
||||
// off never.
|
||||
//
|
||||
// Any other rank count has no narrow row, and a wide all-reduce beside the GEMMs ate the whole gain at
|
||||
// two (it slows the GEMM 1.45-2.1x), so those stay serial.
|
||||
#include <arch/rad_arch.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace rad::arch {
|
||||
|
||||
inline bool prefill_pipeline(RadBuilder* b, int world, const char* who) {
|
||||
const char* e = std::getenv("RADIANCE_PREFILL_PIPELINE");
|
||||
const bool on = e && !std::strcmp(e, "on"), off = e && !std::strcmp(e, "off");
|
||||
if (e && *e && !on && !off && std::strcmp(e, "auto") != 0)
|
||||
rad_note(b, "%s: RADIANCE_PREFILL_PIPELINE=%s is not auto, on or off; taken as auto", who, e);
|
||||
if (off || world < 2) return false;
|
||||
if (world == 2) return true;
|
||||
if (on && (world == 3 || world == 4 || world == 8)) {
|
||||
rad_note(b, "%s: the pipelined prefill at %d ranks (RADIANCE_PREFILL_PIPELINE=on) is not yet "
|
||||
"measured on hardware", who, world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace rad::arch
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <arch/rad_arch.h>
|
||||
#include <arch/rad_fp8.h>
|
||||
#include <arch/rad_block_dflash2.h>
|
||||
#include <arch/rad_prefill_pipe.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -1187,15 +1188,15 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_x}, {m.b_x});
|
||||
|
||||
/* The pipelined prefill (step_pipelined) at two ranks wherever a step can be wide enough, on an
|
||||
* MXFP4 trunk with fused junctions (decided below; RADIANCE_GEMMA3_PIPE=0 turns it off). Its
|
||||
/* The pipelined prefill (step_pipelined) wherever a step can be wide enough, on an MXFP4 trunk
|
||||
* with fused junctions (decided below), at the rank counts RADIANCE_PREFILL_PIPELINE allows
|
||||
* (rad_prefill_pipe.h: two by default). Its
|
||||
* second lane touches the stream, the branch output, the shared input pair, the taps and the
|
||||
* bounds, so those leave the sharing pool (Ctx::lane1_); the pair is one for every block so
|
||||
* that this costs one pair, not one a linear. */
|
||||
{
|
||||
const char* e = std::getenv("RADIANCE_GEMMA3_PIPE");
|
||||
m.pipe_on = g.world == 2 && g.max_tok >= kPipeMinRows && !calib_dir() &&
|
||||
!(e && std::strcmp(e, "0") == 0);
|
||||
m.pipe_on = g.max_tok >= kPipeMinRows && !calib_dir() &&
|
||||
rad::arch::prefill_pipeline(b, (int)g.world, "gemma3");
|
||||
}
|
||||
if (m.pipe_on) {
|
||||
m.pipe_in.mx = true;
|
||||
@@ -1489,8 +1490,8 @@ static const int32_t* pipe_ready(RadCtx* c, const RadBatch* batch, Model& m, boo
|
||||
rad_memcpy_async(d, m.pipe_tbl + 4 * T, 4 * (int64_t)sizeof(int32_t), rad_stream(c)) !=
|
||||
RAD_OK) {
|
||||
rad_step_fail(c, "gemma3: the pipelined prefill's piece bounds could not be put on the card "
|
||||
"(no pinned host memory, or the copy failed); RADIANCE_GEMMA3_PIPE=0 runs "
|
||||
"prefill serially");
|
||||
"(no pinned host memory, or the copy failed); RADIANCE_PREFILL_PIPELINE=off "
|
||||
"runs prefill serially");
|
||||
*failed = true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
#include <arch/rad_block_mtp_fp8.h>
|
||||
#include <arch/rad_block_dflash2.h>
|
||||
#include <arch/rad_block_vit.h>
|
||||
#include <arch/rad_prefill_pipe.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -883,14 +884,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_x}, {m.b_x});
|
||||
#if !QWEN35_MOE
|
||||
/* The pipelined prefill (step_pipelined), at two ranks wherever a step can be wide enough;
|
||||
* RADIANCE_QWEN35_PIPE=0 turns it off. Its second lane touches the residual stream, the normed
|
||||
/* The pipelined prefill (step_pipelined), wherever a step can be wide enough, at the rank
|
||||
* counts RADIANCE_PREFILL_PIPELINE allows (rad_prefill_pipe.h: two by default). Its second lane touches the residual stream, the normed
|
||||
* input in both forms, the taps and the bounds, so those leave the sharing pool
|
||||
* (Ctx::lane1_); the bounds also because no declared op reads them, which would leave a
|
||||
* transient dead before the kernels that take them raw. */
|
||||
{
|
||||
const char* e = std::getenv("RADIANCE_QWEN35_PIPE");
|
||||
m.pipe_on = g.world == 2 && g.max_tok >= kPipeMinRows && !(e && std::strcmp(e, "0") == 0);
|
||||
m.pipe_on = g.max_tok >= kPipeMinRows && rad::arch::prefill_pipeline(b, (int)g.world, "qwen35");
|
||||
}
|
||||
if (m.pipe_on) {
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.b_x));
|
||||
@@ -1329,8 +1329,8 @@ static const int32_t* pipe_ready(RadCtx* c, const RadBatch* batch, Model& m, boo
|
||||
rad_memcpy_async(d, m.pipe_tbl + 3 * T, 3 * (int64_t)sizeof(int32_t), rad_stream(c)) !=
|
||||
RAD_OK) {
|
||||
rad_step_fail(c, "qwen35: the pipelined prefill's piece bounds could not be put on the card "
|
||||
"(no pinned host memory, or the copy failed); RADIANCE_QWEN35_PIPE=0 runs "
|
||||
"prefill serially");
|
||||
"(no pinned host memory, or the copy failed); RADIANCE_PREFILL_PIPELINE=off "
|
||||
"runs prefill serially");
|
||||
*failed = true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user