Merge claude/slots-footprint2: free 1,084 MiB VRAM (unused MTP pack bank, lazy legacy QSA key mirrors); 11,568 -> 12,144 expert slots, +1.75% paired tok/s (n=3), bit-identical at equal slots; LELEKA_FOOTPRINT_LEGACY=1 restores. Placement-class gate on the larger cache still to run
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,8 +61,10 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
/// Explicit selected factory: real arena-backed MMQ, with no second
|
||||
/// X/weight/GU/H/Q8/Down payload bank or old host-window prefill owner.
|
||||
/// The caller loads/adopts the authentic model bank before this boundary.
|
||||
/// `mtp_pack_experts`: also upload the pinned MTP pack's expert bank (675 MiB). Only the pack-driven draft (no RT directory) reads it;
|
||||
/// see `new_with_mtp_experts`.
|
||||
pub(crate) fn new_original_prompt_arena(
|
||||
binding: &ModelBinding, context: &'ctx Context<'ctx>, options: leleka_cuda_driver::PrefillLayoutOptions,
|
||||
binding: &ModelBinding, context: &'ctx Context<'ctx>, options: leleka_cuda_driver::PrefillLayoutOptions, mtp_pack_experts: bool,
|
||||
) -> Result<Self> {
|
||||
let capacity = u32::try_from(options.capacity).map_err(|_|Error::InvalidDimension)?;
|
||||
if !(1..=8192).contains(&capacity) || binding.layer_count() != 48 {
|
||||
@@ -78,7 +80,7 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
return Err(driver_error(primary));
|
||||
}
|
||||
crate::bringup_trace!("DBG arena: workspace+group arena ok");
|
||||
let mut cache = match Self::assemble_mmq(binding, context, workspace) { Ok(c)=>c, Err(e)=>{crate::bringup_trace!("DBG arena assemble_mmq err: {e:?}");return Err(e)} };
|
||||
let mut cache = match Self::assemble_mmq_with_mtp_experts(binding, context, workspace, mtp_pack_experts) { Ok(c)=>c, Err(e)=>{crate::bringup_trace!("DBG arena assemble_mmq err: {e:?}");return Err(e)} };
|
||||
crate::bringup_trace!("DBG arena: assemble_mmq ok");
|
||||
cache.original_prompt_mmq = true;
|
||||
cache.mmq_policy = MmqRoutingPolicy::NativeIntegerIq3;
|
||||
|
||||
@@ -55,6 +55,8 @@ pub(crate) fn validate_ranked_profile(bytes: &[u8]) -> Result<()> {
|
||||
pub(crate) const WORKING_RESERVE: usize = 128 * 1024 * 1024;
|
||||
const MAIN_LIMIT: usize = 24 * 1024 * 1024 * 1024;
|
||||
const MTP_DENSE_LIMIT: usize = 116_099_072;
|
||||
/// The pinned MTP pack's expert bank (`pack.expert_bank`): the draft layer's 256 routed experts, uploaded once at construction.
|
||||
const MTP_PACK_EXPERT_BANK_BYTES: usize = 707_788_800;
|
||||
|
||||
/// Exact production admission predicate; overflow always refuses.
|
||||
pub(super) fn room_fits(allocated: usize, budget: usize, main_bytes: usize, extra: usize) -> bool {
|
||||
@@ -622,6 +624,17 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
self.failed.set(true);
|
||||
}
|
||||
pub(crate) fn new(binding: &ModelBinding, context: &'ctx Context<'ctx>) -> Result<Self> {
|
||||
Self::new_with_mtp_experts(binding, context, true)
|
||||
}
|
||||
/// Bytes `new` charges against the budget for the pinned MTP pack: the dense roles always, the 675 MiB expert bank only when it is uploaded.
|
||||
pub(in crate::qwen_forward) const fn mtp_pack_charge(mtp_experts: bool) -> usize {
|
||||
(if mtp_experts { MTP_PACK_EXPERT_BANK_BYTES } else { 0 }) + MTP_DENSE_LIMIT
|
||||
}
|
||||
/// `mtp_experts == false` leaves the pinned pack's EXPERT BANK (707,788,800 bytes, the draft layer's routed experts) out of VRAM. The serve stack
|
||||
/// passes false when it loads the draft layer from an RT directory (`--mtp-rt-dir`, the product path): that path streams its own copy of the
|
||||
/// experts (`original_mtp_rt_bank`) and never reads this one, so keeping both held 675 MiB of VRAM (and the host copy during the upload) for nothing.
|
||||
/// The pack's dense roles are still uploaded: the draft-KV recording of the prompt path reads them through `mtp_matrix`.
|
||||
pub(crate) fn new_with_mtp_experts(binding: &ModelBinding, context: &'ctx Context<'ctx>, mtp_experts: bool) -> Result<Self> {
|
||||
let mut cache = Self {
|
||||
context,
|
||||
binding: binding.identity(),
|
||||
@@ -691,12 +704,14 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
cache.room(0)?;
|
||||
if binding.has_mtp() {
|
||||
let pack = binding.mtp_weights().map_err(binding_error)?;
|
||||
cache.room(707_788_800 + MTP_DENSE_LIMIT)?;
|
||||
let data = pack.expert_bank(binding).map_err(binding_error)?;
|
||||
let bank = cache.upload(&data)?;
|
||||
cache.bank = Some(Rc::new(bank));
|
||||
drop(data);
|
||||
cache.counters.misses = cache.counters.misses.saturating_add(1);
|
||||
cache.room(Self::mtp_pack_charge(mtp_experts))?;
|
||||
if mtp_experts {
|
||||
let data = pack.expert_bank(binding).map_err(binding_error)?;
|
||||
let bank = cache.upload(&data)?;
|
||||
cache.bank = Some(Rc::new(bank));
|
||||
drop(data);
|
||||
cache.counters.misses = cache.counters.misses.saturating_add(1);
|
||||
}
|
||||
let mut total = 0usize;
|
||||
for role in pack.dense_roles(binding).map_err(binding_error)? {
|
||||
let rows = pack.dense_complete(binding, role).map_err(binding_error)?;
|
||||
@@ -1512,12 +1527,20 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
binding: &ModelBinding,
|
||||
context: &'ctx Context<'ctx>,
|
||||
workspace: MmqWorkspace<'ctx>,
|
||||
) -> Result<Self> {
|
||||
Self::assemble_mmq_with_mtp_experts(binding, context, workspace, true)
|
||||
}
|
||||
fn assemble_mmq_with_mtp_experts(
|
||||
binding: &ModelBinding,
|
||||
context: &'ctx Context<'ctx>,
|
||||
workspace: MmqWorkspace<'ctx>,
|
||||
mtp_experts: bool,
|
||||
) -> Result<Self> {
|
||||
if !room_fits(context.allocated_bytes(), context.budget_bytes(), 0, 0) {
|
||||
let _ = workspace.close();
|
||||
return Err(Error::InputAllocation);
|
||||
}
|
||||
match Self::new(binding, context) {
|
||||
match Self::new_with_mtp_experts(binding, context, mtp_experts) {
|
||||
Ok(mut cache) => {
|
||||
cache.mmq_workspace = Some(workspace);
|
||||
Ok(cache)
|
||||
@@ -2631,9 +2654,17 @@ impl<'ctx> MoeWeightCache<'ctx> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod cache_policy_sdet {
|
||||
use super::{MoeWeightDescriptor, oldest_weight, room_fits};
|
||||
use super::{MoeWeightCache, MoeWeightDescriptor, oldest_weight, room_fits};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
fn leaving_the_pinned_mtp_expert_bank_out_saves_exactly_the_bank() {
|
||||
// the RT-directory serve path never reads the pack's expert bank: its 675 MiB are not charged, the dense roles still are
|
||||
assert_eq!(MoeWeightCache::mtp_pack_charge(true) - MoeWeightCache::mtp_pack_charge(false), 707_788_800);
|
||||
assert_eq!(MoeWeightCache::mtp_pack_charge(false), 116_099_072);
|
||||
assert_eq!(707_788_800 % (1 << 20), 0, "675 MiB");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warmed_slotpack_peak_cannot_spend_independent_working_reserve() {
|
||||
// Actual64-row ten-slot packets + shared activations + scalar2MiB peak.
|
||||
|
||||
@@ -12,6 +12,22 @@ use leleka_cuda_driver::{
|
||||
const N_ROT: f32 = 64.0;
|
||||
/// `kVerifyMaxT`.
|
||||
pub(in crate::qwen_forward) const VERIFY_MAX_T: usize = 8;
|
||||
|
||||
/// `LELEKA_FOOTPRINT_LEGACY=1` restores the two device allocations the serve path holds without ever reading them (claude/slots-footprint2):
|
||||
/// the pinned MTP pack's expert bank next to the RT-directory copy (675 MiB, `MoeWeightCache::new_with_mtp_experts`) and the legacy host-canonical
|
||||
/// QSA index-key mirror (12 x 32 MiB, `QsaIndexKeyCache`). The switch exists as the A/B baseline and as a rollback; the default is OFF (not held).
|
||||
pub(in crate::qwen_forward) fn legacy_footprint() -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ON.get_or_init(|| legacy_footprint_from(std::env::var("LELEKA_FOOTPRINT_LEGACY").ok().as_deref()))
|
||||
}
|
||||
fn legacy_footprint_from(value: Option<&str>) -> bool {
|
||||
matches!(value.map(str::trim), Some("1" | "on" | "yes" | "true"))
|
||||
}
|
||||
/// Whether the MoE cache uploads the pinned MTP pack's expert bank: only when the draft layer is NOT loaded from an RT directory (the pack-driven draft
|
||||
/// reads it) or the legacy footprint is asked for.
|
||||
pub(in crate::qwen_forward) fn mtp_pack_experts_needed(rt_directory_set: bool) -> bool {
|
||||
!rt_directory_set || legacy_footprint()
|
||||
}
|
||||
const VOCABULARY: usize = 248_320;
|
||||
|
||||
/// Per-layer routed-expert byte sizes (one expert's gate, up and down matrices), the quantities the
|
||||
@@ -308,6 +324,25 @@ pub(in crate::qwen_forward) fn prefill_layout_options(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn the_pack_expert_bank_is_needed_only_without_an_rt_directory() {
|
||||
// pack-driven draft (no RT directory): the pack's experts are the draft layer's experts
|
||||
assert!(mtp_pack_experts_needed(false));
|
||||
// RT-directory draft (the product): it streams its own experts; the default environment holds no second copy
|
||||
if !legacy_footprint() {
|
||||
assert!(!mtp_pack_experts_needed(true));
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn the_legacy_footprint_switch_is_off_unless_asked_for() {
|
||||
assert!(!legacy_footprint_from(None));
|
||||
assert!(!legacy_footprint_from(Some("")));
|
||||
assert!(!legacy_footprint_from(Some("0")));
|
||||
assert!(!legacy_footprint_from(Some("off")));
|
||||
assert!(legacy_footprint_from(Some("1")));
|
||||
assert!(legacy_footprint_from(Some(" on ")));
|
||||
}
|
||||
|
||||
use leleka_context::rope_scaling::RopeKernelArgs;
|
||||
|
||||
fn blobs() -> ExpertBlobSizes {
|
||||
|
||||
@@ -420,7 +420,10 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
None => None,
|
||||
});
|
||||
let dense = staged!("dense weights", context, DenseWeightCache::new_original_prompt_capacity(binding, context, config.capacity).map_err(at("DenseWeightCache::new_original_prompt_capacity"))?);
|
||||
let moe = staged!("MoE arena cache", context, MoeWeightCache::new_original_prompt_arena(binding, context, layout).map_err(at("MoeWeightCache::new_original_prompt_arena"))?);
|
||||
let moe = staged!("MoE arena cache", context, MoeWeightCache::new_original_prompt_arena(binding, context, layout, super::original_serve_config::mtp_pack_experts_needed(config.rt_directory.is_some())).map_err(at("MoeWeightCache::new_original_prompt_arena"))?);
|
||||
if !super::original_serve_config::mtp_pack_experts_needed(config.rt_directory.is_some()) {
|
||||
operator_note("footprint: the pinned MTP pack's expert bank (675 MiB) is not uploaded: the draft layer is loaded from the RT directory and never reads it (LELEKA_FOOTPRINT_LEGACY=1 keeps it)");
|
||||
}
|
||||
vram_note(context, "after embedding, output, kar, dense, moe arena");
|
||||
let mut session = QwenSession::for_binding_on_shared_device(binding, shared);
|
||||
let request = OriginalMtpRequest::ring_int8(verifier_max_t, config.capacity, settings.coupled, MTP_RESIDENT_CELLS);
|
||||
|
||||
@@ -93,19 +93,36 @@ pub(in crate::qwen_forward) struct QsaIndexKeyCache<'ctx> {
|
||||
uploads: usize,
|
||||
}
|
||||
impl<'ctx> QsaIndexKeyCache<'ctx> {
|
||||
/// Bytes of one layer's mirror (`max_rows` pooled key rows).
|
||||
fn layer_bytes() -> Result<usize> {
|
||||
max_rows().checked_mul(ROW_BYTES).ok_or(Error::Overflow)
|
||||
}
|
||||
/// The mirror serves the legacy host-canonical QSA path (`qsa_index.rs`, `QsaPrior`); the serve path keeps its keys in the resident index
|
||||
/// (`OriginalQsaResidentIndex`) and never calls `select`, so the twelve 32 MiB buffers (384 MiB, 408 MiB for the driver) are allocated
|
||||
/// by the first `select` of a layer instead of at construction. `LELEKA_FOOTPRINT_LEGACY=1` allocates all twelve here, as before.
|
||||
pub(in crate::qwen_forward) fn new(
|
||||
binding: BindingIdentity,
|
||||
context: &'ctx Context<'ctx>,
|
||||
failed: Rc<Cell<bool>>,
|
||||
) -> Result<Self> {
|
||||
Self::with_eager(binding, context, failed, crate::qwen_forward::original_serve_config::legacy_footprint())
|
||||
}
|
||||
fn with_eager(
|
||||
binding: BindingIdentity,
|
||||
context: &'ctx Context<'ctx>,
|
||||
failed: Rc<Cell<bool>>,
|
||||
eager: bool,
|
||||
) -> Result<Self> {
|
||||
if failed.get() {
|
||||
return Err(Error::CudaExecution);
|
||||
}
|
||||
let bytes = max_rows().checked_mul(ROW_BYTES).ok_or(Error::Overflow)?;
|
||||
let bytes = Self::layer_bytes()?;
|
||||
let total = bytes.checked_mul(12).ok_or(Error::Overflow)?;
|
||||
// lazy: only the transient peak of one selection must fit; eager: the whole mirror too
|
||||
let charge = if eager { total } else { 0 };
|
||||
if context
|
||||
.allocated_bytes()
|
||||
.checked_add(total)
|
||||
.checked_add(charge)
|
||||
.and_then(|n| n.checked_add(device_peak()))
|
||||
.is_none_or(|n| n > context.budget_bytes())
|
||||
{
|
||||
@@ -119,15 +136,9 @@ impl<'ctx> QsaIndexKeyCache<'ctx> {
|
||||
#[cfg(test)]
|
||||
uploads: 0,
|
||||
};
|
||||
for slot in 0..12 {
|
||||
match context.allocate(bytes).map_err(driver_error) {
|
||||
Ok(buffer) => {
|
||||
cache.entries[slot] = Some(Entry {
|
||||
prior: None,
|
||||
buffer,
|
||||
})
|
||||
}
|
||||
Err(primary) => {
|
||||
if eager {
|
||||
for slot in 0..12 {
|
||||
if let Err(primary) = cache.ensure(slot) {
|
||||
let _ = cache.close();
|
||||
return Err(primary);
|
||||
}
|
||||
@@ -135,6 +146,19 @@ impl<'ctx> QsaIndexKeyCache<'ctx> {
|
||||
}
|
||||
Ok(cache)
|
||||
}
|
||||
/// The layer's mirror, allocated when it is first needed.
|
||||
fn ensure(&mut self, slot: usize) -> Result<&mut Entry<'ctx>> {
|
||||
if self.entries[slot].is_none() {
|
||||
let buffer = self.context.allocate(Self::layer_bytes()?).map_err(driver_error)?;
|
||||
self.entries[slot] = Some(Entry { prior: None, buffer });
|
||||
}
|
||||
self.entries[slot].as_mut().ok_or(Error::IdentityMismatch)
|
||||
}
|
||||
/// Layers whose mirror exists (0 on the serve path).
|
||||
#[cfg(test)]
|
||||
fn allocated_layers(&self) -> usize {
|
||||
self.entries.iter().flatten().count()
|
||||
}
|
||||
pub(in crate::qwen_forward) fn select(
|
||||
&mut self,
|
||||
binding: &BindingIdentity,
|
||||
@@ -165,7 +189,7 @@ impl<'ctx> QsaIndexKeyCache<'ctx> {
|
||||
let rows = next.0.pooled.len().checked_add(1).ok_or(Error::Overflow)?;
|
||||
#[cfg(test)]
|
||||
let needed = rows.checked_mul(ROW_BYTES).ok_or(Error::Overflow)?;
|
||||
let entry = self.entries[slot].as_ref().ok_or(Error::IdentityMismatch)?;
|
||||
let entry = self.ensure(slot)?;
|
||||
if entry.buffer.len()
|
||||
!= capacity(rows)?
|
||||
.checked_mul(ROW_BYTES)
|
||||
@@ -408,8 +432,16 @@ mod gpu {
|
||||
.unwrap();
|
||||
let binding = BindingIdentity::test_identity();
|
||||
let failed = Rc::new(Cell::new(false));
|
||||
let mut cache = QsaIndexKeyCache::new(binding.clone(), &context, failed.clone()).unwrap();
|
||||
// the legacy footprint (LELEKA_FOOTPRINT_LEGACY=1) allocates all twelve mirrors at construction
|
||||
let eager = QsaIndexKeyCache::with_eager(binding.clone(), &context, failed.clone(), true).unwrap();
|
||||
assert_eq!(context.allocated_bytes(), 402659328);
|
||||
assert_eq!(eager.allocated_layers(), 12);
|
||||
eager.close().unwrap();
|
||||
assert_eq!(context.allocated_bytes(), 0);
|
||||
// the default holds nothing until a layer is selected
|
||||
let mut cache = QsaIndexKeyCache::with_eager(binding.clone(), &context, failed.clone(), false).unwrap();
|
||||
assert_eq!(context.allocated_bytes(), 0);
|
||||
assert_eq!(cache.allocated_layers(), 0);
|
||||
let iq = [0.1; 512];
|
||||
let mut prior = synthetic_late_prior_for(binding.clone(), 190000);
|
||||
let mut total = 0;
|
||||
@@ -441,6 +473,9 @@ mod gpu {
|
||||
prior = next;
|
||||
}
|
||||
assert_eq!(cache.uploads, (47500 + 1) * ROW_BYTES + 1024);
|
||||
// layer 3 is mirror slot 0: only that one exists
|
||||
assert_eq!(cache.allocated_layers(), 1);
|
||||
assert_eq!(context.allocated_bytes(), 402659328 / 12);
|
||||
let replacement = synthetic_late_prior_for(binding.clone(), 190004);
|
||||
let expected = select(
|
||||
&context,
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# 5090 fixed VRAM footprint, second pass: two buffers the serve path holds and never reads (claude/slots-footprint2)
|
||||
|
||||
Date 2026-10-30. RTX 5090 (32,110 MiB seen by CUDA), frozen corpus, upstream ranked profile, product budget 31,299 MiB. Base = `main` 221801b3.
|
||||
Labels: M measured in the run named, E estimate, U unverified. Companion of [vram-footprint-5090](vram-footprint-5090.md) (first pass: dense slabs, planner against the Context budget, opt-in alias and reserve).
|
||||
|
||||
## 1. Result (M: ledger runs, not a speed result)
|
||||
|
||||
| item | where | VRAM freed | expert slots | kind |
|
||||
| --- | --- | ---: | ---: | --- |
|
||||
| the digest-pinned MTP pack's expert bank (707,788,800 B) uploaded by `MoeWeightCache::new`, while the product (`--mtp-rt-dir`) loads the draft layer from the RT directory and streams its own copy (`original_mtp_rt_bank`, 675 MiB) | MoE arena stage | 676 MiB driver (also 403 MiB less host `avail` at that stage) | | not held when `rt_directory` is set |
|
||||
| the 12 `QsaIndexKeyCache` mirrors (32 MiB each) of the legacy host-canonical QSA path (`qsa_index.rs`, `QsaPrior`), allocated at construction | dense stage | 408 MiB driver | | allocated by the first `select` of a layer; the serve path never calls it |
|
||||
| total | | **1,084 MiB** (free before the cache 23,633 -> 24,717 MiB) | **11,568 -> 12,144 (+576, 12 quota steps of 48)** | |
|
||||
|
||||
`LELEKA_FOOTPRINT_LEGACY=1` restores both allocations (main's behaviour): it is the A/B baseline and the rollback. Default OFF (not held).
|
||||
Vanilla Strata 0.2.6 keeps 12,575 slots: the remaining slot gap is 431 (it was 1,007).
|
||||
|
||||
Sources: ledger run of main's engine code `runs/slots2/ledger-bin-speedtrain3` (job `slots2-ledger`) and of this branch `runs/slots2/ledger-footprint2` (job `slots2-ledger-fp2`), both `LELEKA_VRAM_LEDGER=1`, one 2-turn session.
|
||||
|
||||
| line of the log | main code | this branch |
|
||||
| --- | ---: | ---: |
|
||||
| `DBG vram after embedding, output, kar, dense, moe arena` free MiB | 25,727 | 26,811 |
|
||||
| `DBG vram after prompt executor and draft` / `before cache` free MiB | 23,633 | 24,717 |
|
||||
| `expert cache N slots` | 11,568 | 12,144 |
|
||||
| `DBG vram after expert tier` free MiB (reserve 700 + 300, plus the quota remainder) | 1,055 | 1,015 |
|
||||
| `DBG vram decode after assemble` free MiB (the lowest the card had) | 547 / 543 | 507 / 503 |
|
||||
| prompt path borrows | its last 2,236 slots | its last 2,227 slots |
|
||||
|
||||
The decode-time free VRAM stays above vanilla's 315 MiB; the reserve policy is unchanged.
|
||||
|
||||
## 2. How they were found (M)
|
||||
|
||||
The first pass could only say that "prompt executor + MTP drafter" held 2,094 MiB against vanilla's 835 MiB for the MTP layer. The per-call-site ledger (`LELEKA_VRAM_LEDGER=1`, bea07c3d) run on the server splits it:
|
||||
|
||||
| stage (main) | MiB | site |
|
||||
| --- | ---: | --- |
|
||||
| prompt executor + MTP: MTP RT bank experts | 675.0 | `original_mtp_rt_bank` / `stream_experts` (needed: the drafter) |
|
||||
| | 399.0 | 12 QSA resident K/V pools, `QsaPromptKv::new` (needed: decode reads the resident window) |
|
||||
| | 384.0 (408 driver) | 12 `OriginalQsaResidentIndex` (the serve path's index keys; needed) |
|
||||
| | 214.2 | `original_mtp_draft_head` (draft vocabulary rows; needed) |
|
||||
| | 128.1 | `OriginalQsaPromptDevice` scratch (prompt-only; not moved) |
|
||||
| | 110.7 | MTP RT bank dense roles |
|
||||
| | 50.2 | `OriginalGdnPromptDevice` (prompt-only; not moved) |
|
||||
| | 34 + 23 + 11 + ... | MTP ring state, full forward, prefill |
|
||||
| MoE arena cache (944 driver) | **784.1 (802 driver)** | `MoeWeightCache::upload` from `new` -> `assemble_mmq`: pack expert bank 675 + pack dense roles 109 |
|
||||
| dense weights (4,038 driver) | **384.0 (408 driver)** | `QsaIndexKeyCache::new` |
|
||||
|
||||
Reading the code: `OriginalServeStack::open` builds the MoE cache first (its `new` uploads the pinned pack when the binding has an MTP layer), then, when `config.rt_directory` is set, `select_rt_mtp`
|
||||
builds the executor and the draft layer from the RT directory without touching `moe` (`retain_original_mtp_weights` is the only reader of the pack's expert bank and is called only on the pack-driven branch).
|
||||
The pack's DENSE roles are still read in the rt mode: `record_original_draft_kv` takes the ten prefill matrices from `moe.mtp_matrix`, so they stay (109 MiB). The key mirror's only callers are `qsa_index.rs` `qsa_select` (the host
|
||||
canonical `QsaPrior` scalar path); the serve QSA layers go through `ResidentQsaLayer`.
|
||||
|
||||
## 3. Kind of change, gates
|
||||
|
||||
* Both removals change no value any kernel reads. At an EQUAL slot count the engine is bit-identical with and without them: job `footprint2-id.sh` (static tier, `EXPERT_SLOTS=8000`, RT directory set in every process, replay of the 256k capture, top-16
|
||||
logprobs per row) must report 0 flips and max |dlogprob| 0. It did (section 5.2).
|
||||
* With `EXPERT_SLOTS=auto` the freed VRAM becomes 576 more resident experts, which moves expert placement: GPU-resident experts round differently from the CPU's (`bench/results/2026-09-27-cache-parity`). That is the PLACEMENT class, gated by the relative
|
||||
criterion of `/data/leleka-e2e/decode/notes.md` (<= 1.5x the control deviation, flips <= 2.8 %, >= 1000 rows), not by bit-identity. That gate has NOT been run for the larger cache (U).
|
||||
* The pack-driven draft (no RT directory: laptop profile, replay without `LELEKA_ORIGINAL_SERVE_RT_DIR`) is unchanged: the bank is still uploaded there.
|
||||
|
||||
## 4. Paired A/B
|
||||
|
||||
Job `footprint2-ab.sh`: one binary (`dt/bin-footprint2`, code 1a993970), arms `fp2-base-noseed` (`LELEKA_FOOTPRINT_LEGACY=1`) and `fp2-new-noseed`, 3 pairs interleaved with the order alternated, seed OFF, upstream profile, 5 turns to ~245k, guards: final turn
|
||||
>= 200k input tokens, turn-5 `window.ple` < 5 ms. Results: section 5.1.
|
||||
|
||||
## 5. Measurements
|
||||
|
||||
### 5.1 Paired A/B, `runs/footprint2-ab` (job `footprint2-ab`, 2026-10-30 22:09-22:27Z, server uptime ~11 h, same boot for all six runs)
|
||||
|
||||
Six VALID runs (final-turn input 246,885 / 247,062 tokens, turn-5 `window.ple` 0.16-0.19 ms), order base new new base base new, pair k = runs 2k-1 and 2k. Same binary; only `LELEKA_FOOTPRINT_LEGACY=1` differs. Seed OFF, auto slots.
|
||||
|
||||
| arm (3 runs each) | slots | tok/s T1..T5 (mean of 3) | all-turn | tokens/round T1..T5 | ms/round T1..T5 (decode wall / rounds) |
|
||||
| --- | ---: | --- | ---: | --- | --- |
|
||||
| fp2-base (legacy footprint = main) | 11,568 | 136.1 140.3 148.5 137.4 141.8 | 140.8 | 2.08 2.04 2.22 1.91 2.04 | 15.24 14.56 14.91 13.88 14.36 |
|
||||
| fp2-new (this branch) | 12,144 | 131.9 137.9 156.0 143.9 146.8 | 143.3 | 2.04 1.98 2.17 1.88 2.03 | 15.47 14.38 13.94 13.04 13.84 |
|
||||
|
||||
Pairs (all-turn tok/s, new against base): -0.35 %, +2.75 %, +2.86 %; mean **+1.75 %** (min -0.35, max +2.86); per-turn mean difference -3.1, -1.7, +5.1, +4.7, +3.6 %.
|
||||
Lowest free VRAM of a run: 539-541 MiB (base), 499 MiB (new).
|
||||
|
||||
Reading it (M for the numbers, E for the reading):
|
||||
|
||||
* ms/round, the quantity the change acts on, falls in turns 3-5 by 1.0, 0.8 and 0.5 ms (-6.5, -6.1, -3.6 %) and is within +-0.25 ms in turns 1-2; the all-turn mean is 14.59 -> 14.13 ms (-3.2 %).
|
||||
* tokens/round differs by 1-3 % between the arms in every turn (2.04 against 2.08 in turn 1, in all three new runs 2.04): the cache holds more experts, GPU- and CPU-computed experts round differently, so the greedy text and the draft acceptance differ. That is the placement class
|
||||
and it moves tok/s independently of the round time; it is why turns 1-2 read lower in tok/s although their ms/round does not rise. The three runs of an arm do not give a confidence interval; the spread of tok/s inside an arm is 1-8 % in turns 3-5.
|
||||
* The mechanism is visible in the per-window lines (`DBG window`, windows 20+ of each request, 3 runs per arm; `entries` and `experts` are what the CPU pool computed in a window, `pcie_experts` what was copied over PCIe, `pool` the wait for the pool; base -> new):
|
||||
|
||||
| turn | CPU-pool entries | CPU-pool experts | PCIe experts | pool wait ms | window total ms |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1 | 42.0 -> 37.7 | 37.9 -> 34.1 | 19.9 -> 17.6 | 4.93 -> 4.51 | 12.96 -> 12.61 |
|
||||
| 2 | 37.1 -> 32.4 | 34.3 -> 30.1 | 17.5 -> 14.2 | 4.35 -> 3.92 | 12.61 -> 12.26 |
|
||||
| 3 | 42.8 -> 33.5 | 37.1 -> 29.9 | 21.0 -> 15.7 | 4.55 -> 3.82 | 13.09 -> 12.44 |
|
||||
| 4 | 32.6 -> 25.6 | 29.4 -> 23.4 | 15.0 -> 10.6 | 3.53 -> 2.98 | 12.08 -> 11.60 |
|
||||
| 5 | 34.1 -> 26.4 | 30.2 -> 23.5 | 14.6 -> 10.0 | 3.59 -> 2.99 | 12.38 -> 11.96 |
|
||||
|
||||
Not claimed: parity with vanilla (it stays at 151-174 tok/s and 10.1-11.4 ms/round in the earlier series; this series ran ours at 131-163 tok/s, and vanilla was not run beside it). Not measured: quality of the larger cache by the relative criterion (U), TTFT (the lent slots and the refill are unchanged: 2,227 against 2,236 lent slots).
|
||||
|
||||
### 5.2 Identity at an equal slot count, `runs/footprint2-id` (job `footprint2-id`, 2026-10-30 22:27-22:48Z)
|
||||
|
||||
One test binary (`dt/rt-footprint2`), replay of the 256k capture `night5-long-256k` (5 requests, 48 forced decode tokens each), static tier, `EXPERT_SLOTS=8000` (10,368 slots after the per-layer quota in both processes), seed OFF, `LELEKA_SPEC=4`, RT directory set, top-16
|
||||
logprobs per row; process `idLegacy` with `LELEKA_FOOTPRINT_LEGACY=1` (free VRAM before the cache 23,639 MiB), `idFp2` with the defaults (24,723 MiB, the `footprint:` note present). Each process ran two arms.
|
||||
|
||||
| comparison (`q_pair`, 353 forced rows) | identical | different | argmax flips |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| legacy, arm1 against arm0 (A/A floor) | 353 | 0 | 0 |
|
||||
| footprint2, arm1 against arm0 (A/A) | 353 | 0 | 0 |
|
||||
| footprint2 against legacy, arm0 | 353 | 0 | 0 |
|
||||
| footprint2 against legacy, arm1 | 353 | 0 | 0 |
|
||||
|
||||
`q_tail_gate` of each process: 240 rows, d_top1 and dmax16 all 0.0000, 0 flips, PASS. So the two removals change no logprob of any forced row at an equal slot count (bitwise; 353 rows is a bitwise check, not the 1,000-row relative-criterion gate).
|
||||
The relative-criterion gate for the larger auto cache (12,144 slots) has not been run.
|
||||
|
||||
## 6. What is left of the slot gap (E)
|
||||
|
||||
| lever | VRAM | slots | status |
|
||||
| --- | ---: | ---: | --- |
|
||||
| prompt-path token table aliased onto the native embedding's host mapping (as vanilla) | 324 MiB | +166 | exists (`LELEKA_PROMPT_EMBED_ALIAS=1`), experimental, drafter gather latency not measured |
|
||||
| decode reserve 300 -> 130 MiB | 170 MiB | +87 | exists, opt-in; decode free would be 337 MiB (vanilla runs at 315) |
|
||||
| the pack's 109 MiB dense roles next to the RT directory's 111 MiB copy | 109 MiB | +56 | not done: the prompt-path draft-KV recording reads the pack's, equality of the two copies is not shown |
|
||||
| QSA prompt scratch (128 MiB) and GDN prompt device (50 MiB) carved from the lent slots instead of held | 178 MiB | +90 | not done; every lent MiB is refilled after each prefill |
|
||||
| quota remainder (the table is `layer * quota`) | up to 93 MiB | up to +48 | not done |
|
||||
@@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env bash
|
||||
# claude/slots-footprint2: paired, interleaved 5-turn ~245k session (seed OFF, frozen corpus, upstream ranked profile, auto expert slots) of ONE binary (dt/bin-footprint2, code 1a993970)
|
||||
# with and without its footprint change, so that the only variable is the change itself:
|
||||
# fp2-base-noseed LELEKA_FOOTPRINT_LEGACY=1: the pinned MTP pack's expert bank (675 MiB) next to the RT-directory copy and the 12 eager QSA index-key mirrors (384 MiB) are
|
||||
# held as on main (221801b3): the baseline
|
||||
# fp2-new-noseed defaults: neither is held; the auto expert cache grows by the freed VRAM (placement CLASS change, not bit-identical per se; bit-identity at an equal slot
|
||||
# count is the job footprint2-id.sh)
|
||||
# fp2-alias-noseed (optional, on request) new + LELEKA_PROMPT_EMBED_ALIAS=1: the prompt-path token table (324 MiB) aliased onto the native embedding's host mapping, as vanilla
|
||||
# Everything else is identical: bin-footprint2, E2E_GPU_BUDGET 31,299 MiB (the product profile), EXPERT_SLOTS=auto, prefix cache auto/reply, capacity 8192, chain=all, same corpus.
|
||||
# HOLDER JOB (rnr5090). Install: cp scripts/e2e/decode/footprint2-ab.sh /data/leleka-e2e/decode/dt/jobs/footprint2-ab.sh ; stub ~/work/gpu-runs/holder2/jobs/footprint2-ab.sh
|
||||
# (#!/usr/bin/env bash / exec bash /data/leleka-e2e/decode/dt/jobs/footprint2-ab.sh) ; one line in jobs/PRIORITY. It takes /data/leleka-e2e/gpu.lock per arm. ~12 min an arm.
|
||||
# ARMS="fp2-base-noseed fp2-new-noseed fp2-new-noseed fp2-base-noseed fp2-base-noseed fp2-new-noseed" bash footprint2-ab.sh # the default: 3 pairs, order alternated; pair k = runs 2k-1, 2k
|
||||
# Validity per run (VALIDITY.txt): no turn failed, 5 turns, final-turn input tokens >= 200000, turn-5 mean window.ple < 5 ms. An INVALID run is never used in a comparison.
|
||||
# Reported per run and per arm: decode tok/s per turn, tokens/round (output tokens / rounds of the request), ms/round (decode wall time / rounds) and the dt_agg ms/round
|
||||
# (verify_commit + finish), expert slots ("expert cache N slots"), the lowest free VRAM seen. Vanilla is not run here and no parity with it is claimed.
|
||||
set -uo pipefail
|
||||
D=/data/leleka-e2e/decode/dt
|
||||
LOCK=/data/leleka-e2e/gpu.lock
|
||||
OUTR=/data/leleka-e2e/runs/footprint2-ab
|
||||
CORPUS=/data/leleka-e2e/decode/corpus/src/crates
|
||||
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin # ranked upstream profile; run-e2e.sh refuses any other digest
|
||||
RUN_TAG=${RUN_TAG:-} # suffix of the run directories (a rerun next to earlier ones)
|
||||
ARMS=${ARMS:-"fp2-base-noseed fp2-new-noseed fp2-new-noseed fp2-base-noseed fp2-base-noseed fp2-new-noseed"}
|
||||
SESSION_ARGS="--turns 5 --target-tokens 245000 --max-output 300 --min-final-tokens 200000"
|
||||
for f in "$UP" "$D/tools/long-session.py" "$D/scripts/e2e/run-e2e.sh" "$D/bin-footprint2/leleka-inference" "$CORPUS/backend-api/src/lib.rs"; do
|
||||
[ -r "$f" ] || { echo "missing $f" >&2; exit 3; }
|
||||
done
|
||||
|
||||
ours() { # $1 tag, $2 arm
|
||||
local tag=$1 arm=$2
|
||||
( export E2E_BIN=$D/bin-footprint2 E2E_OUT=$OUTR/$tag
|
||||
mkdir -p "$E2E_OUT"
|
||||
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800}
|
||||
export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p 0"
|
||||
export E2E_SAMPLE_S=10 LELEKA_CHAIN=all
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP
|
||||
unset LELEKA_FOOTPRINT_LEGACY LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_PERF LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB
|
||||
export LELEKA_ORIGINAL_SERVE_SEED=off
|
||||
case $arm in
|
||||
fp2-base-noseed) export LELEKA_FOOTPRINT_LEGACY=1 ;;
|
||||
fp2-new-noseed) ;;
|
||||
fp2-alias-noseed) export LELEKA_PROMPT_EMBED_ALIAS=1 ;;
|
||||
*) echo "unknown ours arm $arm" >&2; exit 2 ;;
|
||||
esac
|
||||
{ echo "arm=$arm tag=$tag"; date -u +%FT%TZ; free -g | sed -n 2p; uptime; sha256sum "$UP" "$E2E_BIN"/leleka-inference "$E2E_BIN"/leleka-daemon "$E2E_BIN"/leleka-cli "$E2E_BIN"/strata-next
|
||||
cat "$E2E_BIN/COMMIT.txt" 2>/dev/null; head -1 /data/leleka-e2e/decode/corpus/MANIFEST.txt
|
||||
env | grep -E '^(LELEKA_|STRATA_|E2E_)' | sort; } >"$E2E_OUT/env-arm.txt"
|
||||
export E2E_RUN_CMD="python3 -I $D/tools/long-session.py --src $CORPUS $SESSION_ARGS"
|
||||
( while sleep 5; do echo "$(date +%T) $(grep -E "SwapFree|MemAvailable|^Cached|Shmem:|Dirty" /proc/meminfo | tr -s " " | tr "
|
||||
" " ") $(head -1 /proc/pressure/io) $(head -1 /proc/pressure/memory) $(awk "/pswpin|pgmajfault/{printf \"%s=%s \",\$1,\$2}" /proc/vmstat)"; done > "$E2E_OUT/memsample.txt" 2>/dev/null ) & SAMP=$!
|
||||
bash "$D/scripts/e2e/run-e2e.sh" 2>&1 | grep -a -E "^\{|expert cache|request outcome|ready after|rc=|refus|error|Error|long_session|client exit" | cut -c1-300
|
||||
kill $SAMP 2>/dev/null
|
||||
echo "run-e2e done $tag $(date -u +%FT%TZ)" )
|
||||
}
|
||||
|
||||
validity() { # $1 run dir
|
||||
python3 -I - "$1" <<'PY'
|
||||
import json, os, re, sys
|
||||
d = sys.argv[1]
|
||||
f = os.path.join(d, "long-session.json")
|
||||
verdict = "INVALID: no long-session.json"
|
||||
if os.path.exists(f):
|
||||
t = json.load(open(f))
|
||||
final = (t[-1].get("input_tokens") or 0) if t else 0
|
||||
if any("error" in r for r in t):
|
||||
verdict = "INVALID: a turn failed"
|
||||
elif len(t) < 5 or final < 200000:
|
||||
verdict = "INVALID: %d turns, final-turn input tokens %d < 200000 (short corpus?)" % (len(t), final)
|
||||
else:
|
||||
verdict = "VALID: 5 turns, final-turn input tokens %d" % final
|
||||
wins, last = [], []
|
||||
for ln in open(os.path.join(d, "inference.log"), errors="replace"):
|
||||
if ln.startswith("DBG window "):
|
||||
last.append(dict((k, float(v)) for k, v in re.findall(r"(\w+)=([-\d.]+)", ln)))
|
||||
elif "leleka-serve request outcome" in ln:
|
||||
wins.append(last); last = []
|
||||
w = wins[-1] if wins else []
|
||||
ple = sum(x.get("ple", 0) for x in w) / max(len(w), 1)
|
||||
verdict += "; turn-5 window.ple mean %.2f ms over %d windows" % (ple, len(w))
|
||||
if not w:
|
||||
verdict = "INVALID: no turn-5 window lines (trace env missing?)"
|
||||
elif ple >= 5:
|
||||
verdict = "INVALID: turn-5 window.ple mean %.2f ms >= 5 ms (PLE scan back?)" % ple
|
||||
open(os.path.join(d, "VALIDITY.txt"), "w").write(verdict + "\n")
|
||||
print(os.path.basename(d), verdict)
|
||||
PY
|
||||
}
|
||||
|
||||
n=0
|
||||
for arm in $ARMS; do
|
||||
n=$((n + 1)); tag="$arm-r$n$RUN_TAG"
|
||||
got=0
|
||||
for _ in $(seq 1 1080); do
|
||||
if mkdir "$LOCK" 2>/dev/null; then echo "footprint2-ab $tag $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi
|
||||
sleep 5
|
||||
done
|
||||
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
|
||||
echo "=== $tag $(date -u +%FT%TZ)"; free -g | sed -n 2p
|
||||
if [ -n "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader)" ]; then
|
||||
echo "GPU busy, skipping $tag"; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; continue
|
||||
fi
|
||||
case $arm in
|
||||
fp2-base-noseed|fp2-new-noseed|fp2-alias-noseed) ours "$tag" "$arm" ;;
|
||||
*) echo "unknown arm $arm" >&2; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; exit 2 ;;
|
||||
esac
|
||||
validity "$OUTR/$tag"
|
||||
echo "arm done $tag $(date -u +%FT%TZ)"
|
||||
rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null
|
||||
sleep 15
|
||||
done
|
||||
|
||||
# summary: per run and per arm, then the adjacent pairs (run numbers 2k-1 and 2k, one base and one candidate, in whatever order)
|
||||
python3 -I - "$OUTR" <<'PY'
|
||||
import glob, json, os, re, statistics, sys
|
||||
root = sys.argv[1]
|
||||
def run_number(path):
|
||||
tail = path.rsplit("-r", 1)[-1]
|
||||
tail = re.sub(r"\D+$", "", tail)
|
||||
return int(tail) if tail.isdigit() else 0
|
||||
def load(d):
|
||||
sess = json.load(open(os.path.join(d, "long-session.json")))
|
||||
reqs, prof = [], None
|
||||
slots, lowest = None, None
|
||||
for ln in open(os.path.join(d, "inference.log"), errors="replace"):
|
||||
if ln.startswith("DBG profile request:"):
|
||||
prof = {m[0]: float(m[1].split("/")[0]) for m in re.findall(r"(\S+?)=([\d.]+/\d+)", ln)}
|
||||
elif "leleka-serve request outcome" in ln:
|
||||
m = re.search(r"produced=(\d+) rounds=(\d+)", ln)
|
||||
reqs.append((int(m.group(1)), int(m.group(2)), prof)); prof = None
|
||||
elif "leleka-serve expert cache" in ln and slots is None:
|
||||
slots = int(re.search(r"expert cache (\d+) slots", ln).group(1))
|
||||
m = re.search(r"DBG vram .*lowest note so far (\d+) MiB", ln)
|
||||
if m:
|
||||
lowest = int(m.group(1)) if lowest is None else min(lowest, int(m.group(1)))
|
||||
rows = []
|
||||
for i, t in enumerate(sess):
|
||||
produced, rounds, p = reqs[i] if i < len(reqs) else (0, 0, None)
|
||||
tps = t.get("decode_tok_s") or 0.0
|
||||
out = t.get("output_tokens") or produced
|
||||
agg = float("nan")
|
||||
if p and rounds and "round.verify_commit" in p and "round.finish" in p:
|
||||
agg = (p["round.verify_commit"] + p["round.finish"]) / rounds
|
||||
rows.append(dict(tps=tps, tok_round=(produced / rounds if rounds else float("nan")),
|
||||
ms_round=(1000.0 * out / tps / rounds if rounds and tps else float("nan")), ms_agg=agg))
|
||||
return rows, slots, lowest
|
||||
def arm(n): return re.sub(r"-r\d+.*$", "", n)
|
||||
runs = {}
|
||||
for d in sorted(glob.glob(os.path.join(root, "*-r[0-9]*")), key=run_number):
|
||||
name = os.path.basename(d)
|
||||
v = os.path.join(d, "VALIDITY.txt")
|
||||
if not os.path.exists(v) or not open(v).read().startswith("VALID"):
|
||||
print(name, "not used:", open(v).read().strip() if os.path.exists(v) else "no VALIDITY.txt")
|
||||
continue
|
||||
runs[name] = load(d)
|
||||
for n, (rows, slots, lowest) in runs.items():
|
||||
print("%-26s slots %s lowest-free-VRAM %s MiB | tok/s %s | tok/round %s | ms/round %s | ms/round(dt_agg) %s" % (n, slots, lowest,
|
||||
" ".join("%.1f" % r["tps"] for r in rows), " ".join("%.2f" % r["tok_round"] for r in rows),
|
||||
" ".join("%.2f" % r["ms_round"] for r in rows), " ".join("%.2f" % r["ms_agg"] for r in rows)))
|
||||
by = {}
|
||||
for n in runs: by.setdefault(arm(n), []).append(n)
|
||||
for a, ns in sorted(by.items()):
|
||||
allrows = [runs[n][0] for n in ns]
|
||||
mean = lambda f: [statistics.mean(f(r[t]) for r in allrows) for t in range(5)]
|
||||
print("ARM %s (%d runs, slots %s): tok/s per turn %s all-turn %.1f | tokens/round %s | ms/round %s" % (a, len(ns), sorted({runs[n][1] for n in ns}),
|
||||
" ".join("%.1f" % x for x in mean(lambda r: r["tps"])), statistics.mean(mean(lambda r: r["tps"])),
|
||||
" ".join("%.2f" % x for x in mean(lambda r: r["tok_round"])), " ".join("%.2f" % x for x in mean(lambda r: r["ms_round"]))))
|
||||
for cand in [a for a in by if a != "fp2-base-noseed"]:
|
||||
diffs, per_turn = [], []
|
||||
for k in range(1, 40):
|
||||
pair = [n for n in runs if (run_number(n) + 1) // 2 == k]
|
||||
b = [n for n in pair if arm(n) == "fp2-base-noseed"]; c = [n for n in pair if arm(n) == cand]
|
||||
if len(b) == 1 and len(c) == 1:
|
||||
rb, rc = runs[b[0]][0], runs[c[0]][0]
|
||||
mb, mc = statistics.mean(x["tps"] for x in rb), statistics.mean(x["tps"] for x in rc)
|
||||
diffs.append(100 * (mc / mb - 1)); per_turn.append([100 * (y["tps"] / x["tps"] - 1) for x, y in zip(rb, rc)])
|
||||
print("pair %d %s vs base: all-turn tok/s %.1f vs %.1f (%+.2f %%), slots %s vs %s" % (k, cand, mc, mb, diffs[-1], runs[c[0]][1], runs[b[0]][1]))
|
||||
if diffs:
|
||||
print("%s over fp2-base-noseed: %d pairs, mean %+.2f %% (min %+.2f max %+.2f); per-turn mean %s" % (cand, len(diffs), statistics.mean(diffs), min(diffs), max(diffs),
|
||||
" ".join("%+.2f" % statistics.mean(c[t] for c in per_turn) for t in range(5))))
|
||||
PY
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
# claude/slots-footprint2 identity gate: the footprint change (no pinned MTP pack expert bank next to the RT-directory copy, lazy QSA index-key mirror) against the same binary with
|
||||
# LELEKA_FOOTPRINT_LEGACY=1 (both buffers held as on main), at an EQUAL FIXED slot count. Nothing reads the two buffers, so the expectation is BITWISE identity (0 flips, max |dlogprob| 0).
|
||||
# HOLDER JOB (copy of speedtrain3-id.sh / draftvocab-id.sh): teacher-forced replay of the 256k-class capture night5-long-256k (5 requests, recorded replies, decode capped at 48 tokens
|
||||
# each), production shape, top-16 logprobs of every row, STATIC tier (ADAPT_EVERY=0), EXPERT_SLOTS=8000 per-layer, seed OFF, LELEKA_SPEC=4, ONE test binary (dt/rt-footprint2) for both
|
||||
# processes. LELEKA_ORIGINAL_SERVE_RT_DIR is set in EVERY process (the product path, `--mtp-rt-dir`); without it the replay stack takes the pack-driven draft and the change does not apply.
|
||||
# p1 idLegacy LELEKA_FOOTPRINT_LEGACY=1, two identical arms I1 I2 (the A/A noise floor, expected 0)
|
||||
# p2 idFp2 defaults, two arms I1 I2
|
||||
# ~8 GPU-min a process, 2 processes, one at a time under gpu.lock; about 20 min.
|
||||
# Install: cp scripts/e2e/decode/footprint2-id.sh /data/leleka-e2e/decode/dt/jobs/footprint2-id.sh; stub in ~/work/gpu-runs/holder2/jobs/footprint2-id.sh (exec bash that file); one line in jobs/PRIORITY.
|
||||
set -uo pipefail
|
||||
LOCK=/data/leleka-e2e/gpu.lock
|
||||
D=/data/leleka-e2e/decode/dt
|
||||
O=/data/leleka-e2e/runs/footprint2-id
|
||||
mkdir -p $O
|
||||
export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
|
||||
A=$HOME/leleka-gates/assets
|
||||
G=$HOME/work/gpu-runs
|
||||
CAP=/data/leleka-e2e/sm120/capture
|
||||
export LELEKA_STRA169_KAR_PROVENANCE=$A/qwen-iq3-s-l2-v4.kar.provenance.json
|
||||
export LELEKA_STRA169_IQ3S_SHARD0=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf
|
||||
export LELEKA_STRA169_IQ3S_SHARD1=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf
|
||||
export LELEKA_STRA169_MTP_PACK=$A/data/mtp-rt LELEKA_STRA169_MTP_STAGING=$G/mtp-staging-own LELEKA_ORIGINAL_SERVE_BUDGET_GIB=30
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.55
|
||||
export LELEKA_SMOKE_PROMPT_CACHE=0 LELEKA_SERVE_PROFILE=1 LELEKA_GRAPH_EXEC_REUSE=off
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin
|
||||
export LELEKA_ORIGINAL_SERVE_RT_DIR=$A/data/mtp-rt
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=8000 LELEKA_CHAIN=all
|
||||
export LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0 LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_ORIGINAL_SERVE_CPU_WORKERS=1 LELEKA_SPEC=4 LELEKA_SPEC_SUFFIX=0
|
||||
unset LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_FOOTPRINT_LEGACY
|
||||
for f in $D/rt-footprint2 $D/tools/q_pair.py $D/tools/q_tail_gate.py $CAP/night5-long-256k; do
|
||||
[ -e "$f" ] || { echo "missing $f" >&2; exit 3; }
|
||||
done
|
||||
sha256sum $D/rt-footprint2
|
||||
shape="reply@8192/8192!orig!fast!nocluster!store!qpf!gpool!mspan"
|
||||
run() { # label bin extra-env arms
|
||||
BIN=$D/$2
|
||||
got=0
|
||||
for i in $(seq 1 1080); do
|
||||
if mkdir $LOCK 2>/dev/null; then echo "footprint2 identity $1 $(date -u +%FT%TZ)" >$LOCK/owner; got=1; break; fi
|
||||
sleep 5
|
||||
done
|
||||
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; return 3; }
|
||||
avail=$(awk '/MemAvailable/{print int($2/1048576)}' /proc/meminfo); echo "=== $1 bin=$2 extra=[$3] MemAvailable GiB: $avail"; free -g | sed -n 2,3p
|
||||
if [ "$avail" -lt 60 ]; then echo "abort: less than 60 GiB available"; rm -f $LOCK/owner; rmdir $LOCK; return 4; fi
|
||||
date -u +%FT%TZ
|
||||
env $3 LELEKA_ORIGINAL_SERVE_REPLAY=yes LELEKA_BRINGUP_TRACE=1 LELEKA_REPLAY_DIR=$CAP/night5-long-256k LELEKA_PREFIX_TRACE=1 LELEKA_REPLAY_PREFIX_MIB=6000 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_LOGPROBS=16 \
|
||||
LELEKA_REPLAY_MAX_NEW=48 LELEKA_REPLAY_FORCE=1 LELEKA_REPLAY_ARMS=$4 \
|
||||
nice -n 5 $BIN --ignored --exact --test-threads=1 --nocapture backend::original_serve_replay::original_serve_replay_smoke > $O/$1.full 2>&1
|
||||
echo "rc=$? label=$1"; date -u +%FT%TZ
|
||||
grep -a -E "^REPLAY|test result|panicked|FAILED|expert cache [0-9]+ slots|leleka-serve dense weights" $O/$1.full | cut -c1-300 | tail -10
|
||||
rm -f $LOCK/owner; rmdir $LOCK 2>/dev/null
|
||||
sleep 15
|
||||
}
|
||||
run idLegacy rt-footprint2 "LELEKA_FOOTPRINT_LEGACY=1" "I1=$shape,I2=$shape"
|
||||
run idFp2 rt-footprint2 "LELEKA_X=1" "I1=$shape,I2=$shape"
|
||||
T=$D/tools
|
||||
PROCS="idLegacy idFp2"
|
||||
for p in $PROCS; do echo "== q_tail_gate $p"; python3 $T/q_tail_gate.py $O/$p.full $CAP/night5-long-256k 2>&1 | tail -12; done
|
||||
python3 - <<PY
|
||||
import sys
|
||||
sys.path.insert(0, "$T")
|
||||
import q_pair
|
||||
rows = {p: [q_pair.rows_of("$O/%s.full" % p, i) for i in (0, 1)] for p in ("idLegacy", "idFp2")}
|
||||
q_pair.compare(rows["idLegacy"][0], rows["idLegacy"][1], "legacy footprint, arm1 against arm0 (A/A noise floor)")
|
||||
q_pair.compare(rows["idFp2"][0], rows["idFp2"][1], "footprint2, arm1 against arm0 (A/A)")
|
||||
q_pair.compare(rows["idLegacy"][0], rows["idFp2"][0], "footprint2 against legacy, arm0")
|
||||
q_pair.compare(rows["idLegacy"][1], rows["idFp2"][1], "footprint2 against legacy, arm1")
|
||||
PY
|
||||
sha256sum $O/*.full
|
||||
date -u +%FT%TZ
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# claude/slots-footprint2: ONE short ours run with LELEKA_VRAM_LEDGER=1 to read the per-call-site device allocation ledger of the opening stages
|
||||
# (what the 2094 MiB "prompt executor + MTP drafter" and 944 MiB "MoE arena cache" consist of). Not a measurement of speed. ~5 min.
|
||||
# HOLDER JOB (rnr5090). Install: cp this file to /data/leleka-e2e/decode/dt/jobs/slots2-ledger.sh; queue stub in ~/work/gpu-runs/holder2/jobs/slots2-ledger.sh
|
||||
# (#!/usr/bin/env bash / exec bash /data/leleka-e2e/decode/dt/jobs/slots2-ledger.sh), one line in jobs/PRIORITY.
|
||||
# BIN=<dt/bin-dir name> (default bin-speedtrain3 = main's engine code for this purpose); extra env of the engine is passed through the variable EXTRA_ENV="A=1 B=2".
|
||||
set -uo pipefail
|
||||
D=/data/leleka-e2e/decode/dt
|
||||
LOCK=/data/leleka-e2e/gpu.lock
|
||||
BIN=${BIN:-bin-speedtrain3}
|
||||
TAG=${TAG:-ledger-$BIN}
|
||||
OUT=/data/leleka-e2e/runs/slots2/$TAG
|
||||
CORPUS=/data/leleka-e2e/decode/corpus/src/crates
|
||||
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin
|
||||
for f in "$UP" "$D/tools/long-session.py" "$D/scripts/e2e/run-e2e.sh" "$D/$BIN/leleka-inference" "$CORPUS/backend-api/src/lib.rs"; do [ -r "$f" ] || { echo "missing $f" >&2; exit 3; }; done
|
||||
got=0
|
||||
for _ in $(seq 1 1080); do
|
||||
if mkdir "$LOCK" 2>/dev/null; then echo "slots2-ledger $TAG $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi
|
||||
sleep 5
|
||||
done
|
||||
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
|
||||
if [ -n "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader)" ]; then echo "GPU busy"; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; exit 3; fi
|
||||
(
|
||||
export E2E_BIN=$D/$BIN E2E_OUT=$OUT
|
||||
mkdir -p "$E2E_OUT"
|
||||
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1 LELEKA_VRAM_LEDGER=1
|
||||
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800}
|
||||
export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p 0"
|
||||
export E2E_SAMPLE_S=10 LELEKA_CHAIN=all LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP
|
||||
unset LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_PERF LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_DENSE_SLAB LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB
|
||||
for kv in ${EXTRA_ENV:-}; do export "$kv"; done
|
||||
{ echo "tag=$TAG bin=$BIN"; date -u +%FT%TZ; sha256sum "$E2E_BIN"/leleka-inference; cat "$E2E_BIN/COMMIT.txt" 2>/dev/null; env | grep -E '^(LELEKA_|STRATA_|E2E_)' | sort; } >"$E2E_OUT/env-arm.txt"
|
||||
export E2E_RUN_CMD="python3 -I $D/tools/long-session.py --src $CORPUS --turns 2 --target-tokens 12000 --max-output 40 --min-final-tokens 0"
|
||||
bash "$D/scripts/e2e/run-e2e.sh" 2>&1 | grep -a -E "^\{|expert cache|request outcome|ready after|rc=|refus|error|Error|long_session|client exit" | cut -c1-300
|
||||
)
|
||||
grep -a -E "^(DBG vram|DBG memory stage|DBG ledger|leleka-serve expert cache)|ledger" "$OUT/inference.log" | cut -c1-400 > "$OUT/ledger.txt"
|
||||
echo "ledger lines: $(wc -l < "$OUT/ledger.txt") -> $OUT/ledger.txt"
|
||||
rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null
|
||||
Reference in New Issue
Block a user