Archived
format: a span per stacked part, and a share that is zeros
Two additive builder exports, RAD_ABI_VERSION untouched. rad_weight_shard_span_parts: a row-sharded weight whose stacked parts are not the same width -- the delta net's [q|k|v|z], 2048, 2048, 6144, 6144 rows on Flash-Next -- cannot take rad_weight_shard_span's one [lo, hi), which is applied to every part and assumes them equal. This takes a span per part together with each part's whole extent in the container; share.cpp cuts every part by its own rows and refuses totals that do not sum to the entry. It is how a rank declares an UNEVEN share of the heads -- 6 of 16 K heads where three ranks take 6, 5 and 5 -- with nothing padded. rad_weight_shard_zero: this rank's share of a row- or column-sharded weight is zeros. weight_share returns the declaration's extents with no rectangles; the loader stages the weight with a worker that writes zeros (the route a checkpoint weight already takes from a container) and reads nothing. It is for a rank the geometry gives no real heads (next commit), which then declares the same program as its peers. share_test holds the per-part cut and the zero share.
This commit is contained in:
1 parent
1936bc881f
commit
82445ca71f
9 files changed
+241
-8
No files matched your search
+21
-6
@@ -1979,11 +1979,15 @@ static int fill_from_checkpoint(const CkptWeight& cw, const std::vector<PlaneSha
|
||||
std::string why;
|
||||
for (size_t k = 0; k < shares.size(); ++k) {
|
||||
const PlaneShare& sh = shares[k];
|
||||
uint8_t* at = in + offs[k];
|
||||
if (sh.zero) {
|
||||
std::memset(at, 0, (size_t)sh.dense_bytes());
|
||||
continue;
|
||||
}
|
||||
const RadEncPlane& p = cw.enc.plane[sel[k]];
|
||||
int64_t pr = 0, pc = 0;
|
||||
rad_enc_plane_dims(&p, cw.rows, cw.cols, &pr, &pc);
|
||||
const int64_t crb = rad_enc_row_bytes(p.dtype, pc);
|
||||
uint8_t* at = in + offs[k];
|
||||
for (const PlaneShare::Rect& q : sh.rects) {
|
||||
if (q.byte0 == 0 && q.bytes == sh.row_bytes) {
|
||||
const int64_t off = q.row0 * sh.row_bytes, n = q.rows * sh.row_bytes;
|
||||
@@ -2296,8 +2300,11 @@ int Engine::load_weights() {
|
||||
|
||||
/* FROM A CHECKPOINT, every weight is staged and its worker reads it: there is no
|
||||
* sweep to deliver it, and the stored form is whatever the pool makes of the share --
|
||||
* as it is, widened, or relaid. */
|
||||
if (!e) {
|
||||
* as it is, widened, or relaid. A ZERO SHARE (rad_weight_shard_zero) takes the same
|
||||
* route from a container: nothing in the file is its source, so no sweep run can
|
||||
* deliver it; its worker writes zeros and the pool stores them as it would any share. */
|
||||
const bool zero_share = sh[0].zero;
|
||||
if (!e || zero_share) {
|
||||
StagedWeight sw;
|
||||
sw.prog = &r->program;
|
||||
sw.wi = i;
|
||||
@@ -2322,9 +2329,17 @@ int Engine::load_weights() {
|
||||
std::vector<int> sel(w.sel, w.sel + w.n_sel);
|
||||
std::vector<int64_t> offs(sw.plane_off, sw.plane_off + w.n_sel);
|
||||
const std::string name = w.name;
|
||||
sw.fill = [cw, shares, sel, offs, name](uint8_t* in) -> int {
|
||||
return fill_from_checkpoint(*cw, shares, sel, offs, name, in);
|
||||
};
|
||||
if (zero_share) {
|
||||
const int64_t bytes = in_bytes;
|
||||
sw.fill = [bytes](uint8_t* in) -> int {
|
||||
std::memset(in, 0, (size_t)bytes);
|
||||
return RAD_OK;
|
||||
};
|
||||
} else {
|
||||
sw.fill = [cw, shares, sel, offs, name](uint8_t* in) -> int {
|
||||
return fill_from_checkpoint(*cw, shares, sel, offs, name, in);
|
||||
};
|
||||
}
|
||||
staged.push_back(std::move(sw));
|
||||
++n_loaded;
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user