Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Module Based Model Runtime for AOT #46
Module Based Model Runtime for AOT #46
Changes from 2 commits
f4ef8a6
639ad69
04b6d76
d5659c5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
runtime.Module is produced per backend. As long as that exists, somewhere in the compiler per-backend IRModule have to exist -- that does the translation from IRModule --> runtime.Module.
However, we have hierarchical runtime.Module trees being built -- so what we can eventually do maybe create hierarchical IRModule structure. In that structure, it might make sense to keep this metadata.
cc : @tqchen @Mousius @jroesch
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.
a couple points:
runtime.Module
can be produced by a given backendThere 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.
Agreed.
The requirement to mention this here seems like stemming from the fact it is aligned with other RFC/pre-RFCs that single (tree of) IRModule --> (list of) runtime.Modules -- is a proposed change -- therefore, this motivates the change proposed here.
Thus, would it be possible to add a reference to this proposal (if any)?
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.
hmm, i'm not quite sure i follow you here. I'm happy to add a reference to the Artifact proposal, but I'm not sure it's quite exactly what I'm stating here. Here, what I mean is that the TIR-to-Runtime interface is
IRModule -> (tree of runtime.Module)
. The existing MetadataModule (which is proposed to rename to ConstLoaderModule here) seems to have arisen out of a desire to build common infrastructure to handle loading DLTensor from.text
in the C++ runtime. Here what I'm trying to point out is that since the TIR-to-Runtime interface provides no facility for the TIR-to-runtime processes to return metadata outside of theruntime::Module
, this leads to duplication of information should it be required by the compiler in any way. For example,constant_sizes
could be deduced from the DLTensor passed to ConstLoaderModule, but ConstLoaderModule is not supported by all runtimes and not the de-facto way to load constant data or metadata at runtime because it doesn't support encoding structs and scalar values. You can also see some duplication in CudaModule.I think this proposal is attempting to start down the path of unifying these different methods of providing data generated during lowering to the runtime as Metadata. I think that's mainly covered here, but happy to add a reference to the Artifact thing if it helps, it just seems a bit orthogonal to me.
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 I dont dispute the claim that IRModule --> (tree of runtime.Module).
The current lowering flow creates IRModule per backend that get translated to runtime.Module(s).
I see that as (correct me if I am wrong) : Unified IRModule --> [IRModule per backend] --> tree of runtime.Module s
which is basically a host runtime.Module includes a flat array device runtime.Modules.
Now the proposal here want to attach model-level Metadata from the Unified IRModule to (root of) tree of runtime.Module s.
So the gap in the text here is that the text assumes it is common knowledge that how [IRModule per backend] disappears. Hypothetically, lets say it is not there -- then text make sense because the model-level metadata could be attached to Unified IRModule and then passed onto tree of runtime.Module s.
Now my questions is, in the absense of a proposal how to remove the IRModule per backend (or if its already there -- please link the RFC/pre-RFC), this RFC needs to outline a way how this will be communicated from Unified IRModule to tree of runtime.Module s in the current lowering flow and/or the changes brought by this RFC.
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 see--so this is more about the wording a couple paragraphs down, no?
cc @jroesch i am actually not sure if there is an RFC describing this.
i'm hoping to describe my ambitions to "link" metadata into TIR via
tir.load_metadata
node in a following RFC, and I definitely would need consolidated metadata for this at the IRModule level. I'm not sure if there is anything in code-generation that strictly requires this--it's just cleaner in my book. Let me know if I'm missing anything here.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.
per our offline discussion, clarified how the metadata is carried through the current compiler design, removed references to un-RFC'd design efforts and replaced with text to motivate them. also clarified some wording--ptal
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 the following arguments argues for re-structure (not just runtime::MetadataNode).
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.
how so?
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 dont see how 1.) is relevant to the expansion of runtime::MetadataNode.
My comment was to adjust the text here to say something like "modify the lowering flow" rather than "the expansion of
runtime::MetadataNode
" -- because latter is a sub-part of the former and I believe former is what is proposed here and covered by the following points.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 i see, changed the wording. i guess i was trying to say that the name MetadataNode should cover a more complex thing, but in practice you're right that this proposes a restructuring.