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
14 changes: 11 additions & 3 deletions docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,12 @@ These are startup sizing budgets, not OS-enforced quotas. Pools stay fixed
during serving; Flare does not resize them as other processes allocate memory.
Startup reports the requested policies, loaded footprint, per-rank cache
budgets, allocated KV tokens, and whether memory, the selected KV ceiling, or
prepared virtual extents limited the pool. TP ranks agree on a capacity each
prepared virtual extents limited the pool. On Linux integrated GPUs, the `Plan
cache` summary also appends `MemFree / MemAvailable / Cached` from
`/proc/meminfo`, emits a stderr warning when KV sizing is limited by memory and
`MemAvailable - MemFree` exceeds 10 GiB, and attaches those counts (with a
`drop_caches` hint when the reclaimable gap exceeds 4 GiB) to
`CUDA_ERROR_OUT_OF_MEMORY` failures during CUDA context creation. TP ranks agree on a capacity each
can back. Runtime memory flags reuse the same prepared core and do not
alter preparation or captured graphs. They are absent
from `ignition export` and the diagnostic `ignition debug-serve` commands.
Expand Down Expand Up @@ -1458,8 +1463,11 @@ The request controls the seed.
`memory.reserve` exists for one case: a process that starts after Flare and
needs GPU memory. Processes already running when Flare starts need no
setting, because supply is free memory rather than card size. Preparation records
it as the core's serving reserve. Native serving uses an explicit host configuration
value in preference to that recorded reserve.
it as the core's serving reserve. Native serving (`flare run` and `flare orbit
run`) uses an explicit host configuration value in preference to that recorded
reserve; on `orbit run`, the inherited value applies at launch when neither the
command line nor a saved persistent group sets `--memory-limit`, and is never
persisted into the group definition.

The GPU prefix cache is derived. It holds model states at instruction,
prompt, and answer boundaries so that later requests repeating a prefix skip
Expand Down
15 changes: 11 additions & 4 deletions docs/orbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,14 @@ Local core, executable, and verification paths are saved as absolute paths.
The definition is written after placement validation and
before starting ranks, so a startup failure can be retried. `--dry-run` saves
nothing. A later run uses the saved configuration; overrides affect that launch
only unless `--persistent` is passed again. An existing running group with the
same saved name on the candidate nodes prevents another launch.
only unless `--persistent` is passed again. When neither the command line nor
the saved group specifies `--memory-limit`, `orbit run` inherits `[memory]
reserve` from the controller's Flare configuration at launch without writing
it into the saved `serving` list, so later `[memory] reserve` edits take effect
automatically while a saved explicit `--memory-limit` still takes precedence
over configuration (and a CLI `--memory-limit` overrides both). An existing
running group with the same saved name on the candidate nodes prevents another
launch.

`flare orbit ls` keeps saved groups visible when stopped. An unreachable node
makes an inactive saved group's state unknown. Saved definitions belong to the
Expand Down Expand Up @@ -464,8 +470,9 @@ serve. It applies these rules in order:
The controller prints the placement, one member per line with its node, GPU
and whether the node already holds its rank, before transferring payloads.
`--dry-run` stops there after metadata verification and node queries. The planner
does not set `--memory-limit`; groups on disjoint GPUs retain their own serving
memory settings. Placement does not check ring adjacency; routing follows the
does not set `--memory-limit`; groups on disjoint GPUs keep their own explicit
or saved serving memory settings (inheriting the controller's `[memory] reserve`
when neither specifies `--memory-limit`). Placement does not check ring adjacency; routing follows the
selected rank order.

## Core caching
Expand Down
6 changes: 6 additions & 0 deletions flare-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,12 @@ pub struct OrbitRun {

#[command(flatten)]
pub serving: ServingOptions,

/// `[memory] reserve` inherited from host configuration; kept separate from
/// `serving.memory_limit` so it is never persisted into a group's saved options and
/// applies at launch only when neither a saved group nor the CLI specifies `--memory-limit`.
#[arg(skip)]
pub config_memory_limit: Option<MemoryLimit>,
}

impl OrbitRun {
Expand Down
109 changes: 108 additions & 1 deletion flare-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Configuration {
)?))
}
#[cfg(test)]
fn parse(text: &str) -> Result<Self, Failure> {
pub(crate) fn parse(text: &str) -> Result<Self, Failure> {
Ok(Self(flare::configuration::Configuration::parse(text)?))
}
pub(crate) fn apply(
Expand Down Expand Up @@ -169,6 +169,11 @@ impl Configuration {
},
cli::Command::Orbit(args) => match &mut args.command {
cli::OrbitCommand::Run(run) => {
if run.serving.memory_limit.is_none() {
run.config_memory_limit =
size(self.memory.reserve.as_deref(), "memory.reserve")?
.map(MemoryLimit::Reserve);
}
run.serving.hub.core_cache.get_or_insert(cache);
run.serving.hub.hub_cache = Some(hub_cache.clone());
}
Expand Down Expand Up @@ -961,4 +966,106 @@ namespace = "publisher"
);
}
}

#[test]
fn orbit_run_inherits_memory_reserve_unless_explicit_limit_is_set() {
let home = Path::new("/home/test-user");
let configured = Configuration::parse("[memory]\nreserve = '12 GiB'\n").unwrap();

let parse_orbit_run =
|args: &[&str], cfg: &Configuration| -> (cli::OrbitRun, Vec<String>) {
let matches = cli::Cli::command().try_get_matches_from(args).unwrap();
let mut parsed = cli::Cli::from_arg_matches(&matches).unwrap();
cfg.apply(&mut parsed, &matches, home).unwrap();
let cli::Command::Orbit(orbit) = parsed.command else {
panic!("expected orbit command");
};
let cli::OrbitCommand::Run(run) = orbit.command else {
panic!("expected orbit run");
};
let run_matches = matches
.subcommand_matches("orbit")
.unwrap()
.subcommand_matches("run")
.unwrap();
let options = run.rank_options(run_matches);
(*run, options)
};

// Omitted --memory-limit inherits [memory] reserve into config_memory_limit, keeping it
// out of rank_options so persistent groups never freeze the config default.
let (inherited, options) =
parse_orbit_run(&["flare", "orbit", "run", "model.safetensors"], &configured);
assert_eq!(inherited.serving.memory_limit, None);
assert_eq!(
inherited.config_memory_limit,
Some(MemoryLimit::Reserve(12 << 30))
);
assert!(
!options.iter().any(|arg| arg.starts_with("--memory-limit")),
"{options:?}"
);

// Explicit --memory-limit takes precedence over [memory] reserve and enters rank_options.
let (explicit_fraction, options) = parse_orbit_run(
&[
"flare",
"orbit",
"run",
"model.safetensors",
"--memory-limit=0.8",
],
&configured,
);
assert_eq!(
explicit_fraction.serving.memory_limit,
Some(MemoryLimit::Fraction(0.8))
);
assert_eq!(explicit_fraction.config_memory_limit, None);
assert!(
options
.iter()
.any(|arg| arg == &format!("--memory-limit={}", MemoryLimit::Fraction(0.8))),
"{options:?}"
);

let (explicit_reserve, options) = parse_orbit_run(
&[
"flare",
"orbit",
"run",
"model.safetensors",
"--memory-limit=-4G",
],
&configured,
);
assert_eq!(
explicit_reserve.serving.memory_limit,
Some(MemoryLimit::Reserve(4 << 30))
);
assert_eq!(explicit_reserve.config_memory_limit, None);
assert!(
options
.iter()
.any(|arg| arg == &format!("--memory-limit={}", MemoryLimit::Reserve(4 << 30))),
"{options:?}"
);

// Unset config leaves both memory_limit and config_memory_limit None.
let empty = Configuration::default();
let (unset, options) =
parse_orbit_run(&["flare", "orbit", "run", "model.safetensors"], &empty);
assert_eq!(unset.serving.memory_limit, None);
assert_eq!(unset.config_memory_limit, None);
assert!(
!options.iter().any(|arg| arg.starts_with("--memory-limit")),
"{options:?}"
);

// Invalid [memory] reserve is rejected when loading configuration.
let err = Configuration::parse("[memory]\nreserve = 'not-a-size'\n")
.err()
.expect("invalid memory.reserve should fail");
assert!(err.to_string().contains("memory.reserve"), "{err}");
}
}
4 changes: 3 additions & 1 deletion flare-cli/src/core_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ fn store_entry(
return Err("invalid cached payload blob".into());
}
let mut digest = Sha256::new();
std::io::copy(&mut source, &mut digest)?;
let copied = std::io::copy(&mut source, &mut digest);
flare_helios::release_page_cache(&source);
copied?;
if format!("{}.safetensors", hex(&digest.finalize())) != blob {
return Err("cached payload digest mismatch".into());
}
Expand Down
Loading