QDQ loss debug - Weights Matching
Part 2 of QDQ loss debugging tool: given a float model and its qdq model, return the matching of all weight tensors and their corresponding dequantized weights from the qdq model.
LLVM compiler complains the std::hash<const char*> and suggests std::hash<const void*>. But the intention is to hash the name string instead of the pointer. So use std::hash<std::string> to be explicit.
* add AddBiasTranspose kernel, new format of weights
* Use compact global_q in GEMM
* sequence_index from BxS to S; new stream for copy
* merge input and output pointers in scratch2
* update default benchmark tests
* add new format 0 for weight and bias
* avoid integer overflow
* check gpu memory
* output summary in benchmark
* add logging
* update unit tests with non empty bias value
* add rocblasGemmHelper and rocblasGemmStridedBatchedHelper for Rocm
* use std::variant for synthetic data storage.
* use std::variant to replace TypedCheckpointProperty
* Remvoe shared ptr for checkpoint property
* fix tests
* refine std::variant usage a bit
* remove CheckpointProperty data abstraction
* use InlinedVector and InlinedHashMap if possible
* fix comments
* fix build and test
* fix some comments
* use gsl::span
* fix tests
* refine based on comments
* fix win build
* fix build
* Add build option to link prebuilt TensorRT parser
* Test without the build option to link prebuilt TRTParser
* Minor: update name of build option
* Minor: update name of build option
Debugger for QDQ loss - activation matching
This is the first part of the QDQ debugger tool: activation matching, where we identify and match corresponding activations from the float model and the qdq model. The idea is that during quantization, we have an original float model and a qdq model. The debugger can run the two models side by side using the same input data. By comparing intermediate activations, we can help the model author figure out where the values differ, and take steps to reduce precision loss.
* uint8 support
Signed-off-by: Kevin Chen <kevinch@nvidia.com>
* Handle outputs as well
Signed-off-by: Kevin Chen <kevinch@nvidia.com>
Signed-off-by: Kevin Chen <kevinch@nvidia.com>
* Add ability to use ORT format model flatbuffer directly for intiializers by leveraging the TensorProto external data infrastructure.
Requires user to provide ORT format model bytes when creating the session, and set both `session.use_ort_model_bytes_directly` and `session.use_ort_model_bytes_for_initializers` to 1 in SessionOptions config entries (AddSessionConfigEntry in C API).
* [ROCm] Add FusedConv Op.
* Enable ROCm for FusedConvTest
* [ROCm] Implement FusedConv Op. with Fusion API
The old code path was left as the fallback since some combinations are
not supported (e.g., FusedConvTest.Conv2D_Bias_Z_Relu as of ROCM 5.1,
where to bias layers are needed).
* [ROCM] Suppress duplicated warnings in unsupported Fusion API usage.
Know limitation for current MIOpen (verified with ROCM 5.2): Only one
bias layer may present in the Fusion Plan. Adding the second bias
operation to the Fusion plan will end up with miopenStatusUnsupportedOp.
In this case the fallback code path will be taken to complete required
FusedConv operation.
However, previously this failure was not detected and cached, and
applications that create multiple FusedConv Ops with both z and bias
will keep printing error messages, which is annoying to end users
while this message is mainly for developers.
This commit will let it print the first error message as a reminder, and
skip the Fusion API code path in following calls if both z and bias
present. (Note: the skipping applies to all newly created FusedConv Ops).
* [ROCM] Add cache mechanism for FusedConv Op.
Now the operator with the same configuration will share the same Fusion
Plan object, and the creation result will also be cached.
Two benefits:
1. No duplicated Fusion plan creation, which is a presumably very costly
process.
2. Failures due to MIOpen limitations (like z and b cannot present at
the same time) will only be triggered once.
Know limits:
Due to the limitation of MIOpen Interface, the tensor order of the
convolution operator can only be guessed.
* [ROCm] enable NGramRepeatBlock Op
* [ROCm] Enable testing ROCm in NGramRepeatBlockTest.NGramSize_3
Also link onnxruntime_test_all with amdhip64 when USE_ROCM=1
* [ROCm] add LongformerAttention Op
* [ROCm] Enable LongformerAttentionTest
* [ROCm] Add DecoderAttention Op
* Enable DecoderAttention Test for ROCm.
* [ROCM] Updates according to reviews
* enable PythonOp by default when --enable_training_torch_interop is enabled during build
* clean up
* fix
* fix comment
* fix
* fix tests
* fix fallback test
* pylint format
* refine based on comments
Fix minor bug in qdq quantization tool
Motivation and Context
Relu node is removed in qdq quantization tool if it can be merged to its input node. When performing the removal, we forgot to check whether the input is actually the graph input
Python module for dumping activation tensors when running an ONNX model
This is the first step towards a quantization debugging tool. We dump the activation tensors. Next step would be to compare them: original model vs quantized model (running with same input) to see where the difference becomes significant.
* Load checkpoint in cpp
* removed unused imports
* throw error on invalid name and change function name
* inplace model assignment, change name and other comments resolved
* name change on import
* Addded unit test, resolved comments
* remove unused imports
* resolved comments
* refactoring too reduce memoory allocation
* resolved extra comments
* changed files hierarchy an force added onnx moodel
* solved order of function argument
* used gtest macros on test cases
Co-authored-by: Adam Louly <adamlouly@microsoft.com@orttrainingdev7.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net>