-
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
Enabling non-hardcoded run of our test infrastructure #145
Open
ajakovljevicTT
wants to merge
3
commits into
main
Choose a base branch
from
ajakovljevic/solving_the_twochip_issue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+75
−28
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
|
||
#include "common/pjrt_implementation/loaded_executable_instance.h" | ||
|
||
#include <unordered_set> | ||
|
||
#include "common/pjrt_implementation/buffer_instance.h" | ||
#include "common/pjrt_implementation/client_instance.h" | ||
#include "common/pjrt_implementation/error_instance.h" | ||
|
@@ -32,12 +34,15 @@ void LoadedExecutableInstance::BindApi(PJRT_Api *api) { | |
DLOG_F( | ||
LOG_DEBUG, | ||
"LoadedExecutableInstance::PJRT_LoadedExecutable_AddressableDevices"); | ||
const std::vector<DeviceInstance *> &devices = | ||
const std::vector<DeviceInstance *> &addressable_devices = | ||
LoadedExecutableInstance::Unwrap(args->executable) | ||
->addressable_devices(); | ||
int num_addressable_devices = | ||
LoadedExecutableInstance::Unwrap(args->executable) | ||
->image_->get_num_addressable_devices(); | ||
args->addressable_devices = const_cast<PJRT_Device **>( | ||
reinterpret_cast<PJRT_Device *const *>(devices.data())); | ||
args->num_addressable_devices = devices.size(); | ||
reinterpret_cast<PJRT_Device *const *>(addressable_devices.data())); | ||
args->num_addressable_devices = num_addressable_devices; | ||
return nullptr; | ||
}; | ||
api->PJRT_LoadedExecutable_Delete = | ||
|
@@ -77,23 +82,34 @@ LoadedExecutableInstance::Execute(PJRT_LoadedExecutable_Execute_Args *args) { | |
DLOG_F(LOG_DEBUG, "LoadedExecutableInstance::Execute"); | ||
|
||
auto [system_desc, chip_ids] = tt::runtime::getCurrentSystemDesc(); | ||
int dev_0 = chip_ids[0]; | ||
tt::runtime::Device device = tt::runtime::openDevice({dev_0}); | ||
|
||
// Sanity check, as we only support execution on one chip currently. | ||
assert(args->num_devices == 1); | ||
|
||
int dev_index = 0; | ||
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. Why is this hardcoded? 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. We still have only one process that executes, which is what this index represents. |
||
tt::runtime::Binary binary(image_->get_binary()); | ||
|
||
std::vector<tt::runtime::Tensor> rt_inputs; | ||
rt_inputs.reserve(args->num_args); | ||
|
||
std::unordered_set<int> device_ids; | ||
|
||
for (size_t i = 0; i < args->num_args; ++i) { | ||
BufferInstance *buffer = | ||
BufferInstance::Unwrap(args->argument_lists[dev_index][i]); | ||
rt_inputs.emplace_back(buffer->tensor()); | ||
int64_t buffer_device_id = | ||
buffer->device().device_description()->device_id(); | ||
device_ids.insert(chip_ids[buffer_device_id]); | ||
DLOG_F(INFO, "Runtime input id: %d", buffer->unique_id()); | ||
} | ||
|
||
assert(device_ids.size() == 1); | ||
ajakovljevicTT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
std::vector<int> device_ids_vector(device_ids.begin(), device_ids.end()); | ||
|
||
tt::runtime::Device device = tt::runtime::openDevice(device_ids_vector); | ||
|
||
std::vector<tt::runtime::Tensor> rt_outputs = | ||
tt::runtime::submit(device, binary, 0, rt_inputs); | ||
std::vector<tt::runtime::TensorDesc> output_specs = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the difference between
num_devices
andnum_addressable_devices
?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.
num_devices
, passed as the argument of this function is the total number of devices for execution. It was inferred fromnum_addressable_devices
in the xla bridge code.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.
Inferred how? Equal to it?
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.
Yes, equal to it