-
Notifications
You must be signed in to change notification settings - Fork 14
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
[DRAFT] Create ModuleCache, load ModuleCache into FB, Use to load FB + Golden Data in Explorer #1882
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for looking into and discovering this neat way of solving the problem! Minor naming/convention changes, otherwise looks great.
table ModuleCache { | ||
module_cache: [ModuleCacheItem]; | ||
} | ||
|
||
table DebugInfo { | ||
mlir: MLIR; |
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.
I think we should just turn this field into mlir_stages: [MLIR]
.
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.
Ah yeah, I didn't think to leverage the source
property of MLIR as the source pass, but that makes sense.
std::unordered_map<std::string, GoldenTensor> goldenMap = {}); | ||
std::shared_ptr<void> ttnnToFlatbuffer( | ||
Operation *op, std::unordered_map<std::string, GoldenTensor> goldenMap = {}, | ||
std::vector<std::pair<std::string, std::string>> moduleCache = {}); |
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.
We should probably pass by const&
, and update goldenMap
to do the same.
passName) != passNamesToCache.end()) { | ||
this->moduleCache.emplace_back(passName, outString); | ||
} else if (passNamesToCache.empty()) { | ||
this->moduleCache.emplace_back(passName, outString); |
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.
Let's restructure this, because printing the IR is relatively expensive, so let's only print if we need to:
bool shouldCache =
passNamesToCache.empty() ||
(std::find(passNamesToCache.begin(), passNamesToCache.end(), passName) != passNamesToCache.end());
if (shouldCache) {
... passAction.getOp()->print(os, flags); ...
}
transform();
I'm also not sure if we want to default print all passes, we probably want the default to do nothing.
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.
Yeah that looks much better, I left the default on all passes as a bit of a debug while I add this functionality into explorer. I will remove it by the time I finish drafting this PR.
include/ttmlir/Conversion/Passes.h
Outdated
@@ -26,6 +26,44 @@ namespace mlir::tt { | |||
#define GEN_PASS_REGISTRATION | |||
#include "ttmlir/Conversion/Passes.h.inc" | |||
|
|||
struct MLIRModuleCacher { |
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.
Let's call this MLIRModuleLogger
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.
Vraj this looks great! I think we can probably move it out of being a draft if you're ready.
Glad to hear it! I'm still adding support into explorer for actually loading from a FB stored this way. Running into a weird issue where ttrt doesn't recognize the new FB schema. |
tt-torch
frontend, view changes to make this possible there @ https://github.com/tenstorrent/tt-torch/tree/vprajapati/module-cacheMLIRModuleCacher
struct to trigger actions and cache modules.ModuleCache
todebug_info.fbs
so it gets stored there.runner