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

Fin Perf Eval handles (reboot) #1548

Merged
merged 115 commits into from
Jun 22, 2022
Merged

Conversation

cderb
Copy link
Contributor

@cderb cderb commented May 18, 2022

rehash of #1546
Changes:
generic_search
GetAllSolutions function added to generic_search, this function is made available through any_solver to the outside. This allows Fin to get the full list of solutions so that it may manage compilation manually.
Related function GetAllConfigs is also introduced for code modularity.

any_solver has functions added
GetAllSolutions - returns list of all solutions, used for kernel compiling in Fin.
GetPerfCfgParams - returns the parameter string for the solver's performance configuration. This is used for db recording in Fin.
LegacySolver - creates a bool at compile time that identifies legacy solvers

execution_context & find_solutions
add db_update bool to context - This allows Fin to programmatically initiate a db update tuning.

solver.hpp + .cpp files
changes necessary for new functions in generic_search

binary_cache
spelling fix

cderb and others added 30 commits December 2, 2021 00:05
a30a51bc6 remove unused header
7d2fd834c reduce scope of variable
f6e9abe79 clang format
834e9a397 remove comment
c8d6eb1a0 workspace rename
aa7d2ea24 Merge remote-tracking branch 'origin/develop' into cderb/miopen_perf
aaf13fb12 add to print for debug
ebd9aa6bd update member name (#43)
34e11fa70 Merge remote-tracking branch 'origin/develop' into cderb/miopen_perf
cb6c19d13 add search+update directives to execution context, add json examples for perf eval
85029077b connecting new fin functions for perf eval
d6d798efe add cu count (#39)
8e1989a9f Add find option for selecting only dynamic solvers (#38)
4d1e031fd add outputs and definitions
952538cb8 adding perf eval function, in progress
0e164bf66 setting json version (#37)
617dccd9c rename
5c35ae886 fixes for collecting kernel blobs
5cfea7c43 syntax fixes
2f2a4ed9f add test file
7175019f5 first rendition of perf_compile
f3f7fed18 Remove function redefinition (#36)
e1de51a58 Performance DB de-serialize test (#34)
043cdcdaa Layout support in Fin (#33)
3a1d58236 Hotfix (#32)
ee3f0d543 4.4 Tuning Bugfixes (#31)
832dbe234 Tunability Reporting (#27)
a564a229f include gfx90a_110 (#28)

git-subtree-dir: fin
git-subtree-split: a30a51bc6b4e3b1dedf6a37b429b287abf5784fc
@cderb
Copy link
Contributor Author

cderb commented Jun 2, 2022

Let me remind about re-implementing this with callbacks. Why:

  • Callback-based implementation involves smaller number of changes.
  • It does not have the drawback mentioned here.

I'll draft that up in a separate pr.

@cderb cderb marked this pull request as draft June 2, 2022 20:27
@atamazov
Copy link
Contributor

atamazov commented Jun 3, 2022

@cderb After second thought, I guess maybe it's time to kill ComputedContainers and replace them with STL.

Yes, ComputedContainers are virtually endless, but this feature is not really used. After all, now we build kernels for all possible PerformanceConfigs before benchmarking. If there are too many PerformanceConfigs, then the system will first run out of disk space. Usual STL container of PerformanceConfigs will run out of space much later.

So I am not against brute-force approach. And removal of ComputedContainers should make our code simpler.

@atamazov
Copy link
Contributor

atamazov commented Jun 3, 2022

@cderb So please decide yourself. If you decide to use STL, then go ahead. I will get rid of ComputedContainers after that, in a separate PR.

@cderb
Copy link
Contributor Author

cderb commented Jun 3, 2022

@atamazov I'm leaning more towards this implementation (using STL). It looks more clean from an interface level to have a function that specifically returns the array of solutions. The callback implementation I've tested and is functional, but I have some concerns about expanding the function signature of GenericSearch / what unintended uses that function pointer could enable.

@cderb cderb marked this pull request as ready for review June 3, 2022 20:31
@atamazov
Copy link
Contributor

atamazov commented Jun 3, 2022

@cderb Ok.

@junliume
Copy link
Contributor

junliume commented Jun 6, 2022

@atamazov @DrizztDoUrden @JehandadKhan last round call for the reviewers, we plan to proceed with this one.

junliume
junliume previously approved these changes Jun 6, 2022
JehandadKhan
JehandadKhan previously approved these changes Jun 6, 2022
averinevg
averinevg previously approved these changes Jun 7, 2022
src/include/miopen/any_solver.hpp Outdated Show resolved Hide resolved
src/include/miopen/any_solver.hpp Show resolved Hide resolved
ConvSolution FindSolution(const ConvolutionContext& ctx,
Db& db,
const miopen::AnyInvokeParams& invoke_ctx) const override
{
return miopen::solver::FindSolution(value, ctx, db, invoke_ctx);
};

std::string GetPerfCfgParams(const ConvolutionContext& ctx, Db& db, std::true_type) const
Copy link
Contributor

Choose a reason for hiding this comment

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

The body of this function looks like a modified copy of very similar code from FindSolutionImpl (src/include/miopen/find_solution.hpp). Can we generalize this?

Copy link
Contributor Author

@cderb cderb Jun 7, 2022

Choose a reason for hiding this comment

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

The objective of this function is to return the parameter string from the performance config. I see the portion that is common here, and most likely it was the example for this addition. They are entirely similar in that they

  1. use the same type declaration
  2. load from the db
  3. check validity of the config loaded
  4. do a function x with the loaded config
  5. log progress

The main difference being (4) the way to minimize this code would be to create an additional function providing a callback in place of (4).
Disregarding log statements and syntactical spacing there are a total of 4 shared lines. Not sure if it's worth complicating with a callback.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cderb

The objective of this function is to return the parameter string from the performance config

Excuse me, but AFAICS this function is not used, so it seems like it does not have an objective expressed in the code ;)

Which is not surprising, because from the architectural point of view, getting tuning config from the database is not a Solver's job.

I think that this method should be removed from AnySolver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove this function, I'll need a way to retrieve the serialized performance parameters. Could be the winner from the solver or from a solution. I'm searching for another method, but nothing yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add this function to a PR that will actually use it? This will allow us to expedite the review of this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. If you know SolverId, then it is possible to construct an instance of the Solver and then follow the design pattern of:
https://github.com/ROCmSoftwarePlatform/MIOpen/blob/72d89b40ee97666efaac0a0979a48680bd02f1da/src/include/miopen/find_solution.hpp#L123-L125
I can do this for you in a future PR where you will implement Fin changes. Or you can ask @DrizztDoUrden to assist.

But let's avoid adding unused code in this PR. Is it acceptable for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the key issue is that in order to call serialize on PerformanceConfig, access to the fully substantiated type is required, but occluded behind AnySolver. There needs to be some way of extracting that performance parameter string so that the pdb entry data can be recorded by Fin.
A function producing the performance parameter string would be necessary for the current implementation of performance tuning in Fin to be complete.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please send me proposed Fin changes (where you call GetPerfCfgParams) and I will offer a substitute. This is necessary, because

from the architectural point of view, getting tuning config from the database is not a Solver's job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll email the code section to your amd address. Do you still have access?

Copy link
Contributor

Choose a reason for hiding this comment

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

@cderb No, unfortunately. But you can send me mail to DXC (please check your amd inbox).

@cderb cderb dismissed stale reviews from averinevg, JehandadKhan, and junliume via 9563a5e June 8, 2022 17:55
src/include/miopen/any_solver.hpp Outdated Show resolved Hide resolved
src/solver/conv_hip_implicit_gemm_bwd_v4r1.cpp Outdated Show resolved Hide resolved
src/solver/conv_hip_implicit_gemm_fwd_v4r4.cpp Outdated Show resolved Hide resolved
@@ -67,6 +67,7 @@ struct ExecutionContext
{
// Operation modes & environment
bool do_search = false;
bool db_update = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only initialized but not updated anywhere. Can we make this change when it's really needed (thus following the YAGNI principle)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in fin, at conv_fin.hpp:559

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but the problem is that this PR does NOT include changes in conv_fin.hpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be resolved by changes in #1588

Copy link
Contributor

@atamazov atamazov left a comment

Choose a reason for hiding this comment

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

Let's move forward with whatever we already have. I will try to refactor the code after some ongoing rework (that involves reworking of the PerformanceConfig class hierarchy) is done.

/cc @averinevg

@junliume junliume merged commit 45801b0 into develop Jun 22, 2022
@cderb cderb deleted the cderb/fin_perf_solver_mergres2 branch July 22, 2022 16:59
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.

6 participants