Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
#include "common/Logger.h"
#include "common/MeasureCounts.h"
#include "common/ServerHelper.h"
#include "common/RestClient.h"

#include "cudaq/utils/cudaq_utils.h"

#include "nlohmann/json.hpp"

#include <filesystem>
#include <llvm/ADT/StringRef.h>

#include <cstdlib>
Expand Down Expand Up @@ -45,11 +48,18 @@ class Equal1ServerHelper : public ServerHelper {

cudaq::sample_result processResults(ServerMessage &postJobResponse, std::string &jobId) override;

void updatePassPipeline(const std::filesystem::path &platformPath,
std::string &passPipeline) override;
private:

std::string equal1ServerURL;
std::string machine;
std::string optimizationLevel;

std::string devicePassPipeline;

RestClient client;

inline std::optional<std::string> getEnv(llvm::StringRef envVar) const {
const char* val = std::getenv(envVar.data());
if(!val)
Expand All @@ -70,8 +80,19 @@ class Equal1ServerHelper : public ServerHelper {

return defaultValue;
}

std::string queryPassPipeline();
};


std::string Equal1ServerHelper::queryPassPipeline() {
auto headers = getHeaders();
auto deviceProperties = client.get(equal1ServerURL, "devices/" + machine,
headers);

return deviceProperties["passPipeline"].get<std::string>();
}

void Equal1ServerHelper::initialize(BackendConfig config) {
cudaq::debug("{}ServerHelper::initialize", name());

Expand All @@ -82,12 +103,14 @@ void Equal1ServerHelper::initialize(BackendConfig config) {
if(!equal1ServerURL.ends_with("/"))
equal1ServerURL += "/";

machine = getConfig("EQUAL1_TARGET_MACHINE", "machine", "default");
machine = getConfig("EQUAL1_TARGET_MACHINE", "machine", "beta2");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the machine hardcoded here? Isn't there a way to set it like we set the target backend?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, we can set it either from the global config (passed from user) or override it from environment

That line just sets "beta2" as a default value


optimizationLevel = getConfig("EQUAL1_OPTIMIZATION_LEVEL", "opt", "1");

parseConfigForCommonParams(config);

devicePassPipeline = queryPassPipeline();

return;
}

Expand Down Expand Up @@ -167,6 +190,11 @@ cudaq::sample_result Equal1ServerHelper::processResults(ServerMessage &getJobRes
return sample;
};

void Equal1ServerHelper::updatePassPipeline(const std::filesystem::path&, std::string &passPipeline) {
passPipeline += "," + devicePassPipeline;
return;
}

} // namespace cudaq

// Register the Equal1 server helper in the CUDA-Q server helper factory
Expand Down
Loading