Skip to content

Commit

Permalink
Update FCP and TFF dependencies.
Browse files Browse the repository at this point in the history
This includes the migration of the core TFF language to
https://github.com/google-parfait/federated-language.

Bug: 382151086
Change-Id: I6a24c63303358087fa62ff5bb23a641e0b63a9b1
  • Loading branch information
bmclarnon committed Dec 4, 2024
1 parent bdf8dfb commit aeb1d16
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 62 deletions.
27 changes: 21 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,24 @@ http_archive(
# Patch to make TFF compatible with TF 2.18.
"//third_party/org_tensorflow_federated:tensorflow_2_18.patch",
],
sha256 = "391dea2c6f3ec1279d802d36703c1cec690c4a1642cc8cd19a078f440b3e7fa8",
strip_prefix = "tensorflow-federated-03b32cfbd38b58bb9c09f2649632c3376cb95163",
url = "https://github.com/google-parfait/tensorflow-federated/archive/03b32cfbd38b58bb9c09f2649632c3376cb95163.tar.gz",
sha256 = "bc5297068936a1c04a5e5a90373007cf69e041e8fb69d544096b8ac4c5436cd9",
strip_prefix = "tensorflow-federated-3782a88fc4651b59ecff95ca600fd83972547875",
url = "https://github.com/google-parfait/tensorflow-federated/archive/3782a88fc4651b59ecff95ca600fd83972547875.tar.gz",
)

http_archive(
name = "federated_language",
patches = [
"@org_tensorflow_federated//third_party/federated_language:proto_library_loads.patch",
"@org_tensorflow_federated//third_party/federated_language:python_deps.patch",
"@org_tensorflow_federated//third_party/federated_language:structure_visibility.patch",
],
repo_mapping = {
"@protobuf": "@com_google_protobuf",
},
sha256 = "07fad8cb743caac8f9afeebf06ef767471713f23a15b2e6713fcc0a17967747b",
strip_prefix = "federated-language-2ec477bcd8ecfa7e5422b806450f101d1eed7ecb",
url = "https://github.com/google-parfait/federated-language/archive/2ec477bcd8ecfa7e5422b806450f101d1eed7ecb.tar.gz",
)

# Use a newer version of BoringSSL than what TF gives us, so we can use
Expand Down Expand Up @@ -192,9 +207,9 @@ http_archive(
"//third_party/federated_compute:libcppbor.patch",
"//third_party/federated_compute:visibility.patch",
],
sha256 = "cf811d94df68ccf39123a6782fb237c0eb896bdd679516509d4fb701f577b6fa",
strip_prefix = "federated-compute-57bec0884b2c8a231b10c274e93aadb57a5cde1c",
url = "https://github.com/google/federated-compute/archive/57bec0884b2c8a231b10c274e93aadb57a5cde1c.tar.gz",
sha256 = "801b08bbc5cb19fc24ba81028dc847a41d9eb5bd51218e4a3dd18edce68a7a6e",
strip_prefix = "federated-compute-33a0495a0c4462001a8ca67eac8e65c2e414478a",
url = "https://github.com/google/federated-compute/archive/33a0495a0c4462001a8ca67eac8e65c2e414478a.tar.gz",
)

http_archive(
Expand Down
1 change: 1 addition & 0 deletions containers/tff_server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cc_library(
"@federated-compute//fcp/protos/confidentialcompute:confidential_transform_cc_grpc",
"@federated-compute//fcp/protos/confidentialcompute:confidential_transform_cc_proto",
"@federated-compute//fcp/protos/confidentialcompute:tff_config_cc_proto",
"@federated_language//federated_language/proto:computation_cc_proto",
"@lingvo//lingvo/core/ops:assert_kernels",
"@oak//proto/containers:orchestrator_crypto_cc_grpc",
"@org_tensorflow//tensorflow/compiler/jit:xla_cpu_jit",
Expand Down
4 changes: 2 additions & 2 deletions containers/tff_server/confidential_transform_server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "fcp/protos/confidentialcompute/confidential_transform.pb.h"
#include "fcp/protos/confidentialcompute/file_info.pb.h"
#include "fcp/protos/confidentialcompute/tff_config.pb.h"
#include "federated_language/proto/computation.pb.h"
#include "gmock/gmock.h"
#include "google/protobuf/repeated_ptr_field.h"
#include "grpcpp/channel.h"
Expand All @@ -56,7 +57,6 @@
#include "tensorflow_federated/cc/core/impl/executors/reference_resolving_executor.h"
#include "tensorflow_federated/cc/core/impl/executors/tensor_serialization.h"
#include "tensorflow_federated/cc/core/impl/executors/tensorflow_executor.h"
#include "tensorflow_federated/proto/v0/computation.pb.h"
#include "testing/parse_text_proto.h"

namespace confidential_federated_compute::tff_server {
Expand Down Expand Up @@ -112,7 +112,7 @@ absl::StatusOr<Value> LoadFileAsTffValue(absl::string_view path) {
}
std::stringstream file_stream;
file_stream << file_istream.rdbuf();
tensorflow_federated::v0::Computation computation;
federated_language::Computation computation;
if (!google::protobuf::TextFormat::ParseFromString(
std::move(file_stream.str()), &computation)) {
return absl::InvalidArgumentError(
Expand Down
2 changes: 2 additions & 0 deletions containers/tff_worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cc_library(
"@federated-compute//fcp/protos/confidentialcompute:pipeline_transform_cc_grpc",
"@federated-compute//fcp/protos/confidentialcompute:pipeline_transform_cc_proto",
"@federated-compute//fcp/protos/confidentialcompute:tff_worker_configuration_cc_proto",
"@federated_language//federated_language/proto:computation_cc_proto",
"@org_tensorflow//tensorflow/core:tensorflow",
"@org_tensorflow_federated//tensorflow_federated/cc/core/impl/aggregation/protocol:federated_compute_checkpoint_parser",
"@org_tensorflow_federated//tensorflow_federated/cc/core/impl/aggregation/tensorflow:converters",
Expand Down Expand Up @@ -64,6 +65,7 @@ cc_test(
"@federated-compute//fcp/protos/confidentialcompute:pipeline_transform_cc_grpc",
"@federated-compute//fcp/protos/confidentialcompute:pipeline_transform_cc_proto",
"@federated-compute//fcp/protos/confidentialcompute:tff_worker_configuration_cc_proto",
"@federated_language//federated_language/proto:computation_cc_proto",
"@googletest//:gtest_main",
"@org_tensorflow//tensorflow/core:protos_all_cc",
"@org_tensorflow//tensorflow/core:tensorflow",
Expand Down
7 changes: 4 additions & 3 deletions containers/tff_worker/pipeline_transform_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "fcp/base/status_converters.h"
#include "fcp/protos/confidentialcompute/pipeline_transform.pb.h"
#include "fcp/protos/confidentialcompute/tff_worker_configuration.pb.h"
#include "federated_language/proto/computation.pb.h"
#include "grpcpp/server_context.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
Expand All @@ -45,7 +46,7 @@ namespace tf = ::tensorflow;
namespace tff = ::tensorflow_federated;

struct ComputationAndInput {
tff::v0::Computation computation;
federated_language::Computation computation;
tff::v0::Value input;
};

Expand Down Expand Up @@ -154,7 +155,7 @@ absl::StatusOr<tff::v0::Value> RestoreClientCheckpointToDict(
// given the names from the `fed_sql_tf_checkpoint_spec` and the values in
// the FCP checkpoint.
tff::v0::Value_Federated* federated = restored_value.mutable_federated();
tff::v0::FederatedType* type_proto = federated->mutable_type();
federated_language::FederatedType* type_proto = federated->mutable_type();
type_proto->set_all_equal(true);
*type_proto->mutable_placement()->mutable_value()->mutable_uri() =
tff::kClientsUri;
Expand Down Expand Up @@ -205,7 +206,7 @@ absl::StatusOr<ComputationAndInput> GetClientComputationAndInput(
ComputationAndInput computation_and_input;

// Read in TFF computation from the TffWorkerConfiguration.
tff::v0::Computation client_work_computation;
federated_language::Computation client_work_computation;
if (!computation_and_input.computation.ParseFromString(
client_work.serialized_client_work_computation())) {
return absl::InvalidArgumentError(
Expand Down
17 changes: 8 additions & 9 deletions containers/tff_worker/pipeline_transform_server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "fcp/protos/confidentialcompute/pipeline_transform.grpc.pb.h"
#include "fcp/protos/confidentialcompute/pipeline_transform.pb.h"
#include "fcp/protos/confidentialcompute/tff_worker_configuration.pb.h"
#include "federated_language/proto/computation.pb.h"
#include "gmock/gmock.h"
#include "google/protobuf/text_format.h"
#include "grpcpp/channel.h"
Expand All @@ -48,7 +49,6 @@
#include "tensorflow_federated/cc/core/impl/aggregation/testing/test_data.h"
#include "tensorflow_federated/cc/core/impl/executors/cardinalities.h"
#include "tensorflow_federated/cc/core/impl/executors/tensor_serialization.h"
#include "tensorflow_federated/proto/v0/computation.pb.h"
#include "tensorflow_federated/proto/v0/executor.pb.h"

namespace confidential_federated_compute::tff_worker {
Expand Down Expand Up @@ -88,7 +88,7 @@ constexpr absl::string_view kAggregationComputationPath =
constexpr absl::string_view kClientWorkComputationPath =
"containers/tff_worker/testing/client_work_computation.txtpb";

absl::StatusOr<tff_proto::Computation> LoadFileAsTffComputation(
absl::StatusOr<federated_language::Computation> LoadFileAsTffComputation(
absl::string_view path) {
// Before creating the std::ifstream, convert the absl::string_view to
// std::string.
Expand All @@ -99,7 +99,7 @@ absl::StatusOr<tff_proto::Computation> LoadFileAsTffComputation(
}
std::stringstream file_stream;
file_stream << file_istream.rdbuf();
tff_proto::Computation computation;
federated_language::Computation computation;
if (!google::protobuf::TextFormat::ParseFromString(
std::move(file_stream.str()), &computation)) {
return absl::InvalidArgumentError(
Expand All @@ -111,8 +111,7 @@ absl::StatusOr<tff_proto::Computation> LoadFileAsTffComputation(
tff_proto::Value BuildFederatedIntClientValue(float int_value) {
tff_proto::Value value;
tff_proto::Value_Federated* federated = value.mutable_federated();
tensorflow_federated::v0::FederatedType* type_proto =
federated->mutable_type();
federated_language::FederatedType* type_proto = federated->mutable_type();
type_proto->set_all_equal(true);
*type_proto->mutable_placement()->mutable_value()->mutable_uri() =
kClientsUri;
Expand Down Expand Up @@ -205,7 +204,7 @@ TEST_F(TffPipelineTransformTest, ConfigureAndAttestMoreThanOnce) {
TffWorkerConfiguration tff_worker_configuration;
TffWorkerConfiguration_ClientWork* client_work =
tff_worker_configuration.mutable_client_work();
absl::StatusOr<tff_proto::Computation> computation_proto =
absl::StatusOr<federated_language::Computation> computation_proto =
LoadFileAsTffComputation(kClientWorkComputationPath);
ASSERT_TRUE(computation_proto.ok()) << computation_proto.status();
std::string serialized_computation;
Expand Down Expand Up @@ -234,7 +233,7 @@ TEST_F(TffPipelineTransformTest, ValidConfigureAndAttest) {
TffWorkerConfiguration tff_worker_configuration;
TffWorkerConfiguration_ClientWork* client_work =
tff_worker_configuration.mutable_client_work();
absl::StatusOr<tff_proto::Computation> computation_proto =
absl::StatusOr<federated_language::Computation> computation_proto =
LoadFileAsTffComputation(kClientWorkComputationPath);
ASSERT_TRUE(computation_proto.ok()) << computation_proto.status();
std::string serialized_computation;
Expand Down Expand Up @@ -267,7 +266,7 @@ TEST_F(TffPipelineTransformTest, TransformCannotExecuteAggregation) {
// aggregation work.
TffWorkerConfiguration_Aggregation* aggregation =
tff_worker_configuration.mutable_aggregation();
absl::StatusOr<tff_proto::Computation> computation_proto =
absl::StatusOr<federated_language::Computation> computation_proto =
LoadFileAsTffComputation(kAggregationComputationPath);
ASSERT_TRUE(computation_proto.ok()) << computation_proto.status();
std::string serialized_computation;
Expand Down Expand Up @@ -301,7 +300,7 @@ TEST_F(TffPipelineTransformTest, TransformExecutesClientWork) {
// work.
TffWorkerConfiguration_ClientWork* client_work =
tff_worker_configuration.mutable_client_work();
absl::StatusOr<tff_proto::Computation> computation_proto =
absl::StatusOr<federated_language::Computation> computation_proto =
LoadFileAsTffComputation(kClientWorkComputationPath);
ASSERT_TRUE(computation_proto.ok()) << computation_proto.status();
std::string serialized_computation;
Expand Down
Loading

0 comments on commit aeb1d16

Please sign in to comment.