[AutoTVM] Find the default optimization configuration of the kernel

Hi, I’m trying to get the default schedule configuration for each kernel in tuner modules. e.g., [(‘tile_f’, [-1, 64, 1, 1]), (‘tile_y’, [-1, 1, 1, 7]), …]

I’m bit running out-of-time so I’m asking here to find any luck while looking into the code. Any advice or suggestion would be greatly appreciated. Thanks!

Hi,

I’m not fully sure whether I understood your questions correctly. If you are looking for the default schedule for a selected target, TVM fetches that from this repository during execution time and places a copy under /home/yourusername/.tvm/tophub/

Cheers, Robert

Thank you for the advice!

When looking into the autotuners (python/tvm/autotvm/tuner/), they generate a set of optimization configurations that they want to apply to the compilation of each kernel.
(If 1,000 trials are given, they will generate 1,000 configurations and pick the best one)

In this context, I’m wondering what is the default configuration is for each kernel. If default setting is not applying any optimization, I’m not sure how I can trigger compilation and measurement without any optimization inside the tuner module.

Thanks!

I see! That’s a very good question. I’m not sure to be honest. I wanted to look into it myself for measuring a performance baseline for each kernel before autotuning. I’ll look into it the next days when I have spare time. Please let me know if you have found something in the meanwhile…

It depends on the schedule function. For example:

  1. Directly define a default configuration.
  1. Load the best configurations of similar workloads and make a one.
1 Like

Thanks for the advice. This seems like a good start.

I’ve been playing around with auto-tuner module and thinking that we may utilize the performance of the default schedule during the tuning process.

2nd approach seems more relevant for my purpose. Rather than defining a default configuration by myself as the 1st approach, I want to measure the performance of the current default configuration in the tuner model.

Is fallback_with_reference_log the one I can use? I’m not sure since it does not return any configuration. (Seems like it applies directly to the kernel?)

As far as I know, I need a set of optimization configurations (config in the following code) for the default setting to trigger the measurement inside the tuner.

Thank you so much for the great advices!

Is fallback_with_reference_log the one I can use? I’m not sure since it does not return any configuration. (Seems like it applies directly to the kernel?)

Yes this is the one. It didn’t return because it is a method of a config entity. What it did was copying the config map from other config enrities to itself, such as https://github.com/apache/incubator-tvm/blob/master/python/tvm/autotvm/task/space.py#L1045.

In this case, you don’t need to run AutoTVM for the fallback config. When you build the model without calling apply_history_best, the fallback config will be used automatically.

Thank you for the help. Here’s what I’ve learned and found issues.

  • This is what I tried inside the my custom tuner.

      cfg = FallbackConfigEntity()
      func_name = self.task.name          // conv2d_nchw_winograd.cuda
      ref_log = autotvm.tophub.load_referernce_log( target.target_name, 
                                                    '1080ti', func_name)
      print(cfg)                          // Returns 'None'
    
  • Automatic device model selection in line 229 did not work for my case: when selecting alternative model, current code does not check whether it contains data for the workload and pick the wrong model. So, currently, I picked the valid model manually.

  • Is there any reason for FallbackConfigEntity to inherit ConfigSpace, not the ConfigEntity? In my code, cfg.fallback_with_reference_log updates cfg with reference configuration but since it is not a ConfigEntity object, tuner cannot handle this object. For example, index field does not exist with FallbackConfigEntity although it loads the best knobs from the reference. When I pass this object to the tuner, it complains the runtime error with error_no=4.