Skip to content

Commit

Permalink
Release v0.2.0
Browse files Browse the repository at this point in the history
GitOrigin-RevId: eb73a08756cf3c4ffcfabd079af92ad0b60304e2
  • Loading branch information
Privacy Sandbox Team authored and andrewkvuong committed Jun 17, 2024
1 parent d79223f commit 015930f
Show file tree
Hide file tree
Showing 204 changed files with 6,845 additions and 2,868 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
.idea/
**/*.iml

# python venv
# python
__pycache__/
venv/

# code coverage output
genhtml/

# python cache
**/__pycache__/**
13 changes: 7 additions & 6 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ Images can be built using the provided script

The expected output for images built within the provided [Dockerfile](Dockerfile):
```
bazel-bin/shuffler/services/aggregator/aggregator_image/index.json: "digest": "sha256:375a7525eb34a9cff17c0f21f572485a4f19318ede5dc85dd15fa8390800f203"
bazel-bin/shuffler/services/collector/collector_image/index.json: "digest": "sha256:aa51fa96b69612eda957d2931cd04a570cf6deb9dbdff0cf87ee673b43bc6cbe"
bazel-bin/shuffler/services/modelupdater/model_updater_image/index.json: "digest": "sha256:0c57e62a78cc112ecfa91fbb2eb6a16a484264cb65d2add500bcccbabae8e51c"
bazel-bin/shuffler/services/taskassignment/task_assignment_image/index.json: "digest": "sha256:bcc328634272c591a5a58f3a8406d8849ecb393fe8cf0cb62091338a99e3d772"
bazel-bin/shuffler/services/taskmanagement/task_management_image/index.json: "digest": "sha256:001060ec8a7fe40f761aa125474389021cd8404930739c8f8340240bfd21c221"
bazel-bin/shuffler/services/taskscheduler/task_scheduler_image/index.json: "digest": "sha256:3a8a7bd66646aac0e55fbc510291f32a1e4b9b03f3e64ea72fb9ceace985750e"
bazel-bin/shuffler/services/aggregator/aggregator_image/index.json: "digest": "sha256:c04b35b41fc2990e47f4c6c1e575f4dc06eadfef5add6498959977b012c008d4"
bazel-bin/shuffler/services/collector/collector_image/index.json: "digest": "sha256:4f6bef12c33bac516448d44e423ffc9a7a6d273fe9c2de327c45ec0bad74295a"
bazel-bin/shuffler/services/modelupdater/model_updater_image/index.json: "digest": "sha256:05f73cbec7dea193ae81e51c99a3c02de6cd0e62c27e267b9a43e31e6c8d530a"
bazel-bin/shuffler/services/taskassignment/task_assignment_image/index.json: "digest": "sha256:80439bfca81d86d69010540c26bb5e7371f7fe98d5538a1ac0813f6f8c69f35a"
bazel-bin/shuffler/services/taskbuilder/task_builder_image/index.json: "digest": "sha256:3959610c3a6896e0f77358d94a85900b088290951f0cad53557c6298a4d86bf2"
bazel-bin/shuffler/services/taskmanagement/task_management_image/index.json: "digest": "sha256:4f9239def6a6ee004aec5a55dbed47b255e83705250d749923d96b6d1e27b2b0"
bazel-bin/shuffler/services/taskscheduler/task_scheduler_image/index.json: "digest": "sha256:a15ef0b318a133c7e5d6112ae458fca0f344e2646bb2094323d6d27a8c721049"
```

## Publishing
Expand Down
62 changes: 52 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ maven_install(
"com.google.crypto.tink:tink:1.12.0",
"com.google.inject:guice:7.0.0",
"org.slf4j:slf4j-api:2.0.7",
"com.google.cloud:google-cloud-logging-logback:0.131.8-alpha",
# spring
"org.springframework.boot:spring-boot-autoconfigure:3.1.1",
"org.springframework.boot:spring-boot-starter-actuator:3.1.1",
Expand Down Expand Up @@ -145,10 +146,10 @@ http_archive(
http_archive(
name = "coordinator-services-and-shared-libraries",
build_file = "coordinator.BUILD",
sha256 = "90e147c05801bbcd9b25491bea0239c17404f61cdff236edc3da6a522b59ecd0",
strip_prefix = "coordinator-services-and-shared-libraries-1.5.0",
sha256 = "7879ff1c7bf0f96a6214725fe87bf39ef5297db4aab8d39d7b6fef49c2643c55",
strip_prefix = "coordinator-services-and-shared-libraries-1.7.0",
urls = [
"https://github.com/privacysandbox/coordinator-services-and-shared-libraries/archive/refs/tags/v1.5.0.tar.gz",
"https://github.com/privacysandbox/coordinator-services-and-shared-libraries/archive/refs/tags/v1.7.0.tar.gz",
],
)

Expand All @@ -169,6 +170,29 @@ http_archive(
url = "https://github.com/project-oak/oak/archive/0acf3f6dc0af2035d40884fe1258b1e0e7db5488.tar.gz",
)

# The following enables the use of the library functions in the differential-
# privacy github repo
http_archive(
name = "com_google_cc_differential_privacy",
sha256 = "6e6e1cd7a819695caae408f4fa938129ab7a86e83fe2410137c85e50131abbe0",
strip_prefix = "differential-privacy-3.0.0/cc",
url = "https://github.com/google/differential-privacy/archive/refs/tags/v3.0.0.tar.gz",
)

http_archive(
name = "com_google_differential_privacy",
sha256 = "6e6e1cd7a819695caae408f4fa938129ab7a86e83fe2410137c85e50131abbe0",
strip_prefix = "differential-privacy-3.0.0",
url = "https://github.com/google/differential-privacy/archive/refs/tags/v3.0.0.tar.gz",
)

http_archive(
name = "org_tensorflow_federated",
sha256 = "2bb1e641a84f05bc1776eefc98eb108454807071ae0bed45ee5e8bee896511be",
strip_prefix = "tensorflow-federated-9c5a51af41fccc8e720a63aa754465767113877d",
url = "https://github.com/tensorflow/federated/archive/9c5a51af41fccc8e720a63aa754465767113877d.tar.gz",
)

# Tensorflow v2.14.0
http_archive(
name = "org_tensorflow",
Expand Down Expand Up @@ -208,12 +232,10 @@ http_archive(
url = "https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python",
ignore_root_user_error = True,
Expand Down Expand Up @@ -243,20 +265,20 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_

rules_proto_toolchains()

load("@federatedcompute//fcp/tensorflow/pip_tf:defs.bzl", "TF_ADDITIVE_BUILD_CONTENT")
load("@python//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "package_annotation", "pip_parse")
load("@federatedcompute//fcp/tensorflow/pip_tf:defs.bzl", "TF_ADDITIVE_BUILD_CONTENT")

http_archive(
name = "differential_privacy",
repo_mapping = {
"@accounting_py_pip_deps": "@pypi",
},
sha256 = "6e6e1cd7a819695caae408f4fa938129ab7a86e83fe2410137c85e50131abbe0",
strip_prefix = "differential-privacy-3.0.0/python/dp_accounting/",
urls = [
"https://github.com/google/differential-privacy/archive/refs/tags/v3.0.0.tar.gz",
],
repo_mapping = {
"@accounting_py_pip_deps": "@pypi"
},
)

pip_parse(
Expand Down Expand Up @@ -458,3 +480,23 @@ llvm_toolchain(
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()


################
# pybind11
################

http_archive(
name = "pybind11_bazel",
strip_prefix = "pybind11_bazel-2.12.0",
sha256 = "a58c25c5fe063a70057fa20cb8e15f3bda19b1030305bcb533af1e45f36a4a55",
urls = ["https://github.com/pybind/pybind11_bazel/archive/pybind11_bazel-2.12.0.zip"],
)
# We still require the pybind library.
http_archive(
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11-BUILD.bazel",
strip_prefix = "pybind11-2.12.0",
sha256 = "411f77380c43798506b39ec594fc7f2b532a13c4db674fcf2b1ca344efaefb68",
urls = ["https://github.com/pybind/pybind11/archive/pybind11-2.12.0.zip"],
)
2 changes: 1 addition & 1 deletion federatedcompute
Submodule federatedcompute updated 68 files
+13 −2 .bazelrc
+9 −0 WORKSPACE
+14 −0 fcp/BUILD
+1 −1 fcp/aggregation/core/BUILD
+65 −54 fcp/aggregation/core/dp_group_by_aggregator.cc
+38 −0 fcp/aggregation/core/dp_group_by_aggregator.h
+58 −12 fcp/aggregation/core/dp_group_by_aggregator_test.cc
+2 −5 fcp/aggregation/core/tensor_aggregator.h
+1 −4 fcp/aggregation/core/tensor_aggregator_factory.h
+3 −0 fcp/aggregation/core/tensor_aggregator_registry_test.cc
+8 −0 fcp/aggregation/protocol/BUILD
+10 −0 fcp/aggregation/protocol/checkpoint_aggregator_test.cc
+2 −0 fcp/aggregation/protocol/config_converter_test.cc
+14 −0 fcp/aggregation/protocol/simple_aggregation/simple_aggregation_protocol_test.cc
+1 −1 fcp/aggregation/tensorflow/BUILD
+1 −1 fcp/artifact_building/federated_compute_plan_builder.py
+6 −0 fcp/artifact_building/plan_utils.py
+5 −5 fcp/client/BUILD
+108 −0 fcp/client/attestation/BUILD
+13 −4 fcp/client/attestation/README.md
+186 −0 fcp/client/attestation/extract_attestation_records.cc
+49 −0 fcp/client/attestation/extract_attestation_records.h
+121 −0 fcp/client/attestation/extract_attestation_records_main.cc
+392 −0 fcp/client/attestation/extract_attestation_records_test.cc
+130 −0 fcp/client/attestation/log_attestation_records.cc
+54 −0 fcp/client/attestation/log_attestation_records.h
+101 −0 fcp/client/attestation/log_attestation_records_test.cc
+5 −79 fcp/client/attestation/oak_rust_attestation_verifier.cc
+4 −32 fcp/client/attestation/oak_rust_attestation_verifier.h
+10 −194 fcp/client/attestation/oak_rust_attestation_verifier_test.cc
+146 −0 fcp/client/attestation/test_values.cc
+42 −0 fcp/client/attestation/test_values.h
+9 −8 fcp/client/converters.cc
+12 −10 fcp/client/converters.h
+14 −11 fcp/client/converters_test.cc
+8 −8 fcp/client/engine/BUILD
+12 −12 fcp/client/engine/example_query_plan_engine.cc
+2 −2 fcp/client/engine/example_query_plan_engine.h
+18 −15 fcp/client/engine/example_query_plan_engine_test.cc
+1 −2 fcp/client/federated_protocol.h
+0 −7 fcp/client/fl_runner.cc
+0 −4 fcp/client/flags.h
+4 −4 fcp/client/rust/oak_attestation_verification_ffi.cc
+4 −4 fcp/client/rust/oak_attestation_verification_ffi.h
+0 −1 fcp/client/test_helpers.h
+2 −1 fcp/demo/README.md
+46 −0 fcp/java_src/main/java/com/google/fcp/aggregation/AggregationException.java
+248 −0 fcp/java_src/main/java/com/google/fcp/aggregation/AggregationSession.java
+43 −0 fcp/java_src/main/java/com/google/fcp/aggregation/BUILD
+51 −0 fcp/java_src/main/java/com/google/fcp/aggregation/jni/BUILD
+232 −0 fcp/java_src/main/java/com/google/fcp/aggregation/jni/aggregation_jni.cc
+20 −1 fcp/java_src/main/java/com/google/fcp/plan/BUILD
+65 −0 fcp/java_src/main/java/com/google/fcp/plan/PhaseSessionV2.java
+316 −0 fcp/java_src/main/java/com/google/fcp/plan/TensorflowPhaseSessionV2.java
+8 −2 fcp/java_src/main/java/com/google/fcp/tensorflow/BUILD
+154 −0 fcp/java_src/test/java/com/google/fcp/aggregation/AggregationSessionTest.java
+36 −0 fcp/java_src/test/java/com/google/fcp/aggregation/BUILD
+3 −0 fcp/java_src/test/java/com/google/fcp/testdata/BUILD
+ fcp/java_src/test/java/com/google/fcp/testdata/keras_checkpoint_v2.ckp
+ fcp/java_src/test/java/com/google/fcp/testdata/keras_gradient_v2.ckp
+ fcp/java_src/test/java/com/google/fcp/testdata/keras_plan_v2.pb
+41 −0 fcp/jni/jni_util.h
+0 −23 fcp/jni/more_jni_util.h
+10 −0 fcp/protos/confidentialcompute/access_policy.proto
+45 −0 fcp/protos/confidentialcompute/ledger.proto
+4 −0 fcp/protos/federatedcompute/common.proto
+4 −0 fcp/protos/plan.proto
+23 −0 third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ java_binary(
":end_to_end_args",
"//java/src/it/java/com/google/ondevicepersonalization/federatedcompute/endtoendtests/clients:device",
"//java/src/it/java/com/google/ondevicepersonalization/federatedcompute/endtoendtests/clients:partner",
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/common:compression_utils",
"//shuffler/proto:task_java_proto",
"@maven//:com_beust_jcommander",
"@maven//:com_google_guava_guava",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.ondevicepersonalization.federatedcompute.endtoendtests;

import com.beust.jcommander.Parameter;
Expand Down Expand Up @@ -54,6 +70,23 @@ public class EndToEndArgs {
@Parameter(names = "--population_name", description = "Population name to use for the task")
private String populationName;

@Parameter(
names = "--eval_training_population_name",
description = "Training population name to use by the eval task")
private String evalTrainingPopulationName;

@Parameter(
names = "--eval_training_task_id",
description = "Training task id used by the eval task",
validateWith = PositiveInteger.class)
private int evalTrainingTaskId = 1;

@Parameter(
names = "--eval_evey_k_iteration",
description = "K value for EveryKIteration selector",
validateWith = PositiveInteger.class)
private int evalEveryKIteration = 1;

@Parameter(
names = "--min_client_version",
description = "Minimum client version to use for the task")
Expand Down Expand Up @@ -118,6 +151,7 @@ enum Operation {
CREATE_AND_COMPLETE_TRAINING_TASK,
CREATE_AND_COMPLETE_EVALUATION_TASK,
CREATE_TASK,
CREATE_EVALUATION_TASK,
RUN_TASK,
GET_TASK
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.ondevicepersonalization.federatedcompute.proto.TaskInfo;
import com.google.ondevicepersonalization.federatedcompute.proto.TaskStatus;
import com.google.ondevicepersonalization.federatedcompute.proto.TrainingInfo;
import com.google.ondevicepersonalization.federatedcompute.shuffler.common.CompressionUtils;
import java.time.InstantSource;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -127,26 +128,43 @@ public static void main(String[] args) {
endToEndTest.completeTask(endToEndTest.createTrainingTask());
break;
case CREATE_AND_COMPLETE_EVALUATION_TASK:
// create training and evaluation task
Task trainingTask = endToEndTest.createTrainingTask();
EvaluationInfo evaluationInfo =
EvaluationInfo.newBuilder()
.setTrainingPopulationName(trainingTask.getPopulationName())
.setTrainingTaskId(trainingTask.getTaskId())
.setCheckPointSelector(
CheckPointSelector.newBuilder()
.setIterationSelector(
EveryKIterationsCheckpointSelector.newBuilder().setSize(1)))
.build();
// create an evaluation task under same population with training task
Task evaluationTask =
endToEndTest.createEvaluationTask(trainingTask.getPopulationName(), evaluationInfo);
endToEndTest.completeTasksInSamePopulation(
ImmutableList.of(trainingTask, evaluationTask));
break;
{
// create training and evaluation task
Task trainingTask = endToEndTest.createTrainingTask();
EvaluationInfo evaluationInfo =
EvaluationInfo.newBuilder()
.setTrainingPopulationName(trainingTask.getPopulationName())
.setTrainingTaskId(trainingTask.getTaskId())
.setCheckPointSelector(
CheckPointSelector.newBuilder()
.setIterationSelector(
EveryKIterationsCheckpointSelector.newBuilder().setSize(1)))
.build();
// create an evaluation task under same population with training task
Task evaluationTask =
endToEndTest.createEvaluationTask(trainingTask.getPopulationName(), evaluationInfo);
endToEndTest.completeTasksInSamePopulation(
ImmutableList.of(trainingTask, evaluationTask));
break;
}
case CREATE_TASK:
endToEndTest.createTrainingTask();
break;
case CREATE_EVALUATION_TASK:
{
EvaluationInfo evaluationInfo =
EvaluationInfo.newBuilder()
.setTrainingPopulationName(endToEndArgs.getEvalTrainingPopulationName())
.setTrainingTaskId(endToEndArgs.getEvalTrainingTaskId())
.setCheckPointSelector(
CheckPointSelector.newBuilder()
.setIterationSelector(
EveryKIterationsCheckpointSelector.newBuilder()
.setSize(endToEndArgs.getEvalEveryKIteration())))
.build();
endToEndTest.createEvaluationTask(endToEndArgs.getPopulationName(), evaluationInfo);
break;
}
case RUN_TASK:
endToEndTest.runTask(endToEndArgs.getRunCount());
break;
Expand Down Expand Up @@ -184,6 +202,13 @@ private static void validateInput(EndToEndArgs args) {
Objects.requireNonNull(args.getInitCheckpoint());
}
break;
case CREATE_EVALUATION_TASK:
if (!args.isUseLocalResources()) {
Objects.requireNonNull(args.getClientPlan());
Objects.requireNonNull(args.getServerPlan());
}
Objects.requireNonNull(args.getEvalTrainingPopulationName());
break;
case RUN_TASK:
if (args.isEncrypt()) {
Objects.requireNonNull(args.getPublicKeyUrl());
Expand Down Expand Up @@ -441,6 +466,6 @@ private void processTaskAssignment() throws Exception {
if (encrypt) {
downloadedGradient = device.encryptAndCompressGradient(downloadedGradient, publicKeyUrl);
}
device.submitResult(downloadedGradient);
device.submitResult(CompressionUtils.compressWithGzip(downloadedGradient));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Creates a task
bazel run //java/src/it/java/com/google/ondevicepersonalization/federatedcompute/endtoendtests:end_to_end_test -- --task_management_server <tm_server_url> --operation CREATE_TASK
```

### CREATE_EVALUATION_TASK
Creates a task
```
bazel run //java/src/it/java/com/google/ondevicepersonalization/federatedcompute/endtoendtests:end_to_end_test -- --task_management_server <tm_server_url> --operation CREATE_EVALUATION_TASK --eval_training_population_name <training_population_name> --eval_training_task_id <training_task_id>
```

### RUN_TASK
Runs `run_count` contributions against a given task.
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public void submitResult(byte[] gradients) throws Exception {
}

String assignmentUri = taskAssignment.getSelfUri();
System.out.println("submitResult: " + assignmentUri);
upload(assignmentUri, content);
}

Expand Down Expand Up @@ -201,6 +202,7 @@ private void upload(String url, byte[] content) throws Exception {
.PUT(HttpRequest.BodyPublishers.ofByteArray(content))
.timeout(Duration.ofSeconds(10))
.header("Content-Type", "application/octet-stream")
.header("content-encoding", "gzip")
.build();

HttpResponse<byte[]> response = client.send(request, BodyHandlers.ofByteArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ springboot(
java_library(
name = "aggregator",
srcs = ["AggregatorApplication.java"],
resources = ["//java/src/main/resources:aggregator_properties"],
resources = ["//java/src/main/resources:aggregator_properties", "//java/src/main/resources:logback_spring"],
deps = [
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/aggregator/controllers:aggregator_controller",
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/aggregator/core:aggregator_core_impl",
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/aggregator/core/gcp:aggregator_config",
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/aggregator/core/gcp:pub_sub_message_receiver",
Expand All @@ -39,6 +40,7 @@ java_library(
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/common/dao/gcp:gcs_blob_dao",
"//java/src/main/java/com/google/ondevicepersonalization/federatedcompute/shuffler/common/messaging/gcp:pub_sub_subscriber_config",
"@maven//:io_micrometer_micrometer_registry_prometheus",
"@maven//:com_google_cloud_google_cloud_logging_logback",
"@maven//:org_springframework_boot_spring_boot",
"@maven//:org_springframework_boot_spring_boot_autoconfigure",
"@maven//:org_springframework_boot_spring_boot_loader",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

package com.google.ondevicepersonalization.federatedcompute.shuffler.aggregator.controllers;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/** Aggregator controller. */
@RestController
public final class AggregatorController {
@GetMapping("/ready")
public String ready() {
// TODO(291594777): Implement readiness check.
return "Greetings from Aggregator Spring Boot! Ready check. \n";
}

@GetMapping("/healthz")
public String healthz() {
// TODO(291594777): Implement health check.
return "Greetings from Aggregator Spring Boot! Health check. \n";
}
}
Loading

0 comments on commit 015930f

Please sign in to comment.