binary-husky/gpt_academic · error · RuntimeError

程序终止。

Error message

程序终止。

What it means

Watchdog abort for the ChatRWKV stream: if more than watch_dog_patience (5s) passes between yields of rwkv_glm_handle.stream_chat, the loop raises RuntimeError('程序终止。'). JittorLLMs RWKV on CPU or during long prefills routinely exceeds 5s between token yields.

Source

Thrown at request_llms/bridge_jittorllms_rwkv.py:136

        if len(observe_window) >= 1: observe_window[0] = load_message + "\n\n" + rwkv_glm_handle.info
        if not rwkv_glm_handle.success:
            error = rwkv_glm_handle.info
            rwkv_glm_handle = None
            raise RuntimeError(error)

    # jittorllms 没有 sys_prompt 接口,因此把prompt加入 history
    history_feedin = []
    for i in range(len(history)//2):
        history_feedin.append([history[2*i], history[2*i+1]] )

    watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
    response = ""
    for response in rwkv_glm_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=sys_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
        print(response)
        if len(observe_window) >= 1:  observe_window[0] = response
        if len(observe_window) >= 2:
            if (time.time()-observe_window[1]) > watch_dog_patience:
                raise RuntimeError("程序终止。")
    return response



def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):
    """
        单线程方法
        函数的说明请见 request_llms/bridge_all.py
    """
    chatbot.append((inputs, ""))

    global rwkv_glm_handle
    if rwkv_glm_handle is None:
        rwkv_glm_handle = GetGLMHandle()
        chatbot[-1] = (inputs, load_message + "\n\n" + rwkv_glm_handle.info)
        yield from update_ui(chatbot=chatbot, history=[])
        if not rwkv_glm_handle.success:
            rwkv_glm_handle = None

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Verify the RWKV child process is alive; check stderr/OOM messages.
  2. Raise watch_dog_patience to >=60s or refresh observe_window[1] each yield.
  3. Use GPU/quantized weights to reduce inter-token latency.
  4. Recreate the handle (restart) if the subprocess is dead — the global handle caches a broken streamer.
Defensive patterns

Strategy: retry

Validate before calling

import time
window = ['', time.time()]
# refresh window[1] per poll; set patience per hardware

Try / catch

try:
    resp = rwkv_predict_no_ui_long_connection(..., observe_window=window)
except RuntimeError as e:
    if '程序终止' in str(e):
        window[1] = time.time()
        resp = rwkv_predict_no_ui_long_connection(..., observe_window=window)

Prevention

When it happens

Trigger: Local RWKV generation stalls >5s between yields — CPU inference, big context prefill, cold model, or the loader subprocess hung/died mid-stream.

Common situations: CPU-only device, GPU OOM killing the child, first generation after load (warm-up), system under load.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/c5ce63955fa99ff4. Report an issue: GitHub.