OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Invalidate cache if it contains patchtoken binaries and driver version changed (#29195)
Tomasz Krupafd00b7c34e24
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cppindex 195a2443016..5239005448c 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.cpp@@ -636,25 +636,56 @@ void kernels_cache::add_to_cached_kernels(const std::vector<kernel::ptr>& kernelvoid kernels_cache::save(BinaryOutputBuffer& ob) const {ob << _cached_binaries.size();++ auto is_zebin = [](const std::vector<unsigned char>& bin) {+ constexpr uint32_t ELF_MAGIC = 0x464C457F;++ if (bin.size() < sizeof(uint32_t)) {+ return false;+ }+ auto magic = reinterpret_cast<const uint32_t*>(bin.data())[0];+ return magic == ELF_MAGIC;+ };+for (auto& cached_binary : _cached_binaries) {+ auto is_zebin_binary = is_zebin(cached_binary.first);+ob << cached_binary.second;ob << cached_binary.first;+ ob << is_zebin_binary;+ if (!is_zebin_binary) {+ auto driver_version = downcast<ocl::ocl_device>(*_device).get_info().driver_version;+ ob << driver_version;+ }}}void kernels_cache::load(BinaryInputBuffer& ib) {std::unordered_map<uint32_t, std::vector<unsigned char>> precompiled_kernels;+ const auto& build_device = downcast<ocl::ocl_device>(*_device);+size_t num_cached_binaries;ib >> num_cached_binaries;for (size_t i = 0; i < num_cached_binaries; ++i) {+ bool is_zebin_binary = true;+uint32_t id;ib >> id;ib >> precompiled_kernels[id];+ ib >> is_zebin_binary;+ if (!is_zebin_binary) {+ // Legacy patchtoken path+ std::string driver_version, current_driver_version;+ ib >> driver_version;+ current_driver_version = build_device.get_info().driver_version;++ if (driver_version != current_driver_version) {+ OPENVINO_THROW("Driver version mismatch in cached patchtoken kernels");+ }+ }}- const auto& build_device = downcast<ocl::ocl_device>(*_device);-try {std::lock_guard<std::mutex> lock(_mutex);_cached_kernels.clear();diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cppindex cad527a9f7d..f14db8994a5 100644--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp@@ -375,13 +375,9 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options)ov::AnyMap actual_runtime_info;auto prepare_actual_runtime_info = [&]() {- // Suppose all devices share the same version driver.- auto device_id = m_default_device_id;- OPENVINO_ASSERT(m_device_map.find(device_id) != m_device_map.end(),- "[GPU] compiled_model_runtime_properties: Couldn't find device for GPU with id ",- device_id);- actual_runtime_info["DRIVER_VERSION"] = m_device_map.at(device_id)->get_info().driver_version;- // More items can be inserted if needed+ // Items can be inserted here if needed.+ // Note: driver version used to be here, but it was moved to cache load logic. See+ // https://github.com/openvinotoolkit/openvino/pull/29195};// Below properties depend on the device ID.if (name == ov::internal::compiled_model_runtime_properties.name()) {