Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,14 @@ memory budget. The cache remains fixed in size while serving and warms
from requests each time the server starts.

`--embedding-table-resident-scales` loads the original scale plane into immutable
host RAM before KV sizing. Disk-backed tables enable this by default unless any
selected GPU shares host memory, as on DGX Spark. Explicit enable and disable
flags override the hardware default on each host. RAM table storage and cores
without embedding tables do not enable it automatically. It applies to every
table in the core's embedding catalog, including Qwen PLE and DeepSeek Engram. The loader uses the declared
host RAM before KV sizing. Disk-backed tables carrying scales enable this by
default unless any selected GPU shares host memory, as on DGX Spark. Explicit
enable and disable flags override the hardware default on each host; explicitly
enabling it fails loading when the core has no embedding tables or when no table
in the catalog carries a scale plane (such as single-plane `BF16` tables). RAM
table storage, cores without embedding tables, and single-plane tables do not
enable it automatically. It applies to every table with a scale plane in the
core's embedding catalog, including Qwen PLE and DeepSeek Engram. The loader uses the declared
weight and scale row sizes; it does not select behavior by model identity.
Weight rows remain on disk, and a row-cache miss reads
only the weight plane. The resident scale allocation is additional to
Expand Down
7 changes: 4 additions & 3 deletions docs/core-format-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,18 @@ Tuning-dependent layouts occupy separate payloads. TP-specific files exist only
for byte-distinct layouts required by selected deployments.

Offloaded DeepSeek Engram and Qwen PLE tables are stored separately from ordinary
weight groups. Each full table uses `weights/engram-<index>-weights.safetensors`
weight groups. Each full two-plane table uses `weights/engram-<index>-weights.safetensors`
and `weights/engram-<index>-scales.safetensors`, with checkpoint row ordering
independent of TP size. Every host receives the full table; local ranks share
independent of TP size; single-plane encodings such as `BF16` omit the `-scales`
file. Every host receives the full table; local ranks share
its reader and row cache. Disk backing requires only bounded staging and row
cache memory. DeepSeek's projection and reduction are TP-sharded, while
its graph requests use canonical full-table row IDs on every rank. A core
whose tables record partition-local rows executes with that recorded layout.
A table recorded with rank-owned row partitions (`EngramTable.shards`) stores
each partition's planes as
`deployments/<deployment>/engram-<index>-shard-<position>-weights.safetensors`
and the matching `-scales` file.
and, for two-plane encodings, the matching `-scales` file.

Hardware names in deployment IDs and cache-entry names use device identifiers
such as `gb202` and `gb10`, producing names such as `gb202-tp1` and `gb10-tp2`.
Expand Down
5 changes: 3 additions & 2 deletions docs/model-preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,9 @@ check. GPU weights, KV, registered host buffers, resident embedding tables,
compiler workers, and the OS compete for that memory. Set `[memory] reserve`
for host activity as well as driver headroom; `reserve = "4G"` leaves four GiB
outside the model's cache budget. RAM embedding tables load before cache
sizing. Disk embedding tables use bounded staging and can retain their scale
planes in RAM with `--embedding-table-resident-scales`. The loader accounts for
sizing. Disk embedding tables use bounded staging and, for tables carrying a
scale plane, can retain their scale planes in RAM with
`--embedding-table-resident-scales`. The loader accounts for
resident scales and the optional row cache before sizing KV, for both PLE and
Engram cores. Disk tables default to a 1 GiB host-RAM row cache per Spark;
`--embedding-table-cache-size` overrides it, and `0` disables it.
Expand Down
29 changes: 23 additions & 6 deletions heliopause/src/embedding_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::engram::Binding;
#[cfg(unix)]
use crate::engram::{PlaneSource, PreparedTables, SourceSegment, TableSource};
#[cfg(unix)]
use pyo3::exceptions::{PyRuntimeError, PyValueError};
use pyo3::{exceptions::PyKeyError, prelude::*};
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyValueError};
use pyo3::prelude::*;
#[cfg(unix)]
use std::{collections::HashMap, path::PathBuf};

Expand All @@ -38,16 +38,33 @@ fn sources(value: &Bound<'_, PyAny>) -> PyResult<(usize, Vec<TableSource>)> {
row_bytes: plane.get_item("row_bytes")?.extract()?,
});
}
if planes.len() != 2 {
if planes.is_empty() || planes.len() > 2 {
return Err(PyValueError::new_err(
"embedding table requires weight and scale planes",
"embedding table requires weight plane and optional scale plane",
));
}
let weights_plane = planes.remove(0);
let scales_plane = (!planes.is_empty()).then(|| planes.remove(0));
let scales_name: Option<String> = match table.get_item("scales") {
Ok(item) if item.is_none() => None,
Ok(item) => Some(item.extract()?),
Err(error) if error.is_instance_of::<PyKeyError>(table.py()) => None,
Err(error) => return Err(error),
};
let scales = match (scales_plane, scales_name) {
(Some(plane), Some(name)) => Some((plane, name)),
(None, None) => None,
_ => {
return Err(PyValueError::new_err(
"embedding table scale plane and scale buffer binding must both be present or both absent",
));
}
};
tables.push(TableSource {
planes: [planes.remove(0), planes.remove(0)],
weights_plane,
heads: table.get_item("heads")?.extract()?,
weights: table.get_item("weights")?.extract()?,
scales: table.get_item("scales")?.extract()?,
scales,
hashes: table.get_item("hashes")?.extract()?,
event: table.get_item("event")?.extract()?,
request: table.get_item("request")?.extract()?,
Expand Down
3 changes: 3 additions & 0 deletions heliopause/src/export/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ fn append_planes(
) -> super::Result<()> {
for name in ["weights", "scales"] {
if let Some(parts) = value.get_mut(name) {
if parts.is_null() {
continue;
}
let sources: Vec<super::FileSource> = serde_json::from_value(parts.clone())?;
*cursor = align(*cursor)?;
let start = *cursor;
Expand Down
Loading