Skip to content

Commit

Permalink
add model info to specs
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Jan 16, 2025
1 parent 1bf0adf commit d9d75b5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
10 changes: 5 additions & 5 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 @@ -9,7 +9,7 @@ default-members = ["compute"]

[workspace.package]
edition = "2021"
version = "0.2.32"
version = "0.2.33"
license = "Apache-2.0"
readme = "README.md"

Expand Down
3 changes: 2 additions & 1 deletion compute/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl DriaComputeNode {
(None, None)
};

let model_names = config.workflows.get_model_names();
Ok((
DriaComputeNode {
config,
Expand All @@ -134,7 +135,7 @@ impl DriaComputeNode {
pending_tasks_batch: HashSet::new(),
completed_tasks_single: 0,
completed_tasks_batch: 0,
spec_collector: SpecCollector::new(),
spec_collector: SpecCollector::new(model_names),
last_pinged_at: Instant::now(),
},
p2p_client,
Expand Down
18 changes: 12 additions & 6 deletions compute/src/utils/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,35 @@ pub struct Specs {
os: String,
/// CPU architecture, e.g. `x86_64`, `aarch64`.
arch: String,
// GPU adapter infos, showing information about the available GPUs.
// gpus: Vec<wgpu::AdapterInfo>,
/// Public IP lookup response.
lookup: Option<LookupResponse>,
/// Used models.
models: Vec<String>,
// GPU adapter infos, showing information about the available GPUs.
// gpus: Vec<wgpu::AdapterInfo>,
}

pub struct SpecCollector {
/// System information object, this is expected to be created only once
/// as per the [docs](https://github.com/GuillaumeGomez/sysinfo?tab=readme-ov-file#good-practice--performance-tips).
system: sysinfo::System,
/// Used models.
models: Vec<String>,
// GPU adapter infos, showing information about the available GPUs.
// gpus: Vec<wgpu::AdapterInfo>,
}

impl Default for SpecCollector {
fn default() -> Self {
Self::new()
Self::new(vec![])
}
}

impl SpecCollector {
pub fn new() -> Self {
pub fn new(models: Vec<String>) -> Self {
SpecCollector {
system: sysinfo::System::new_with_specifics(Self::get_refresh_specifics()),
models,
// gpus: wgpu::Instance::default()
// .enumerate_adapters(wgpu::Backends::all())
// .into_iter()
Expand Down Expand Up @@ -68,8 +73,9 @@ impl SpecCollector {
cpu_usage: self.system.global_cpu_usage(),
os: std::env::consts::OS.to_string(),
arch: std::env::consts::ARCH.to_string(),
// gpus: self.gpus.clone(),
lookup: public_ip_address::perform_lookup(None).await.ok(),
models: self.models.clone(),
// gpus: self.gpus.clone(),
}
}
}
Expand All @@ -80,7 +86,7 @@ mod tests {
#[tokio::test]
#[ignore = "run manually"]
async fn test_print_specs() {
let mut spec_collector = SpecCollector::new();
let mut spec_collector = SpecCollector::new(vec!["gpt-4o".to_string()]);
let specs = spec_collector.collect().await;
println!("{}", serde_json::to_string_pretty(&specs).unwrap());
}
Expand Down
10 changes: 10 additions & 0 deletions workflows/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl DriaWorkflowsConfig {
}

/// Returns the list of unique providers in the config.
#[inline]
pub fn get_providers(&self) -> Vec<ModelProvider> {
self.models
.iter()
Expand All @@ -191,6 +192,15 @@ impl DriaWorkflowsConfig {
})
}

/// Returns the list of all models in the config.
#[inline]
pub fn get_model_names(&self) -> Vec<String> {
self.models
.iter()
.map(|(_, model)| model.to_string())
.collect()
}

/// Check if the required compute services are running.
/// This has several steps:
///
Expand Down

0 comments on commit d9d75b5

Please sign in to comment.