Archived
arch/common: calibrate in layer ranges (RADIANCE_CALIB_LAYERS)
Nemotron-3.5-Bolt's per-expert Hessians take 169 GiB at once. RADIANCE_CALIB_LAYERS names the layers a run taps, so several runs over disjoint ranges share one directory, and a layer's host sums are released once written.
This commit is contained in:
1 parent
c9c3a98894
commit
6f9c084ac6
2 files changed
+34
No files matched your search
@@ -17,6 +17,7 @@
|
|||||||
#include "rad_yarn.h"
|
#include "rad_yarn.h"
|
||||||
#include "rad_abi_layout.h"
|
#include "rad_abi_layout.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -123,6 +124,36 @@ inline const char* calib_dir() {
|
|||||||
return d && *d ? d : nullptr;
|
return d && *d ? d : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Whether layer `layer` taps (RADIANCE_CALIB_LAYERS: comma-separated layers and "lo-hi" ranges;
|
||||||
|
* unset, every layer). A model whose per-expert Hessians do not fit the host at once (Nemotron-3.5
|
||||||
|
* Bolt's are 169 GiB) calibrates in several runs over disjoint ranges; each run writes only its
|
||||||
|
* layers' files, so the runs share one directory. */
|
||||||
|
inline bool calib_layer_on(int layer) {
|
||||||
|
static const std::vector<std::pair<int, int>> ranges = [] {
|
||||||
|
std::vector<std::pair<int, int>> r;
|
||||||
|
const char* s = std::getenv("RADIANCE_CALIB_LAYERS");
|
||||||
|
while (s && *s) {
|
||||||
|
char* e = nullptr;
|
||||||
|
const long lo = std::strtol(s, &e, 10);
|
||||||
|
if (e == s) break;
|
||||||
|
long hi = lo;
|
||||||
|
if (*e == '-') {
|
||||||
|
const char* h = e + 1;
|
||||||
|
hi = std::strtol(h, &e, 10);
|
||||||
|
if (e == h) break;
|
||||||
|
}
|
||||||
|
r.emplace_back((int)lo, (int)hi);
|
||||||
|
s = *e == ',' ? e + 1 : e;
|
||||||
|
if (*s && *s != ',' && !std::isdigit((unsigned char)*s)) break;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}();
|
||||||
|
if (!std::getenv("RADIANCE_CALIB_LAYERS")) return true;
|
||||||
|
for (const auto& r : ranges)
|
||||||
|
if (layer >= r.first && layer <= r.second) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Token count at which the tap dumps and switches itself off (RADIANCE_CALIB_TOKENS, default
|
/* Token count at which the tap dumps and switches itself off (RADIANCE_CALIB_TOKENS, default
|
||||||
* 65536). Whether the tap runs at all is calib_dir()'s decision. */
|
* 65536). Whether the tap runs at all is calib_dir()'s decision. */
|
||||||
inline long long calib_target() {
|
inline long long calib_target() {
|
||||||
|
|||||||
@@ -1833,6 +1833,9 @@ inline void MoeFP8::pass(RadCtx* c_, int64_t T, int64_t r0, int64_t rows, bool o
|
|||||||
(!calib_dne_failed &&
|
(!calib_dne_failed &&
|
||||||
calib_dne.write(gram_dn_stem, c.expert_base, gram_domain,
|
calib_dne.write(gram_dn_stem, c.expert_base, gram_domain,
|
||||||
rad_rank(c_)));
|
rad_rank(c_)));
|
||||||
|
/* Written: the host sums are done with (a layer's can be gigabytes). */
|
||||||
|
calib_dne.acc = {};
|
||||||
|
calib_dne.rows = {};
|
||||||
calib_done = true;
|
calib_done = true;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
std::fprintf(stderr, "radiance: calibration wrote layer Hessians after %lld "
|
std::fprintf(stderr, "radiance: calibration wrote layer Hessians after %lld "
|
||||||
|
|||||||
Reference in new issue
Block a user