-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storing system descriptor #265
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,12 @@ | |
|
||
#include "common/pjrt_implementation/client_instance.h" | ||
|
||
#include <cstddef> | ||
#include <filesystem> | ||
#include <string> | ||
|
||
#include "common/pjrt_implementation/utils.h" | ||
#include "tt/runtime/types.h" | ||
|
||
namespace tt::pjrt { | ||
|
||
|
@@ -21,13 +24,17 @@ namespace tt::pjrt { | |
//===----------------------------------------------------------------------===// | ||
|
||
ClientInstance::ClientInstance(std::unique_ptr<Platform> platform) | ||
: platform_(std::move(platform)) { | ||
: platform_(std::move(platform)), system_descriptor_(nullptr) { | ||
DLOG_F(LOG_DEBUG, "ClientInstance::ClientInstance"); | ||
module_builder_ = std::make_unique<ModuleBuilder>(); | ||
cached_system_descriptor_path_ = | ||
std::filesystem::temp_directory_path().concat( | ||
"/tt_pjrt_system_descriptor"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a TODO comment here explaining that this name would need to be unique to avoid clashes between multiple clients, but since we plan soon to remove the need for storing the descriptor to the disk we are leaving it simple like this until then (or until it causes problems). |
||
} | ||
|
||
ClientInstance::~ClientInstance() { | ||
DLOG_F(LOG_DEBUG, "ClientInstance::~ClientInstance"); | ||
std::remove(cached_system_descriptor_path_.data()); | ||
} | ||
|
||
PJRT_Error *ClientInstance::Initialize() { | ||
|
@@ -164,8 +171,11 @@ void ClientInstance::BindApi(PJRT_Api *api) { | |
tt_pjrt_status ClientInstance::PopulateDevices() { | ||
DLOG_F(LOG_DEBUG, "ClientInstance::PopulateDevices"); | ||
auto [system_desc, chip_ids] = tt::runtime::getCurrentSystemDesc(); | ||
int devices_count = chip_ids.size(); | ||
|
||
system_descriptor_ = system_desc; | ||
system_descriptor_.store(cached_system_descriptor_path_.data()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check after this if
|
||
|
||
int devices_count = chip_ids.size(); | ||
devices_.resize(devices_count); | ||
for (size_t i = 0; i < devices_count; ++i) { | ||
devices_[i] = | ||
|
@@ -187,7 +197,8 @@ PJRT_Error *ClientInstance::Compile(const PJRT_Program *program, | |
std::string_view code(program->code, program->code_size); | ||
std::string_view format(program->format, program->format_size); | ||
|
||
tt_pjrt_status status = module_builder_->buildModule(code, format); | ||
tt_pjrt_status status = module_builder_->buildModule( | ||
code, format, cached_system_descriptor_path_); | ||
if (!tt_pjrt_status_is_ok(status)) { | ||
return ErrorInstance::MakeError(status); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input-only arguments should be ordered before the output or in-out arguments, see more here: https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs