Skip to content

Commit fd00b7c

Browse files
[GPU] Invalidate cache if it contains patchtoken binaries and driver version changed (#29195)
### Tickets: - https://jira.devtools.intel.com/browse/CVS-159917 --------- Co-authored-by: Pavel Durandin <pavel.durandin@intel.com>
1 parent 26b413e commit fd00b7c

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp

+33-2
Original file line numberDiff line numberDiff line change
@@ -636,25 +636,56 @@ void kernels_cache::add_to_cached_kernels(const std::vector<kernel::ptr>& kernel
636636

637637
void kernels_cache::save(BinaryOutputBuffer& ob) const {
638638
ob << _cached_binaries.size();
639+
640+
auto is_zebin = [](const std::vector<unsigned char>& bin) {
641+
constexpr uint32_t ELF_MAGIC = 0x464C457F;
642+
643+
if (bin.size() < sizeof(uint32_t)) {
644+
return false;
645+
}
646+
auto magic = reinterpret_cast<const uint32_t*>(bin.data())[0];
647+
return magic == ELF_MAGIC;
648+
};
649+
639650
for (auto& cached_binary : _cached_binaries) {
651+
auto is_zebin_binary = is_zebin(cached_binary.first);
652+
640653
ob << cached_binary.second;
641654
ob << cached_binary.first;
655+
ob << is_zebin_binary;
656+
if (!is_zebin_binary) {
657+
auto driver_version = downcast<ocl::ocl_device>(*_device).get_info().driver_version;
658+
ob << driver_version;
659+
}
642660
}
643661
}
644662

645663
void kernels_cache::load(BinaryInputBuffer& ib) {
646664
std::unordered_map<uint32_t, std::vector<unsigned char>> precompiled_kernels;
647665

666+
const auto& build_device = downcast<ocl::ocl_device>(*_device);
667+
648668
size_t num_cached_binaries;
649669
ib >> num_cached_binaries;
650670
for (size_t i = 0; i < num_cached_binaries; ++i) {
671+
bool is_zebin_binary = true;
672+
651673
uint32_t id;
652674
ib >> id;
653675
ib >> precompiled_kernels[id];
676+
ib >> is_zebin_binary;
677+
if (!is_zebin_binary) {
678+
// Legacy patchtoken path
679+
std::string driver_version, current_driver_version;
680+
ib >> driver_version;
681+
current_driver_version = build_device.get_info().driver_version;
682+
683+
if (driver_version != current_driver_version) {
684+
OPENVINO_THROW("Driver version mismatch in cached patchtoken kernels");
685+
}
686+
}
654687
}
655688

656-
const auto& build_device = downcast<ocl::ocl_device>(*_device);
657-
658689
try {
659690
std::lock_guard<std::mutex> lock(_mutex);
660691
_cached_kernels.clear();

src/plugins/intel_gpu/src/plugin/plugin.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,9 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options)
375375

376376
ov::AnyMap actual_runtime_info;
377377
auto prepare_actual_runtime_info = [&]() {
378-
// Suppose all devices share the same version driver.
379-
auto device_id = m_default_device_id;
380-
OPENVINO_ASSERT(m_device_map.find(device_id) != m_device_map.end(),
381-
"[GPU] compiled_model_runtime_properties: Couldn't find device for GPU with id ",
382-
device_id);
383-
actual_runtime_info["DRIVER_VERSION"] = m_device_map.at(device_id)->get_info().driver_version;
384-
// More items can be inserted if needed
378+
// Items can be inserted here if needed.
379+
// Note: driver version used to be here, but it was moved to cache load logic. See
380+
// https://github.com/openvinotoolkit/openvino/pull/29195
385381
};
386382
// Below properties depend on the device ID.
387383
if (name == ov::internal::compiled_model_runtime_properties.name()) {

0 commit comments

Comments
 (0)