Skip to content

Commit 7bfbd0a

Browse files
Gautham Ganapathygeorgepaw
authored andcommitted
Add a check that the binary was compiled with the correct TF version
Summary: FIX T41133 Verify that the tensorflow and build versions of the embedded runtime match that of the runtime used to compile the executable. Reviewers: #tensorflow, simonl, #framework_ip_review_-_any_oss_or_third-party_code_use_has_been_approved, georgep Reviewed By: #tensorflow, #framework_ip_review_-_any_oss_or_third-party_code_use_has_been_approved, georgep Subscribers: georgep Maniphest Tasks: T41133 Differential Revision: https://phabricator.sourcevertex.net/D48627
1 parent 10a343a commit 7bfbd0a

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

tensorflow/compiler/plugin/poplar/driver/poplar_compiler.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,9 @@ StatusOr<std::unique_ptr<PoplarExecutableCore>> CompileEngine(
17581758
target_arch,
17591759
gateway_mode,
17601760
supports_remote_buffers,
1761+
TF_MAJOR_VERSION,
1762+
TF_MINOR_VERSION,
1763+
tf_git_version(),
17611764
replication_factor,
17621765
annotations.infeed_infos,
17631766
annotations.outfeed_infos,
@@ -1842,6 +1845,9 @@ StatusOr<std::unique_ptr<PoplarExecutableCore>> CompileEngine(
18421845
target_arch,
18431846
gateway_mode,
18441847
supports_remote_buffers,
1848+
TF_MAJOR_VERSION,
1849+
TF_MINOR_VERSION,
1850+
tf_git_version(),
18451851
replication_factor,
18461852
std::move(resources.annotations.infeed_infos),
18471853
std::move(resources.annotations.outfeed_infos),

tensorflow/compiler/plugin/poplar/driver/poplar_executable.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ limitations under the License.
3030
#include "tensorflow/compiler/plugin/poplar/driver/tools/tracepoint.h"
3131
#include "tensorflow/compiler/plugin/poplar/driver/tools/util.h"
3232
#include "tensorflow/compiler/plugin/poplar/driver/xla_ipu_common.h"
33-
#include "tensorflow/core/platform/stacktrace.h"
33+
#include "tensorflow/core/public/version.h"
3434

3535
namespace xla {
3636
namespace poplarplugin {
@@ -82,6 +82,10 @@ PoplarExecutableInfo FromProto(const PoplarExecutableProto& proto,
8282
info.gateway_mode = ertc.gateway_mode();
8383
info.supports_remote_buffers = ertc.supports_remote_buffers();
8484

85+
info.tf_major_version = proto.tf_major_version();
86+
info.tf_minor_version = proto.tf_minor_version();
87+
info.tf_git_version = proto.tf_git_version();
88+
8589
info.replication_factor = proto.replication_factor();
8690

8791
for (const auto& infeed : proto.infeeds()) {
@@ -181,6 +185,10 @@ PoplarExecutableProto ToProto(const PoplarExecutableInfo& info,
181185
ertc->set_gateway_mode(info.gateway_mode);
182186
ertc->set_supports_remote_buffers(info.supports_remote_buffers);
183187

188+
proto.set_tf_major_version(info.tf_major_version);
189+
proto.set_tf_minor_version(info.tf_minor_version);
190+
proto.set_tf_git_version(info.tf_git_version);
191+
184192
proto.set_replication_factor(info.replication_factor);
185193

186194
for (const auto& infeed : info.infeed_infos) {

tensorflow/compiler/plugin/poplar/driver/poplar_executable.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ struct PoplarExecutableInfo {
4545
std::string target_arch;
4646
bool gateway_mode;
4747
bool supports_remote_buffers;
48-
48+
uint32 tf_major_version;
49+
uint32 tf_minor_version;
50+
std::string tf_git_version;
4951
uint32 replication_factor;
5052
CanonicalInfeedInfos infeed_infos;
5153
CanonicalOutfeedInfos outfeed_infos;

tensorflow/compiler/plugin/poplar/driver/poplar_executable.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,8 @@ message PoplarExecutableProto {
117117
bool logging_cycle_count = 13;
118118

119119
EmbeddedRuntimeConfig embedded_runtime_config = 14;
120+
121+
uint32 tf_major_version = 15;
122+
uint32 tf_minor_version = 16;
123+
string tf_git_version = 17;
120124
};

tensorflow/compiler/plugin/poplar/kernels/datastream/application_runtime.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,21 @@ class ApplicationRuntime : public OpKernel {
388388
poplar::Executable executable =
389389
PoplarExecutableBinaryFile::Read(filename_, &proto).ValueOrDie();
390390

391+
OP_REQUIRES(ctx,
392+
proto.tf_major_version() == TF_MAJOR_VERSION &&
393+
proto.tf_minor_version() == TF_MINOR_VERSION,
394+
errors::InvalidArgument(absl::StrFormat(
395+
"TF version mismatch. Runtime version is %u.%u, "
396+
"executable version is %u.%u",
397+
TF_MAJOR_VERSION, TF_MINOR_VERSION,
398+
proto.tf_major_version(), proto.tf_minor_version())));
399+
400+
OP_REQUIRES(ctx, proto.tf_git_version() == tf_git_version(),
401+
errors::InvalidArgument(absl::StrFormat(
402+
"TF build version mismatch. Runtime version is %s, "
403+
"executable version is %s",
404+
tf_git_version(), proto.tf_git_version())));
405+
391406
auto& ertc = proto.embedded_runtime_config();
392407
const std::string target_type_string = ertc.target_type();
393408
poplar::TargetType target_type;

0 commit comments

Comments
 (0)