MatMulNBits: report not stateless to skip eager const-eval#2445
Open
Reza2kn wants to merge 1 commit into
Open
Conversation
Type inference eager-const-evaluates a stateless op whose inputs are all constant, and for MatMulNBits that folds it by rebuilding and optimizing the op in isolation, far more costly than the fold into_optimized already does over the whole graph. Report the op as not stateless so the eager path is skipped; the constant fold still happens in into_optimized.
Collaborator
|
Hey ! thanks for your interest in tract ! Good eye, right diagnostic, but I think we have a better fix. I plead guilty on having abused the stateless flag myself, so it's very understandable. I think the right fix is in hir/src/infer/ops.rs, around the line 30, mimicking core/src/model/typed.rs:89, and if it works, it should fix in one place this class of bug. Care to give it a shot ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type inference eager-const-evaluates a constant-input
MatMulNBitsby rebuilding and optimizing each op in isolation to fold it, which is far slower than deferring the fold tointo_optimizedand can dominate load time on int4 models with many quantized matmuls. Reporting the op as not stateless skips that eager path; the constant fold still happens ininto_optimized.🍍