--op_compiler_cache_mode
Description
Enables disk cache for operator build.
See Also
To specify the disk cache path for operator build, use the --op_compiler_cache_dir option.
Argument
Argument:
- enable: enabled. If it is enabled, operators with the same build configurations and operator configurations will not be built repeatedly, thus accelerating the build speed.
- force: Enabled with cache forcibly refreshed. That is, the existing cache is cleared up before the operator is recompiled and added to the cache. For example, for Python changes, dependency library changes, or repository changes after operator optimization, you need to set this option to force to clear up the existing cache and then change it to enable to prevent the cache from being forcibly refreshed during each build.
- disable (default): disabled.
Restrictions:
- If this option is set to force, the existing cache will be cleared. Therefore, it is not recommended for parallel program compilation. Otherwise, the cache used by other models may be cleared, causing build failures.
- disable and force are recommended for publishing the final model.
- If the repository changes after operator tuning, set this option to force to refresh the cache. Otherwise, the new tuning repository cannot be applied, and the tuning application fails to be executed.
- When the debug function is enabled:
- If --op_debug_level is set to a non-zero value, the --op_compiler_cache_mode parameter configuration does not take effect, the operator build cache function is disabled, and all operators are recompiled.
- If --op_debug_config is not empty and op_debug_list is not configured, the --op_compiler_cache_mode parameter configuration does not take effect, the operator build cache function is disabled, and all operators are recompiled.
- If --op_debug_config is not empty and op_debug_list is configured in the configuration file:
- For operators in the list, ignore the configuration of ge.op_compiler_cache_mode and continue to recompile them.
- For operators out of the list, if --op_compiler_cache_mode is set to enable or force, the cache function is enabled. If --op_compiler_cache_mode is set to disable, the cache function is disabled and the operators are recompiled.
Suggestions and Benefits
If this option is set to enable (recommended), operators with the same build configurations and operator configurations will not be built repeatedly, thus accelerating the build speed.
Example
--op_compiler_cache_mode=enable --op_compiler_cache_dir=$HOME/atc_data/kernel_cache --op_debug_level=0
Applicability
Restrictions
When you enable the operator build cache function, you can set the disk space of the cache folder with the configuration file (the op_cache.ini configuration file automatically generated in the path specified by --op_compiler_cache_dir after the ATC tool runs) or environment variables.
- Using the op_cache.ini configuration file:
If the op_cache.ini file does not exist, manually create it. Open the file and add the following information:
# Configure the file format (required). The automatically generated file contains the following information by default. When manually creating a file, enter the following information: [op_compiler_cache] # Limit the drive space of the cache folder on a chip. The value must be an integer, in MB. max_op_cache_size=500 # Set the ratio of the cache size to be reserved. The value range is [1,100], in percentage. For example, 80 indicates that when the cache space is insufficient, 80% of the cache space is reserved and the rest is cleared up. remain_cache_size_ratio=80
- The op_cache.ini file takes effect only when the values of max_op_cache_size and remain_cache_size_ratio in the preceding file are valid.
- If the size of the build cache file exceeds the value of max_op_cache_size and the cache file is not accessed for more than half an hour, the cache file will be aged. (Operator build will not be interrupted due to the size of the build cache file exceeding the set limit. Therefore, if max_op_cache_size is set to a small value, the size of the actual build cache file may exceed the configured value.)
- To disable the build cache aging function, set max_op_cache_size to -1. In this case, the access time is not updated when the operator cache is accessed, the operator build cache is not aged, and the default drive space is 500 MB.
- If multiple users use the same cache path, you are advised to use the configuration file to set the cache path. In this scenario, the op_cache.ini file affects all users.
- Using environment variables
In this scenario, the environment variable ASCEND_MAX_OP_CACHE_SIZE is used to limit the storage space of the cache folder of a chip. When the build cache space reaches the specified value and the cache file is not accessed for more than half an hour, the cache file is aged. The environment variable ASCEND_REMAIN_CACHE_SIZE_RATIO is used to set the ratio of the cache space to be reserved.
A configuration example is provided as follows:
# The ASCEND_MAX_OP_CACHE_SIZE environment variable defaults to 500, in MB. The value must be an integer. export ASCEND_MAX_OP_CACHE_SIZE=500 # ASCEND_REMAIN_CACHE_SIZE_RATIO environment variable value range is [1,100]. The default value is 50, in percentage. For example, 80 indicates that 80% of the cache space is reserved when the cache space is insufficient. export ASCEND_REMAIN_CACHE_SIZE_RATIO=50
- The argument configured through environment variables takes effect only for the current user.
- To disable the build cache aging function, set the environment variable ASCEND_MAX_OP_CACHE_SIZE to -1. In this case, the access time is not updated when the operator cache is accessed, the operator build cache is not aged, and the default drive space is 500 MB.
Caution: If both the op_cache.ini file and environment variable are configured, the configuration items in the op_cache.ini file are read first. If neither the op_cache.ini file nor the environment variable are configured, the system default values are read: 500 MB disk space and 50% reserved cache space.