Skip to content

Commit f3e2ae0

Browse files
authored
Feat: even odd import from s3 (#897)
* import bytes in even-odd orders from s3 * trigger image push * deploy to stage * fix code len assert * remove leftover change on loading from db * change even/odd order * bring back iris-mpc-py to workspace * remove unused method * simplify size * move invalid id check to pre-load * bump stage version
1 parent 8568198 commit f3e2ae0

File tree

10 files changed

+297
-117
lines changed

10 files changed

+297
-117
lines changed

.github/workflows/temp-branch-build-and-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Branch - Build and push docker image
33
on:
44
push:
55
branches:
6-
- "ps/potential-phantom-match"
6+
- "feat/even-odd-import-from-s3"
77

88
concurrency:
99
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'

deploy/stage/common-values-iris-mpc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: "ghcr.io/worldcoin/iris-mpc:v0.13.10"
1+
image: "ghcr.io/worldcoin/iris-mpc:v0.13.11"
22

33
environment: stage
44
replicaCount: 1

deploy/stage/smpcv2-0-stage/values-iris-mpc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ env:
7575
value: "iris-mpc-db-exporter-store-node-0-stage-eu-north-1"
7676

7777
- name: SMPC__DB_CHUNKS_FOLDER_NAME
78-
value: "binary_output_16k"
78+
value: "even_odd_binary_output_16k"
7979

8080
- name: SMPC__LOAD_CHUNKS_PARALLELISM
8181
value: "32"

deploy/stage/smpcv2-1-stage/values-iris-mpc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ env:
7575
value: "iris-mpc-db-exporter-store-node-1-stage-eu-north-1"
7676

7777
- name: SMPC__DB_CHUNKS_FOLDER_NAME
78-
value: "binary_output_16k"
78+
value: "even_odd_binary_output_16k"
7979

8080
- name: SMPC__LOAD_CHUNKS_PARALLELISM
8181
value: "32"

deploy/stage/smpcv2-2-stage/values-iris-mpc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ env:
7575
value: "iris-mpc-db-exporter-store-node-2-stage-eu-north-1"
7676

7777
- name: SMPC__DB_CHUNKS_FOLDER_NAME
78-
value: "binary_output_16k"
78+
value: "even_odd_binary_output_16k"
7979

8080
- name: SMPC__LOAD_CHUNKS_PARALLELISM
8181
value: "32"

iris-mpc-gpu/src/dot/share_db.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl ShareDB {
302302
}
303303
}
304304

305-
pub fn load_single_record(
305+
pub fn load_single_record_from_db(
306306
index: usize,
307307
db: &CudaVec2DSlicerRawPointer,
308308
record: &[u16],
@@ -339,6 +339,35 @@ impl ShareDB {
339339
};
340340
}
341341

342+
pub fn load_single_record_from_s3(
343+
index: usize,
344+
db: &CudaVec2DSlicerRawPointer,
345+
a0_host: &[u8],
346+
a1_host: &[u8],
347+
n_shards: usize,
348+
code_length: usize,
349+
) {
350+
assert_eq!(a0_host.len(), code_length);
351+
assert_eq!(a1_host.len(), code_length);
352+
353+
let device_index = index % n_shards;
354+
let device_db_index = index / n_shards;
355+
356+
unsafe {
357+
std::ptr::copy(
358+
a0_host.as_ptr() as *const _,
359+
(db.limb_0[device_index] + (device_db_index * code_length) as u64) as *mut _,
360+
code_length,
361+
);
362+
363+
std::ptr::copy(
364+
a1_host.as_ptr() as *const _,
365+
(db.limb_1[device_index] + (device_db_index * code_length) as u64) as *mut _,
366+
code_length,
367+
);
368+
};
369+
}
370+
342371
pub fn preprocess_db(&self, db: &mut SlicedProcessedDatabase, db_lens: &[usize]) {
343372
let code_len = self.code_length;
344373
for device_index in 0..self.device_manager.device_count() {
@@ -381,7 +410,7 @@ impl ShareDB {
381410
.par_chunks(self.code_length)
382411
.enumerate()
383412
.for_each(|(idx, chunk)| {
384-
Self::load_single_record(idx, &db.code_gr, chunk, n_shards, code_length);
413+
Self::load_single_record_from_db(idx, &db.code_gr, chunk, n_shards, code_length);
385414
});
386415

387416
// Calculate the number of entries per shard

iris-mpc-gpu/src/server/actor.rs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,36 +461,36 @@ impl ServerActor {
461461
self.current_db_sizes = db_lens1;
462462
}
463463

464-
pub fn load_single_record(
464+
pub fn load_single_record_from_db(
465465
&mut self,
466466
index: usize,
467467
left_code: &[u16],
468468
left_mask: &[u16],
469469
right_code: &[u16],
470470
right_mask: &[u16],
471471
) {
472-
ShareDB::load_single_record(
472+
ShareDB::load_single_record_from_db(
473473
index,
474474
&self.left_code_db_slices.code_gr,
475475
left_code,
476476
self.device_manager.device_count(),
477477
IRIS_CODE_LENGTH,
478478
);
479-
ShareDB::load_single_record(
479+
ShareDB::load_single_record_from_db(
480480
index,
481481
&self.left_mask_db_slices.code_gr,
482482
left_mask,
483483
self.device_manager.device_count(),
484484
MASK_CODE_LENGTH,
485485
);
486-
ShareDB::load_single_record(
486+
ShareDB::load_single_record_from_db(
487487
index,
488488
&self.right_code_db_slices.code_gr,
489489
right_code,
490490
self.device_manager.device_count(),
491491
IRIS_CODE_LENGTH,
492492
);
493-
ShareDB::load_single_record(
493+
ShareDB::load_single_record_from_db(
494494
index,
495495
&self.right_mask_db_slices.code_gr,
496496
right_mask,
@@ -499,6 +499,53 @@ impl ServerActor {
499499
);
500500
}
501501

502+
#[allow(clippy::too_many_arguments)]
503+
pub fn load_single_record_from_s3(
504+
&mut self,
505+
index: usize,
506+
left_code_odd: &[u8],
507+
left_code_even: &[u8],
508+
right_code_odd: &[u8],
509+
right_code_even: &[u8],
510+
left_mask_odd: &[u8],
511+
left_mask_even: &[u8],
512+
right_mask_odd: &[u8],
513+
right_mask_even: &[u8],
514+
) {
515+
ShareDB::load_single_record_from_s3(
516+
index,
517+
&self.left_code_db_slices.code_gr,
518+
left_code_odd,
519+
left_code_even,
520+
self.device_manager.device_count(),
521+
IRIS_CODE_LENGTH,
522+
);
523+
ShareDB::load_single_record_from_s3(
524+
index,
525+
&self.left_mask_db_slices.code_gr,
526+
left_mask_odd,
527+
left_mask_even,
528+
self.device_manager.device_count(),
529+
MASK_CODE_LENGTH,
530+
);
531+
ShareDB::load_single_record_from_s3(
532+
index,
533+
&self.right_code_db_slices.code_gr,
534+
right_code_odd,
535+
right_code_even,
536+
self.device_manager.device_count(),
537+
IRIS_CODE_LENGTH,
538+
);
539+
ShareDB::load_single_record_from_s3(
540+
index,
541+
&self.right_mask_db_slices.code_gr,
542+
right_mask_odd,
543+
right_mask_even,
544+
self.device_manager.device_count(),
545+
MASK_CODE_LENGTH,
546+
);
547+
}
548+
502549
pub fn increment_db_size(&mut self, index: usize) {
503550
self.current_db_sizes[index % self.device_manager.device_count()] += 1;
504551
}

0 commit comments

Comments
 (0)