콘텐츠로 이동

qubee.configs.llm_config

LlmConfig

class LlmConfig(ConfigABC)

Configuration for Large Language Model (LLM) compilation.

Attributes

Name Description
optional
DEFAULTS
py_to_cpp_name
min_max_check

optional

optional = True

DEFAULTS

DEFAULTS = {
    "llm_config_apply": False,
    "max_data_length": 4096,
    "max_sequence_length": 4096,
    "max_cache_length": 4096,
    "max_core_data_length": 128,
    "random_seq_length": 80,
    "use_full_seq_length": False,
    "use_custom_mask_input": False,
    "start_dram_offset": 0,
    "use_global_core": False,
    "batch_size": 1,
    "npu_core_ids": [0],
    "dynamic_rope": False,
}

py_to_cpp_name

py_to_cpp_name = {
    "llm_config_apply": "apply",
    "max_data_length": "maxDataLength",
    "max_sequence_length": "maxSequenceLength",
    "max_cache_length": "maxCacheLength",
    "max_core_data_length": "maxCoreDataLength",
    "random_seq_length": "randomSeqLength",
    "use_full_seq_length": "useFullSeqLength",
    "use_custom_mask_input": "useCustomMaskInput",
    "start_dram_offset": "startDramOffset",
    "use_global_core": "useGlobalCore",
    "batch_size": "batchSize",
    "dynamic_rope": "dynamicRope",
}

min_max_check

min_max_check = {
    "max_data_length": [0, None],
    "max_sequence_length": [0, None],
    "max_cache_length": [0, None],
    "max_core_data_length": [0, None],
    "random_seq_length": [0, None],
    "start_dram_offset": [0, None],
    "batch_size": [0, None],
}

Methods

Name Description
__init__ Initialize the LlmConfig:
default_config
from_kwargs
from_dict Create LlmConfig from dictionary (JSON structure)
to_dict

__init__

def __init__(
    self,
    llm_config_apply: bool,
    max_data_length: int,
    max_sequence_length: int,
    max_cache_length: int,
    max_core_data_length: int,
    random_seq_length: int,
    use_full_seq_length: bool,
    use_custom_mask_input: bool,
    start_dram_offset: int,
    use_global_core: bool,
    batch_size: int,
    npu_core_ids: List[int],
    dynamic_rope: bool,
    optional: bool = optional,
)

Initialize the LlmConfig:

Parameters

  • llm_config_apply — bool. If True, apply LLM-specific configurations.
  • max_data_length — int. Maximum data length.
  • max_sequence_length — int. Maximum sequence length.
  • max_cache_length — int. Maximum cache length.
  • max_core_data_length — int. Maximum core data length.
  • random_seq_length — int. Random sequence length used for calibration.
  • use_full_seq_length — bool. If True, use the full sequence length for calibration.
  • use_custom_mask_input — bool. If True, use a custom mask input.
  • start_dram_offset — int. Starting DRAM offset.
  • use_global_core — bool. If True, use a global core.
  • batch_size — int. Batch size.
  • npu_core_ids — List[int]. List of NPU core IDs.
  • dynamic_rope — bool. If True, enable dynamic RoPE.
  • optional — bool. Indicates whether this config is optional. Use the default value defined as a class variable.

default_config

def default_config(cls)

from_kwargs

def from_kwargs(cls, **kwargs)

from_dict

def from_dict(cls, config_dict: dict)

Create LlmConfig from dictionary (JSON structure)

to_dict

def to_dict(self)

Functions

Name Description
get_llm_config Create LlmConfig with partial parameters merged with defaults.

get_llm_config

def get_llm_config(**kwargs) -> LlmConfig

Create LlmConfig with partial parameters merged with defaults.