Skip to content

Commit

Permalink
fix(compiler): Decompression of evaluation keys was done several times
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgerieQuentin committed Apr 29, 2024
1 parent 3d338af commit fd2ea3f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct FFT {
typedef struct RuntimeContext {

RuntimeContext() = delete;
RuntimeContext(ServerKeyset serverKeyset);
RuntimeContext(ServerKeyset &serverKeyset);
virtual ~RuntimeContext() {
#ifdef CONCRETELANG_CUDA_SUPPORT
for (int i = 0; i < num_devices; ++i) {
Expand All @@ -69,10 +69,8 @@ typedef struct RuntimeContext {

virtual const struct Fft *fft(size_t keyId) { return ffts[keyId].fft; }

const ServerKeyset getKeys() const { return serverKeyset; }

protected:
ServerKeyset serverKeyset;
ServerKeyset &serverKeyset;
std::vector<std::shared_ptr<std::vector<std::complex<double>>>>
fourier_bootstrap_keys;
std::vector<FFT> ffts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ServerCircuit {

public:
/// Call the circuit with public arguments.
Result<std::vector<TransportValue>> call(const ServerKeyset &serverKeyset,
Result<std::vector<TransportValue>> call(ServerKeyset &serverKeyset,
std::vector<TransportValue> &args);

/// Simulate the circuit with public arguments.
Expand All @@ -65,7 +65,7 @@ class ServerCircuit {
std::shared_ptr<DynamicModule> dynamicModule,
bool useSimulation);

void invoke(const ServerKeyset &serverKeyset);
void invoke(ServerKeyset &serverKeyset);

Message<concreteprotocol::CircuitInfo> circuitInfo;
bool useSimulation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ void mlir::concretelang::python::populateCompilerAPISubmodule(
::concretelang::clientlib::PublicArguments &publicArguments,
::concretelang::clientlib::EvaluationKeys &evaluationKeys) {
SignalGuard signalGuard;
auto keyset = evaluationKeys.keyset;
auto &keyset = evaluationKeys.keyset;
auto values = publicArguments.values;
GET_OR_THROW_RESULT(auto output, circuit.call(keyset, values));
::concretelang::clientlib::PublicResult res{output};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FFT::~FFT() {
}
}

RuntimeContext::RuntimeContext(ServerKeyset serverKeyset)
RuntimeContext::RuntimeContext(ServerKeyset &serverKeyset)
: serverKeyset(serverKeyset) {

// Initialize for each bootstrap key the fourier one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool getGateIsSigned(const Message<concreteprotocol::GateInfo> &gateInfo) {
}

Result<std::vector<TransportValue>>
ServerCircuit::call(const ServerKeyset &serverKeyset,
ServerCircuit::call(ServerKeyset &serverKeyset,
std::vector<TransportValue> &args) {
if (args.size() != argsBuffer.size()) {
return StringError("Called circuit with wrong number of arguments");
Expand Down Expand Up @@ -542,7 +542,7 @@ Result<ServerCircuit> ServerCircuit::fromDynamicModule(
return output;
}

void ServerCircuit::invoke(const ServerKeyset &serverKeyset) {
void ServerCircuit::invoke(ServerKeyset &serverKeyset) {

// We create a runtime context from the keyset, and place a pointer to it in
// the structure.
Expand Down

0 comments on commit fd2ea3f

Please sign in to comment.