Problem cache follow-on: pluggable backends, layered cache paths, compile-options API, and offline tooling - #5117
Conversation
|
Thank you for your contribution! Since this is an external pull request, a maintainer must review PR and add the "ok-to-test" label if it is approved for testing. |
| MIGRAPHX_C_EXPORT migraphx_status migraphx_compile_options_set_advance_backend_options( | ||
| migraphx_compile_options_t compile_options, const char* options_json, ...); | ||
|
|
||
| MIGRAPHX_C_EXPORT migraphx_status migraphx_compile_options_set_problem_cache_paths( |
There was a problem hiding this comment.
The problem cache should be set as a backend option since this is a GPU-only option. So there shouldn't be an API changes.
| } | ||
| }; | ||
|
|
||
| #ifdef HAVE_GPU |
There was a problem hiding this comment.
I dont think we should be putting a lot of GPU-only code into the driver. The offline aggregation could be done as a python script.
|
|
||
| /// Search all caches in priority order (read-only first, then writable). | ||
| /// Returns the first hit. This is what compile_ops should call. | ||
| optional<value> find_in_problem_caches(const std::string& name, const value& problem) const |
There was a problem hiding this comment.
This shouldn't be in the context method. This should be handled by problem_cache::has.
| // | ||
| // te.py DSL input for migraphx::gpu::problem_cache_backend. | ||
| // | ||
| // REGENERATION (until tools/generate.py learns gpu/ subdir routing): |
There was a problem hiding this comment.
The tools/generate.py needs to be updated to handle the gpu/subdir. This should not be done manual as this will not be checked by CI.
| void insert(const cache_device_key& dk, const value& key, const value& solution); | ||
|
|
||
| /// Insert a sentinel (null value) for `key` to record "we've tried | ||
| /// this problem and there is no solution". Distinguished from a hit |
There was a problem hiding this comment.
This is not what mark is for. Its for a pending solution. This comment is completely wrong.
| * new solutions are written to the last (writable) path. Empty falls back | ||
| * to the MIGRAPHX_PROBLEM_CACHE environment variable. | ||
| */ | ||
| std::vector<std::string> problem_cache_paths; |
There was a problem hiding this comment.
There should be only one path. The path for the system level db or user level db should be compiled into migraphx.
| /** | ||
| * Problem cache file paths, searched in priority order (first hit wins); | ||
| * new solutions are written to the last (writable) path. Empty falls back | ||
| * to the MIGRAPHX_PROBLEM_CACHE environment variable. |
There was a problem hiding this comment.
With the backend option the MIGRAPHX_PROBLEM_CACHE variable should be removed.
|
I realized that not all of the runtime functionality is there for the backed abstraction layer is there, thus why it was in a draft so more changes are going to be committed. |
Introduce a type-erased problem_cache_backend (pluggable storage) with JSON and SQLite implementations; the runtime problem_cache routes has/insert/mark/get/load/save through it and canonicalizes keys so JSON round-trips match shipped caches. Move cache_device_key to its own header and route gpu/ DSL generation via generate.py. Signed-off-by: danieyan-amd <daniel.anieyan@amd.com>
Load an ordered list of read-only caches (first hit wins) alongside a writable cache; compile_ops and the gemm paths query them during tuning. Signed-off-by: danieyan-amd <daniel.anieyan@amd.com>
Read problem_cache_files from the GPU backend options and load them into the context; no dedicated API or environment variable is required. Signed-off-by: danieyan-amd <daniel.anieyan@amd.com>
8c119b5 to
6045418
Compare
Summary
Follow-on to #4835 (hardware-provenance problem cache). This adds the deployment and tooling layer around the problem cache so pre-tuned caches can be shipped, discovered, and combined without environment variables.
problem_cache_backendwith a JSON backend and an optional SQLite backend (built on system SQLite), selectable throughcompile_options.compile_optionsgains an ordered list of problem-cache paths (problem_cache_paths, with a single-path convenience). Paths are searched in priority order (first hit wins) and loaded read-only, so an application-provided cache can take precedence over a shipped one without mutating either.migraphx_compile_options_set_problem_cache_pathsand the matching C++/Python wrappers, so the paths can be set programmatically rather than via an environment variable.error_on_conflict/first_wins/last_wins).Testing
New GPU unit tests cover the backend abstraction, the SQLite backend round-trip, the layered path override, and the aggregator (merge / validate / convert plus conflict and legacy-device policies), along with an API-level compile-options test.
Notes
developand for review.