Pretrained Model Reload + SparseGPT Support #31
Merged
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.
Adding in helper functions to support reloading a quantized model from config with SparseAutoModel. This has a few steps:
apply_quantization_config()
is calledload_pretrained_quantization()
function. This loops through the leaf modules and grabs the scale/zp from the safetensors file(s) at model_pathExample Usage (would be in SparseAutoModel.from_pretrained)
@dbogunowicz I know a lot of the UX is going to change with your refactor, but I needed to get something up and running for testing. This is just adding in the helper functions that your UX could will eventually call
Associated SparseML branch: neuralmagic/sparseml#2246
Quick Note on SparseGPT/OBCQ
In the new fake_quantize implementation we overwrite the weights parameter in the forward call (
forward.py
)This didn't happen in the old implementation, we never overwrote the actual parameter so the original unquantized weight was saved. This new implementation messes up OBCQ because we rely on the error between the unquantized and the quantized weight. As a workaround for now, I'm cloning the original weight then restoring it after the forward pass