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
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ members = [
]

[workspace.package]
version = "0.3.70"
version = "0.3.71"
edition = "2024"
license = "MIT"
repository = "https://github.com/profullstack/c0mpute"
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@c0mpute/desktop",
"productName": "c0mpute",
"desktopName": "c0mpute-desktop.desktop",
"version": "0.3.70",
"version": "0.3.71",
"private": true,
"type": "module",
"description": "c0mpute desktop: chat, agent with your MCP servers and skills, node manager, hosting and tasks, with the c0mpute CLI bundled.",
Expand Down
2 changes: 1 addition & 1 deletion apps/tui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0mpute/tui",
"version": "0.3.70",
"version": "0.3.71",
"private": true,
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0mpute",
"version": "0.3.70",
"version": "0.3.71",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/releases/latest.json/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const dynamic = "force-dynamic";
* this in sync with the workspace version in `Cargo.toml` on each release so a
* freshly built CLI reports "already latest" rather than a phantom upgrade.
*/
const FALLBACK_VERSION = "0.3.70";
const FALLBACK_VERSION = "0.3.71";
const FALLBACK_MIN_REQUIRED = "0.0.1";

type Channel = "stable" | "beta" | "nightly";
Expand Down
4 changes: 4 additions & 0 deletions node/crates/c0mpute-core/src/buyer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ pub async fn resume_auction(
load: None,
e2e: None,
instance: None,
model: None,
fallback: None,
},
receipt,
external_ref: job.external_ref.clone(),
Expand Down Expand Up @@ -1130,6 +1132,8 @@ mod tests {
load: None,
e2e: None,
instance: None,
model: None,
fallback: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions node/crates/c0mpute-core/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub fn role_tags(config: &Config) -> Vec<String> {
let models = crate::inference::ready_models();
if !models.is_empty() {
tags.push(crate::inference::ROLE_TAG.to_string());
tags.push(crate::inference::ACCEPT_TAG.to_string());
tags.extend(models.iter().map(|m| crate::inference::model_tag(m)));
}
}
Expand Down
39 changes: 38 additions & 1 deletion node/crates/c0mpute-core/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,21 @@ pub fn run_worker_subscriber_with_load(
);
continue;
}
let eta = eta_seconds(
// Jobs already running share this box with the new one.
let busy = capacity
.free_slots
.map(|free| capacity.total_slots.saturating_sub(free))
.unwrap_or(0);
// Inference offers may accept alternatives: which model we
// would answer with, and whether it is one (see routing).
let pick = if offer.workload_type == crate::inference::WORKLOAD {
crate::inference::bid_model(&offer)
} else {
None
};
let eta = eta_seconds_busy(
capacity.queued,
busy,
capacity.total_slots,
load.as_ref().and_then(WorkerLoad::recent_job_duration),
);
Expand All @@ -295,6 +308,7 @@ pub fn run_worker_subscriber_with_load(
eta,
bench.get(),
capacity.load_fraction(queue_load(tx)),
pick,
)
.await
{
Expand Down Expand Up @@ -573,6 +587,21 @@ impl Capacity {
/// `total_slots` at a time, then it runs, each wave taking about the recent
/// average job time ([`DEFAULT_ETA_SECS`] before any job has completed).
pub(crate) fn eta_seconds(queued: usize, total_slots: usize, recent: Option<Duration>) -> u64 {
eta_seconds_busy(queued, 0, total_slots, recent)
}

/// [`eta_seconds`] on a node already running `busy` jobs: they share the box
/// with the new one, so each running job stretches it by 1/`total_slots`
/// (an idle node quotes its plain recent time, a half-busy one 1.5x). Before
/// this a working node quoted the same ETA as an idle one and kept winning.
pub(crate) fn eta_seconds_busy(queued: usize, busy: usize, total_slots: usize, recent: Option<Duration>) -> u64 {
let slots = total_slots.max(1);
let contention = 1.0 + busy.min(slots) as f64 / slots as f64;
let plain = eta_plain(queued, total_slots, recent);
((plain as f64 * contention).ceil() as u64).clamp(1, MAX_ETA_SECS)
}

fn eta_plain(queued: usize, total_slots: usize, recent: Option<Duration>) -> u64 {
let per_job = recent
.map(|d| d.as_secs_f64())
.filter(|s| *s > 0.0)
Expand Down Expand Up @@ -685,6 +714,7 @@ async fn handle_offer(
eta_seconds: u64,
bench_score: Option<u32>,
bid_load: f32,
pick: Option<(String, bool)>,
) -> Option<(f64, u64, Vec<u8>, Option<crate::job_e2e::WorkerSession>)> {
let now_ms = unix_ms();
if !offer_is_fresh(offer.published_at_ms, now_ms) {
Expand Down Expand Up @@ -755,6 +785,8 @@ async fn handle_offer(
load: Some(bid_load),
e2e,
instance: Some(net.instance_id().to_string()),
model: pick.as_ref().map(|(m, _)| m.clone()),
fallback: pick.as_ref().map(|(_, f)| *f),
};
let payload = match serde_json::to_vec(&bid) {
Ok(b) => b,
Expand Down Expand Up @@ -1179,5 +1211,10 @@ mod tests {
assert_eq!(eta_seconds(3, 1, None), 4 * DEFAULT_ETA_SECS);
assert_eq!(eta_seconds(0, 0, Some(Duration::from_millis(1))), 1);
assert_eq!(eta_seconds(usize::MAX, 1, None), MAX_ETA_SECS);
// A node already running jobs says so in its ETA.
assert_eq!(eta_seconds_busy(0, 0, 2, Some(Duration::from_secs(87))), 87);
assert_eq!(eta_seconds_busy(0, 1, 2, Some(Duration::from_secs(87))), 131);
assert_eq!(eta_seconds_busy(0, 2, 2, Some(Duration::from_secs(10))), 20);
assert_eq!(eta_seconds_busy(0, 9, 2, Some(Duration::from_secs(10))), 20, "busy is capped at the slot count");
}
}
Loading
Loading