-
Notifications
You must be signed in to change notification settings - Fork 68
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
[Runtime] solve the problem that llama frequently calls autotuner #332
Conversation
src/flag_gems/utils/libentry.py
Outdated
connect = sqlite3.connect(self.cache_dir) | ||
c = connect.cursor() | ||
c.execute(f"CREATE TABLE IF NOT EXISTS {self.__name__} (key TEXT, config TEXT)") | ||
cursor = c.execute(f"SELECT key, config from {self.__name__}") | ||
|
||
for row in cursor: | ||
key_str, config_str = row | ||
key = (self.getvalue(k) for k in key_str[1:-1].split(", ")) | ||
|
||
cfg_ls = [item.split(": ") for item in config_str.split(", ")] | ||
config = triton.Config({}) | ||
for k, v in cfg_ls[:-4]: | ||
config.kwargs[k] = eval(v) | ||
config.num_warps = int(cfg_ls[-4][1]) | ||
config.num_ctas = int(cfg_ls[-3][1]) | ||
config.num_stages = int(cfg_ls[-2][1]) | ||
config.enable_fp_fusion = eval(cfg_ls[-1][1]) | ||
|
||
self.cache[key] = config | ||
|
||
connect.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we could leave the connection open and shared because we need to fetch stored params for all gems ops. A try catch block is possibly necessary for external IO operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think its fine at this stage. Let's improve it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is not always a explicit exit of flag_gems. I'm not sure what time to close the connection if keep it open.
|
||
|
||
def config_cache_dir() -> Path: | ||
_config_cache_dir = cache_dir() / "config_cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion for name: "tunning_cache"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference?
* new feature, muti_backend * update auto_tune_module * update auto_tune_module * update auto_tune_module * update __init__ * rebase * fix bug * modifiy auto_tune_config * fix bug * fix bug * update * update * update scatter&gather * fix auto_tune * add gen_torch_device_fn * fix codestyle * fix codestyle * Modify code based on comments * Modify gen_impl with loops instead of recursion * Update code structure * Polish code * update * Polish code * Modify code based on comments * modify based on comment * Modify code based on comments * update * final fix
…agOpen#332) * [operator] turn autotuner to heuristics * [operator] heuristics for gather & index_select * [runtime] libtuner for matmul * [runtime] store config data in one db * [bugfix] parse key as list instead of tuple * [no ci] update var name * [Muti_backend] muti_backend-part_1-framework-and-tune_config (FlagOpen#294) * new feature, muti_backend * update auto_tune_module * update auto_tune_module * update auto_tune_module * update __init__ * rebase * fix bug * modifiy auto_tune_config * fix bug * fix bug * update * update * update scatter&gather * fix auto_tune * add gen_torch_device_fn * fix codestyle * fix codestyle * Modify code based on comments * Modify gen_impl with loops instead of recursion * Update code structure * Polish code * update * Polish code * Modify code based on comments * modify based on comment * Modify code based on comments * update * final fix * [bugfix] update libtuner to be compatible with triton2 * [no ci]reformat * [operator] update log_softmax * [pretune] move pretune to ./examples for models * [format] delete useless print * [format] delete unused import * [format] [no ci] remove useless print --------- Co-authored-by: Galaxy1458 <[email protected]>
PR Category
Runtime
Type of Change
New Feature
Description
implement LibTuner to take place of Autotuner.
it stores tuned configs in database and preloads them before calling.
Issue
Progress
Performance