fix: support ITensor amex in quantize and add export_torch_mode() wrapper - #4431
Conversation
…modelopt quant models
narendasan
left a comment
There was a problem hiding this comment.
Can you explain what this context is and maybe add some tests?
|
I see, is there any harm in always having this context? should we catch cases where the modelopt is missing but the context is needed and throw an error/warning? |
I remember ModelOpt is not required in torch-trt. If we need to check all models with ModelOpt API, the package should be required rather than opt in. |
| if importlib.util.find_spec("modelopt") is not None: | ||
| from modelopt.torch.quantization.utils import export_torch_mode, is_quantized | ||
|
|
||
| if is_quantized(mod): |
There was a problem hiding this comment.
Should we throw a warning if its a quantized model but model opt is not available? Does this matter for torchao or other sources?
There was a problem hiding this comment.
well since the function is_quantized is imported from modelopt, it must be available at this point. If we want to throw errors/warnings, I think we might need to write a helper function to detect quantizers to override is_quantized. For other sources like torchao, if they insert quantizers or similar indicators, we can use the same mechanism.
|
@narendasan I optimized codes so that if modelopt is not installed, it will fallback to check module names. And it will error out for quantized model if modelopt is requirement. Also, it's easy to generalize for other sources like torchao. |
Description
export_torch_mode()wrapper intorch_tensorrt.compileto modelopt quant modelsFixes #4429 #2976
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: