Comments (4)
We have recently enabled the pytorch fx graph mode for quantization aware training and post-training quantization, so no need to add QuantStub and DeQuantStub in the model anymore. If you are interested on using the pytorch eager mode for post-training quantization and on how the model was modified by the Intel Neural Compressor team, you can take a look at : https://github.com/intel/neural-compressor/blob/master/examples/pytorch/eager/language_translation/ptq/transformers/modeling_bert.py
from optimum.
Thanks a lot @echarlaix. Works like a charm with torch FX graph mode. However, when running the test (https://github.com/huggingface/optimum/blob/main/tests/intel/test_lpot.py) for static quantization and changing the batch size, I always run in an error if the number of samples divided by the batch size has a remainder and the last batch then has less samples than the actual batch size (e.g. with batch size 16):
[ERROR] Unexpected exception RuntimeError("shape '[16, 128, 12, 64]' is invalid for input of size 786432") happened during tuning.
Is there some way to circumvent this?
from optimum.
Currently our tracing of the model with torch fx does not support dynamic inputs shapes and we are currently working towards it. In the meantime, a simple fix could be to set dataloader_drop_last of the TrainingArguments to True.
from optimum.
Would definitely be a good solution for training. Since I do not want to loose any samples at inference, I just duplicated the last sample to fill up the batch and later on removed it again :).
I'll close the issue since my initial problem is fixed with torch fx. Thanks for your help!
from optimum.
Related Issues (20)
- Support for Florence 2 model HOT 3
- ONNX support for OneFormer Semantic Segmentation Task HOT 2
- Wrong output from ONNX speculative decoding (assistant_model) HOT 1
- is_cupy_available() can't find CuPy wheel distributions
- request support for transformers4.42 HOT 1
- Slow packing times for GPTQ HOT 1
- Adding Support For Phi Models HOT 4
- ValueError: Trying to export a florence2 model
- how can I get a onnx format int4 model?
- TypeError: _unmask_unattended_patched() missing 1 required positional argument: 'unmasked_value' during ONNX export LLaMa HOT 3
- Export AWQ models to ONNX HOT 1
- Qwen2 cannot be supported
- OPTIMUM Onnx Exporter for openai/clip-vit-large-patch14 model HOT 7
- Adding Support For Florence2 Model HOT 1
- GPTQ Quantization Need `use_marlin` HOT 1
- Latest Optimum library does not compatible with latest Transformers HOT 1
- Convert to onnx missing safety_checker
- Whisper-large-v3 transcript is trimmed HOT 4
- UMT5 & ByT5 Support
- Unexpected arguments `trust_remote_code` when exporting model to onnx with option `--library sentence_transformers` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optimum.