question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data-Aware Calibration

See original GitHub issue

The current calibration algorithm use global_scale to estimate the scale of intermediate result, which is configured by user. For better accuracy loss, we need to implement data-aware calibration algorithm: given a small calibration dataset (like 100 samples), to achieve better scale estimation.

Implementation

Collecting Intermediate Results

To collect intermediate results of every operation in the graph, we may need to implement a Visitor to return every Call as output. The API would be: stats = collect_stats(graph, data)

Modification for SimulatedQuantize

It is kinds of hard to save the mapping from origin operator to the operator after annotation. So we may need to add an option for simulated_quantize, like mode='origin', which denotes that sq will not simulate the rounding error/saturated error, instead, just return the input directly. With this, we can collect the intermediate result of the original graph.

Calibration Procedure

Having the calibration data, we can adjust the scale according to the output of the annotated graph. It is actually an optimization problem. The target can be the KL divergence between outputs of original graph and annotated graph, and the adjustment method can be simply search-based or learning-based. There should be lots of room for exploration.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
eqycommented, Feb 22, 2019

I am very interested in this problem, and I have a few different approaches I want to try out. However, I wonder if requiring intermediate results to be collected is too labor intensive or unnecessary. In the AutoTVM setting, we use domain specific features as they are powerful and allow for transfer learning. However, transfer learning is not as important in this setting, and it could be that blackbox features (e.g., just the scale configuration) may be enough to build a usable machine learning model (just as knob features are usable in AutoTVM). I think if that turns out to already work then we can save a significant amount of effort. It seems slightly expensive to compute both the original graph and annotated graph every time we want to do try a different calibration configuration, so I think it would be great if we could get away with doing even less work 😃.

I’ll send updates on this approach as I get results. You may have already guessed that performance is important as I am first tuning the workloads required for quantization so trying many calibration configurations is not too slow.

0reactions
tqchencommented, Oct 8, 2019

closed by #3538 let us open new thread for tutorials

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorials on data-aware quantization calibration? - Questions
... Data-aware calibration needs to find min/max values of accumulators and pass this info from relay down to code generation (what is the...
Read more >
Data-Aware Calibration · Issue #2651 · apache/tvm - GitHub
The current calibration algorithm use global_scale to estimate the scale of intermediate result, which is configured by user.
Read more >
How to: Customize the GridControl's Data-Aware Export Output
CustomizeSheetSettings event is handled to specify export settings. The ExportContext.SetFixedHeader event method is used to anchor the output ...
Read more >
MVC 5 DevExpress settings.BeforeExport event is not fired
I have a fully working GridView using DevExpress with MVC 5 . I would like to add the possibility to export the data...
Read more >
Data Aware Grid Channels - BBj - Documentation
For this topic's original documentation, see Data Aware Grid Channels. As of BBj 4.0, data aware grids can manipulate OEM-formatted or Julian dates...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found