Extend problem cache with hardware provenance metadata#4835
Open
danieyan-amd wants to merge 3 commits into
Open
Extend problem cache with hardware provenance metadata#4835danieyan-amd wants to merge 3 commits into
danieyan-amd wants to merge 3 commits into
Conversation
Two changes to problem_cache.cpp:
1. load(): Project deserialized keys to only {name, problem} so that
extra metadata fields in the JSON don't break cache key matching.
Previously, the full JSON object (all fields) was used as the map
key, causing 100% cache misses when metadata was present.
2. save(): Enrich each key with hardware provenance before writing:
gpu_arch, cu_count, graphics_clock_mhz, memory_clock_mhz,
memory_bus_bits, vram_bytes, wavefront_size, regs_per_block,
max_threads_per_cu. Queried once via hipGetDeviceProperties at
session end — negligible performance cost.
The in-memory map always uses {name, problem} keys for O(1) lookups.
The on-disk JSON carries additional hardware context for traceability.
On load, the extra fields are projected away, preserving fast matching.
Author
|
Sorry Chris, I didnt mean to hit ready for review. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GPU problem cache persistence format to remain resilient to extra on-disk metadata while also recording hardware provenance for traceability.
Changes:
- In
load(), deserialize into a temporary map and project keys down to{name, problem}to prevent metadata fields from breaking cache-key matching. - In
save(), enrich persisted keys with HIP device properties (e.g., arch, CU count, clocks, VRAM) before writing the JSON file.
| // Enrich keys with hardware provenance metadata on write. | ||
| // This runs once at session end — negligible cost. | ||
| hipDeviceProp_t props{}; | ||
| auto status = hipGetDeviceProperties(&props, get_device_id()); |
Comment on lines
+61
to
+67
| std::unordered_map<value, value> raw; | ||
| from_value(from_json_string(read_string(pc_path)), raw); | ||
| for(auto& [k, v] : raw) | ||
| { | ||
| auto projected = create_key(k.at("name").to<std::string>(), k.at("problem")); | ||
| cache[projected] = v; | ||
| } |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4835 +/- ##
===========================================
+ Coverage 92.32% 92.80% +0.48%
===========================================
Files 583 584 +1
Lines 29332 30146 +814
===========================================
+ Hits 27080 27976 +896
+ Misses 2252 2170 -82 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
pfultz2
reviewed
May 8, 2026
| { | ||
| auto projected = create_key(k.at("name").to<std::string>(), k.at("problem")); | ||
| cache[projected] = v; | ||
| } |
Collaborator
There was a problem hiding this comment.
Make an extra copy can get slow with larger problem caches.
Collaborator
|
I think the metadata should be managed externally. In the future, we may use sqlite dbs to manage problem caches which may not be efficient to insert metadata like this. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two changes to problem_cache.cpp:
load(): Project deserialized keys to only {name, problem} so that extra metadata fields in the JSON don't break cache key matching. Previously, the full JSON object (all fields) was used as the map key, causing 100% cache misses when metadata was present.
save(): Enrich each key with hardware provenance before writing: gpu_arch, cu_count, graphics_clock_mhz, memory_clock_mhz, memory_bus_bits, vram_bytes, wavefront_size, regs_per_block, max_threads_per_cu. Queried once via hipGetDeviceProperties at session end — negligible performance cost.
The in-memory map always uses {name, problem} keys for O(1) lookups. The on-disk JSON carries additional hardware context for traceability. On load, the extra fields are projected away, preserving fast matching.
Motivation
Adding hardware info to the problem cache, and added handling of the hardware data when doing cache lookups for solutions.
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable