Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f00d717
enable loading second half only on demand
dkales Apr 7, 2025
0672220
fix test
dkales Apr 9, 2025
e91527d
add OnDemandLoader trait
dkales Apr 9, 2025
d491f1a
wip on demand loading
dkales Apr 9, 2025
1508170
use ondemand loader
dkales Apr 9, 2025
118e53f
fix copy of sums to device
dkales Apr 9, 2025
d7c126a
debug
dkales Apr 9, 2025
bc69a14
dbg
dkales Apr 9, 2025
7764586
dbg
dkales Apr 9, 2025
c4c21b0
dbg
dkales Apr 9, 2025
d2952a0
use masks engine for masks
dkales Apr 9, 2025
c81de28
change interface of ondemand loader to return full vec
dkales Apr 22, 2025
1c682fb
prepare testdb for having changes changes
dkales Apr 22, 2025
69e2755
persist changes to shared db in tests
dkales Apr 22, 2025
1c711a6
allow out of order insertions
dkales Apr 22, 2025
ddd0ed1
do not insert multiple times per party
dkales Apr 22, 2025
7695024
handle deletions correctly in internal db representation
dkales Apr 22, 2025
e15a4b7
handle resets correctly in internal db representation
dkales Apr 22, 2025
1f12ffb
give tests more stack
dkales Apr 22, 2025
67d11ea
debug
dkales Apr 22, 2025
aabc78f
reduce stack usage in test
dkales Apr 22, 2025
9776312
revert test tokio setup to default
dkales Apr 22, 2025
3a65594
also handle reauth persistence in tests
dkales Apr 22, 2025
bc217f3
feature gate again
dkales Apr 22, 2025
7907c3a
implement OnDemandLoader for database
dkales Apr 22, 2025
4a2ef9a
add config for using on demand loader in GPU server
dkales Apr 22, 2025
919cbe3
add test for on-demand loading and add sanity checks
dkales Apr 23, 2025
2404343
add timing info to iris loading
dkales Apr 23, 2025
ba6c6f7
fix test
dkales Apr 23, 2025
6b99c5a
move to async trait
dkales Apr 23, 2025
8ec72fe
fix sql
dkales Apr 23, 2025
0e6c22c
fix duplicate code
dkales Apr 24, 2025
939631b
add timing to CPU->GPU push for subset
dkales Apr 24, 2025
75aa504
make db subset to GPU copy more CUDA-async
dkales Apr 24, 2025
2aee58b
make loading of subset from DB more async to compute flow
dkales Apr 25, 2025
58e2788
sort db indices
dkales Apr 25, 2025
854415f
fix order of loading
dkales Apr 25, 2025
6451123
add caching ondemandloader
dkales Apr 29, 2025
02f68df
explicitly handle failure condition for subset and allow ondemand loa…
dkales Apr 29, 2025
e906a61
fix lints
dkales Apr 29, 2025
b7b9cd5
also dedup the loaded iris codes
dkales Apr 29, 2025
8ecace5
create docker image
danielle-tfh May 4, 2025
a920c11
Update stage
danielle-tfh May 4, 2025
7957dcd
Update stage
danielle-tfh May 4, 2025
390d7ab
Add logs for one sided scan
danielle-tfh May 5, 2025
9fcb09a
Enable LUC
danielle-tfh May 6, 2025
30048f7
Merge branch 'main' into dk/load_half_on_demand
dkales May 13, 2025
de51a74
fix: expect 0-based indices in DB loader
dkales May 13, 2025
74c0979
Update staging to latest commit
danielle-tfh May 15, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/temp-branch-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Branch - Build and push docker image
on:
push:
branches:
- "chore/insert-sns-msg-id-upon-reset-update-msg"
- "dk/load_half_on_demand"

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
Expand Down
17 changes: 16 additions & 1 deletion 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 deploy/stage/common-values-iris-mpc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: "ghcr.io/worldcoin/iris-mpc@sha256:f1b79237c2e5eb7dd3c26977a49d21d09125d6dc7da69213b3d65c7693b82ca7" # v0.15.5
image: "ghcr.io/worldcoin/iris-mpc:de51a749fbf8de65f71caf4b0c79e9e878b6874e" # v0.15.5

environment: stage
replicaCount: 1
Expand Down
13 changes: 8 additions & 5 deletions deploy/stage/smpcv2-0-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ env:
value: "true"

- name: SMPC__INIT_DB_SIZE
value: "1000" # "1200000"
value: "1200000"

- name: SMPC__MAX_DB_SIZE
value: "100000" # "1300000"
value: "1300000"

- name: SMPC__MAX_BATCH_SIZE
value: "64"
Expand All @@ -114,10 +114,10 @@ env:
value: "true"

- name: SMPC__LUC_ENABLED
value: "false"
value: "true"

- name: SMPC__LUC_LOOKBACK_RECORDS
value: "50"
value: "1000"

- name: SMPC__LUC_SERIAL_IDS_FROM_SMPC_REQUEST
value: "true"
Expand Down Expand Up @@ -157,9 +157,12 @@ env:
- name: SMPC__ENABLE_MODIFICATIONS_REPLAY
value: "true"

- name : SMPC__ENABLE_DEBUG_TIMING
- name: SMPC__ENABLE_DEBUG_TIMING
value: "true"

- name: SMPC__LOAD_ONLY_FULL_SCAN_SIDE_IN_MEMORY
value: "false"

initContainer:
enabled: true
image: "amazon/aws-cli:2.17.62"
Expand Down
11 changes: 7 additions & 4 deletions deploy/stage/smpcv2-1-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ env:
value: "true"

- name: SMPC__INIT_DB_SIZE
value: "1000" # "1200000"
value: "1200000"

- name: SMPC__MAX_DB_SIZE
value: "100000" # "1300000"
value: "1300000"

- name: SMPC__MAX_BATCH_SIZE
value: "64"
Expand All @@ -114,10 +114,10 @@ env:
value: "true"

- name: SMPC__LUC_ENABLED
value: "false"
value: "true"

- name: SMPC__LUC_LOOKBACK_RECORDS
value: "50"
value: "1000"

- name: SMPC__LUC_SERIAL_IDS_FROM_SMPC_REQUEST
value: "true"
Expand Down Expand Up @@ -160,6 +160,9 @@ env:
- name : SMPC__ENABLE_DEBUG_TIMING
value: "true"

- name: SMPC__LOAD_ONLY_FULL_SCAN_SIDE_IN_MEMORY
value: "false"

initContainer:
enabled: true
image: "amazon/aws-cli:2.17.62"
Expand Down
11 changes: 7 additions & 4 deletions deploy/stage/smpcv2-2-stage/values-iris-mpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ env:
value: "true"

- name: SMPC__INIT_DB_SIZE
value: "1000" # "1200000"
value: "1200000"

- name: SMPC__MAX_DB_SIZE
value: "100000" # "1300000"
value: "1300000"

- name: SMPC__MAX_BATCH_SIZE
value: "64"
Expand All @@ -114,10 +114,10 @@ env:
value: "true"

- name: SMPC__LUC_ENABLED
value: "false"
value: "true"

- name: SMPC__LUC_LOOKBACK_RECORDS
value: "50"
value: "1000"

- name: SMPC__LUC_SERIAL_IDS_FROM_SMPC_REQUEST
value: "true"
Expand Down Expand Up @@ -160,6 +160,9 @@ env:
- name : SMPC__ENABLE_DEBUG_TIMING
value: "true"

- name: SMPC__LOAD_ONLY_FULL_SCAN_SIDE_IN_MEMORY
value: "false"

initContainer:
enabled: true
image: "amazon/aws-cli:2.17.62"
Expand Down
2 changes: 2 additions & 0 deletions iris-mpc-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ aws-sdk-sns = { workspace = true, optional = true }
aws-sdk-sqs = { workspace = true, optional = true }
aws-sdk-s3 = { workspace = true, optional = true }
aws-sdk-secretsmanager = { workspace = true, optional = true }
async-trait.workspace = true
dotenvy.workspace = true
clap.workspace = true
rand.workspace = true
Expand Down Expand Up @@ -63,6 +64,7 @@ ring = "0.17.8"
data-encoding = "2.6.0"
bincode.workspace = true
serde-big-array.workspace = true
quick_cache = "0.6.13"
metrics = "0.22.1"
metrics-exporter-statsd = "0.7"

Expand Down
5 changes: 4 additions & 1 deletion iris-mpc-common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ pub struct Config {
#[serde(default = "default_full_scan_side")]
pub full_scan_side: Eye,

#[serde(default)]
pub load_only_full_scan_side_in_memory: bool,
// used to fix max batch size to 1 for correctness testing purposes
#[serde(default = "default_override_max_batch_size")]
pub override_max_batch_size: bool,
Expand Down Expand Up @@ -629,7 +631,8 @@ impl From<Config> for CommonConfig {
cpu_disable_persistence,
hawk_server_resets_enabled,
full_scan_side,
override_max_batch_size: _, // for testing purposes only
load_only_full_scan_side_in_memory: _, // could be different for each server
override_max_batch_size: _, // for testing purposes only
} = value;

Self {
Expand Down
1 change: 1 addition & 0 deletions iris-mpc-common/src/galois_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ pub mod degree4 {
})
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FullGaloisRingIrisCodeShare {
pub code: GaloisRingIrisCodeShare,
pub mask: GaloisRingTrimmedMaskCodeShare,
Expand Down
88 changes: 87 additions & 1 deletion iris-mpc-common/src/helpers/inmemory_store.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::vector_id::VectorId;
use std::sync::Arc;

use crate::{job::Eye, vector_id::VectorId};

/// A helper trait encapsulating the functionality to add iris codes to some
/// form of in-memory store.
Expand Down Expand Up @@ -117,3 +119,87 @@ pub trait InMemoryStore {
/// unpredictable.
fn fake_db(&mut self, size: usize);
}

/// A helper trait encapsulating the functionality to load iris codes on demand from some source (DB, File-backed, etc.).
#[async_trait::async_trait]
pub trait OnDemandLoader {
/// Loads records from the source.
/// The returned Vec has the form:
/// `(index, side_code, side_mask)`.
#[allow(clippy::type_complexity)]
async fn load_records(
&self,
side: Eye,
indices: &[usize],
) -> eyre::Result<Vec<(usize, Vec<u16>, Vec<u16>)>>;
}

pub struct CachingOnDemandLoader {
inner: Arc<dyn OnDemandLoader + Send + Sync + 'static>,
cache: quick_cache::sync::Cache<usize, (Vec<u16>, Vec<u16>)>,
fixed_side: Eye,
}

impl CachingOnDemandLoader {
pub fn new(
inner: Arc<dyn OnDemandLoader + Send + Sync + 'static>,
num_cached_iris_codes: usize,
fixed_side: Eye,
) -> Self {
let cache = quick_cache::sync::Cache::new(num_cached_iris_codes);
Self {
inner,
cache,
fixed_side,
}
}
}

#[async_trait::async_trait]
impl OnDemandLoader for CachingOnDemandLoader {
async fn load_records(
&self,
side: Eye,
indices: &[usize],
) -> eyre::Result<Vec<(usize, Vec<u16>, Vec<u16>)>> {
if side != self.fixed_side {
return Err(eyre::eyre!(
"Invalid side requested, expected: {:?}",
self.fixed_side
));
}

// grab cached iris codes
let cached: Vec<_> = indices.iter().map(|x| (*x, self.cache.get(x))).collect();
// grab missing ones
let missing_indices = cached
.iter()
.filter_map(|(i, c)| if c.is_none() { Some(*i) } else { None })
.collect::<Vec<_>>();

// for missing ones, load from the inner source
let loaded = if missing_indices.is_empty() {
vec![]
} else {
self.inner.load_records(side, &missing_indices).await?
};

// put collected iris codes into the cache
for (idx, code, mask) in loaded.iter() {
self.cache.insert(*idx, (code.clone(), mask.clone()));
}
let result = cached
.into_iter()
.filter_map(|x| {
if let Some((code, mask)) = x.1 {
Some((x.0, code, mask))
} else {
None
}
})
.chain(loaded.into_iter())
.collect::<Vec<_>>();

Ok(result)
}
}
Loading
Loading