diff --git a/clore_onboarding.py b/clore_onboarding.py index 112dd9f..7300e59 100644 --- a/clore_onboarding.py +++ b/clore_onboarding.py @@ -194,6 +194,21 @@ async def async_read_file(path): except Exception as e: #print(f"Error reading file {path}: {e}") return None + +def extract_last_setcore_setmem(input_string): + try: + setcore_pattern = r'--setcore\s+((?:\d+\s*)+)(?=\D|$)' + setmem_pattern = r'--setmem\s+((?:\d+\s*)+)(?=\D|$)' + + setcore_matches = re.findall(setcore_pattern, input_string) + setmem_matches = re.findall(setmem_pattern, input_string) + + last_setcore = [int(num) for num in setcore_matches[-1].split()] if setcore_matches else [] + last_setmem = [int(num) for num in setmem_matches[-1].split()] if setmem_matches else [] + + return last_setcore, last_setmem + except Exception as e: + return [[], []] async def hive_parse_config(file_content): conf = {} @@ -228,7 +243,10 @@ async def hive_load_configs(default_power_limits, static_config): # Parse wallet config clore_config = None get_oc_config = False + fs_mem_lock = [] + fs_core_lock = [] if wallet_conf_content: + fs_core_lock, fs_mem_lock = extract_last_setcore_setmem(wallet_conf_content) for wallet_conf_line in wallet_conf_content.split('\n'): wallet_conf_line = wallet_conf_line.strip() if wallet_conf_line[:1] != "#" and '=' in wallet_conf_line: @@ -259,6 +277,8 @@ async def hive_load_configs(default_power_limits, static_config): try: core_offset = None mem_offset = None + core_lock = None + mem_lock = None pl_static = None for nvidia_conf_line in nvidia_oc.split('\n'): nvidia_conf_line = nvidia_conf_line.strip() @@ -272,14 +292,30 @@ async def hive_load_configs(default_power_limits, static_config): mem_offset = [math.floor(num / 2) for num in validate_and_convert(value, -2000, 6000, adjust_bounds=True)] elif key=="PLIMIT": pl_static = validate_and_convert(value, 1, 1500, adjust_bounds=True) + elif key=="LCLOCK": + core_lock = validate_and_convert(value, 0, 12000, adjust_bounds=True) + elif key=="LMEM": + mem_lock = validate_and_convert(value, 0, 32000, adjust_bounds=True) - if core_offset or mem_offset or pl_static: + if len(fs_mem_lock)>0: + mem_lock = fs_mem_lock + if len(fs_core_lock)>0: + core_lock = fs_core_lock + + #print(mem_lock, core_lock) + + if core_offset or mem_offset or pl_static or mem_lock or core_lock: for gpu_idx, default_pl in enumerate(default_power_limits): out_oc_config[str(gpu_idx)] = { "core": get_number_or_last(core_offset, gpu_idx) if core_offset else 0, "mem": get_number_or_last(mem_offset, gpu_idx) if mem_offset else 0, "pl": get_number_or_last(pl_static, gpu_idx) if pl_static else default_pl } + if type(core_lock)==list and len(core_lock)>0: + out_oc_config[str(gpu_idx)]["core_lock"] = get_number_or_last(core_lock, gpu_idx) + if type(mem_lock)==list and len(mem_lock)>0: + out_oc_config[str(gpu_idx)]["mem_lock"] = get_number_or_last(mem_lock, gpu_idx) + except Exception as oc_info_e: pass