Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Find2.0][API] Invoker caching and binaries serialization in miopen::Solution #2146

Merged
merged 88 commits into from
Jun 12, 2024

Conversation

DrizztDoUrden
Copy link
Contributor

@DrizztDoUrden DrizztDoUrden commented May 11, 2023

This updates convolution internals to support the planned features of find 2.0 and some more as a trivial side-effect.

New features:

  • Invoker caching in the miopenSolution_t. This allows zero lookup miopenRunSolution calls after either miopenFindSolutions or miopenLoadSolution.
  • Solution binaries serialization. This allows users to implement all file-based caching on their side and have zero lookups from the start just by deserializing and running solutions. Binaries are not stored in the solution as is when possible. Runtime program handle wrappers are kept instead. That allows to not waste additional memory, but prevents trivially implementing the features for OpenCL, so no binary serialization happens there.
  • miopenSetFindOptionAttachBinaries with default value of false that controls binary attachment to solutions. With false machinery behaves like before the PR + invoker caching.

This has been squashed as it was based on another PR and had 120+ commits, most of which were completely unrelated or merges.

Future work:

  • Something like miopenStatus_t miopenRemoveSolutionBinaries(miopenSolution_t) can be added to reduce the memory footprint of a solution in case it would be held in memory long-term. This way found solutions may be saved, stripped of binaries and then used.
  • Some API way to detach binaries from multiple solutions to a single external cache with constant lookup time may be implemented to reduce the total size of solutions blob if multiple solutions with same binaries are saved. A set of functions like the following may be added:
    • miopenStatus_t miopenCreateBinariesBlob(miopenBinariesBlob_t*)
    • miopenStatus_t miopenDestroyBinariesBlob(miopenBinariesBlob_t)
    • miopenStatus_t miopenDetachSolutionBinaries(miopenBinariesBlob_t, miopenSolution_t)
    • miopenStatus_t miopenAttachSolutionBinaries(miopenBinariesBlob_t, miopenSolution_t)
    • miopenStatus_t miopensSaveBinaries(miopenBinariesBlob_t, char*, size_t*)
    • miopenStatus_t miopensLoadBinaries(miopenBinariesBlob_t, const char*, size_t)

Internally it can be done as

struct BinariesBlob
{
    std::vector<Program> programs;
};
void to_json(nlohmann::json& json, const BinariesBlob& binaries);
void from_json(const nlohmann::json& json, BinariesBlob& binaries);

with binaries serialized from/to programs in load/save. Detaching from solution would replace program handles with indexes in the vector, removing the duplicates. Reverse for attaching.

@DrizztDoUrden DrizztDoUrden changed the title Find 2.0 internals update Invoker and binaries caching in miopen::Solution May 11, 2023
@DrizztDoUrden DrizztDoUrden changed the title Invoker and binaries caching in miopen::Solution Invoker caching and binaries serialization in miopen::Solution May 11, 2023
@DrizztDoUrden DrizztDoUrden changed the title Invoker caching and binaries serialization in miopen::Solution [Find2.0][API] Invoker caching and binaries serialization in miopen::Solution May 21, 2023
@junliume
Copy link
Collaborator

@DrizztDoUrden the test_find_2_conv is failing pretty persistently now

@junliume junliume dismissed averinevg’s stale review June 12, 2024 06:22

Re-request review

Copy link
Collaborator

@junliume junliume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @averinevg @pfultz2 for last round of review

Copy link
Collaborator

@averinevg averinevg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@junliume junliume merged commit f249c20 into develop Jun 12, 2024
139 of 140 checks passed
@DrizztDoUrden DrizztDoUrden deleted the ddu/find-2.0-core branch June 12, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants