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
19 changes: 10 additions & 9 deletions crates/vectorprime-optimizer/src/bayes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl SearchSpace {
/// for small sample counts, which leads to better initial coverage.
pub fn halton_samples(&self, n: usize) -> Vec<ConfigPoint> {
// Start at index 1 (index 0 maps to all-zeros, a degenerate point).
(1..=n).map(|i| halton_point(i)).collect()
(1..=n).map(halton_point).collect()
}
}

Expand Down Expand Up @@ -473,7 +473,7 @@ impl GpModel {
/// system is singular or has zero rows.
///
/// `a` is modified in-place as part of elimination.
fn solve_linear(a: &mut Vec<Vec<f64>>, b: &[f64]) -> Vec<f64> {
fn solve_linear(a: &mut [Vec<f64>], b: &[f64]) -> Vec<f64> {
let n = b.len();
if n == 0 || a.is_empty() {
return vec![];
Expand Down Expand Up @@ -510,18 +510,19 @@ fn solve_linear(a: &mut Vec<Vec<f64>>, b: &[f64]) -> Vec<f64> {
aug.swap(col, pivot);

let scale = aug[col][col];
for j in col..=n {
aug[col][j] /= scale;
for val in aug[col].iter_mut().skip(col) {
*val /= scale;
}

for row in 0..n {
// Collect pivot row once to avoid borrow checker issues with nested indexing
let pivot_row: Vec<f64> = aug[col][col..=n].to_vec();
for (row, row_data) in aug.iter_mut().enumerate() {
if row == col {
continue;
}
let factor = aug[row][col];
for j in col..=n {
let v = aug[col][j] * factor;
aug[row][j] -= v;
let factor = row_data[col];
for (i, val) in pivot_row.iter().enumerate() {
row_data[col + i] -= val * factor;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vectorprime-optimizer/src/hierarchical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ async fn run_phase1(
// benchmark::run_benchmarks, since AdapterRegistry is not Send).
let handles: Vec<_> = runtimes
.iter()
.cloned()
.map(|runtime| {
let runtime = runtime.clone();
let model = Arc::clone(&model);
let cfg = Arc::clone(&cfg);
tokio::task::spawn_blocking(move || {
Expand Down
9 changes: 3 additions & 6 deletions crates/vectorprime-optimizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ fn all_llamacpp_not_installed(
.filter(|(cfg, _)| cfg.runtime == RuntimeKind::LlamaCpp)
.collect();
!llamacpp_results.is_empty()
&& llamacpp_results.iter().all(|(_, r)| {
r.as_ref()
.err()
.map(|e| is_not_installed(e))
.unwrap_or(false)
})
&& llamacpp_results
.iter()
.all(|(_, r)| r.as_ref().err().map(is_not_installed).unwrap_or(false))
}

/// Remove entries where the error is [`RuntimeError::NotInstalled`] for any
Expand Down
Loading