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

How to tune using API? #3086

Open
bghimireamd opened this issue Jun 27, 2024 · 5 comments
Open

How to tune using API? #3086

bghimireamd opened this issue Jun 27, 2024 · 5 comments
Assignees

Comments

@bghimireamd
Copy link
Contributor

bghimireamd commented Jun 27, 2024

Can we do tuning using API? Lets say if I want to tune fused solver or regular solver. I can do:

MIOPEN_FIND_ENFORCE=3 MIOPEN_FIND_MODE=1 ./bin/MIOpenDriver CBAInfer -F 4 -n 128 -c 3 -H 32 -W 32 -k 64 -y 3 -x 3 -p 1 -q 1 -u 1 -v 1 -l 1 -j 1

But is there its API equivalent? is miopenFindConvolutionForwardAlgorithm for this? But this seem to be for regular solver. I was looking find for fused solver.

@DrizztDoUrden
Copy link
Contributor

DrizztDoUrden commented Jul 15, 2024

AFAIK it is not possible to more or less guarantee tuning happening just through API without MIOPEN_FIND_ENFORCE=3 MIOPEN_FIND_MODE=1 in both conv and fusion. As of recently invoking fusion through any API would cause tuning when possible. IIRC you also need to ensure that find-db doesn't contain an entry for the problem you are tuning currently. Both perfdb and finddb should be functional on all fusion API calls.

@umangyadav
Copy link
Member

umangyadav commented Jul 19, 2024

AFAIK it is not possible to more or less guarantee tuning happening just through API without MIOPEN_FIND_ENFORCE=3 MIOPEN_FIND_MODE=1 in both conv and fusion.

For the Conv case, with find 2.0 API i thought we don't need to set ENV var. Has it changed ?

e.g.

MIOPEN_EXPORT miopenStatus_t miopenFindSolutions(miopenHandle_t handle,

@DrizztDoUrden
Copy link
Contributor

DrizztDoUrden commented Jul 20, 2024

Find 2.0 does not respect FIND_MODE, but perf-db always works the same way. If there is an entry, tuning would not happen unless enforce is set. Plus it also uses find-db, which is also disabled when tuning is enforced.

@umangyadav
Copy link
Member

umangyadav commented Jul 22, 2024

not happen unless enforce is set

Enforce can be set using fort the Find-2.0 API.

MIOPEN_EXPORT miopenStatus_t miopenSetFindOptionTuning(miopenFindOptions_t options, int value);

Is that correct for the case of convolution ?

I have object to following statement that's the reason why i am asking.

it is not possible to more or less guarantee tuning happening just through API without MIOPEN_FIND_ENFORCE=3 MIOPEN_FIND_MODE=1 in both conv and fusion.

@DrizztDoUrden
Copy link
Contributor

DrizztDoUrden commented Jul 26, 2024

TL;DR:

When there is an entry in find-db, it can be skipped by MIOPEN_DEBUG_DISABLE_FIND_DB environment variable. Maybe we should add some way to do it through API like ignoring entry when do_search is set.
When there is an entry in perf-db, tuning can only be forced in fusion by setting an environment variable. Maybe we should add something like miopenSetFindOptionDbUpdate, because we actually have internals in place for that and it is just an API problem.
When there is neither, tuning can be allowed by either enforce or miopenSetFindOptionTuning after #3157 gets merged.

Some details:

Enforce is a separate thing that supersedes it. You are partially correct. Now that I have re-read the related source I can see that it should force tuning in some cases: when find actually happens and there is no entry in the perf-db, like MIOPEN_FIND_ENFORCE=SEARCH. There is no API analogue DB_UPDATE and SEARCH_DB_UPDATE values of the enforce. We can easily add a function for that, but it is not in right now.
Also I see an oversight aka bug that fused problems just ignore value passed to miopenSetFindOptionTuning. I have created #3157.
If there is no entry in both find-db and perf-db and miopenSetFindOptionTuning was called with a non-zero, tuning should happen when the mentioned PR gets merged. In find 1.0 fusion there is no way to force find without the environment variables. Also I am not sure there is some way to force it to overcome an entry in find-db in find 2.0, which is kind of an oversight as well. I thought that it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants