binary-husky/gpt_academic · error · RuntimeError

程序终止。

Error message

程序终止。

What it means

Watchdog abort for the PanGu-Alpha stream: inside the loop over pangu_glm_handle.stream_chat, if time.time() - observe_window[1] exceeds watch_dog_patience (5s) between yields, RuntimeError('程序终止。') ends generation. Local JittorLLMs inference frequently exceeds 5s between tokens on CPU or long prefills.

Solutions

  1. Check the JittorLLMs child process is alive and its stderr for crashes/OOM.
  2. Increase watch_dog_patience (>=60s for CPU) or update observe_window[1] per yield.
  3. Move to GPU / smaller model to keep inter-token latency low.
  4. Restart the app to recreate a hung handle if the subprocess is dead.
Defensive patterns

Strategy: retry

Validate before calling

import time
window = ['', time.time()]
# refresh window[1] each poll; keep patience >= worst-case inter-token gap

Try / catch

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

Prevention

When it happens

Trigger: PanGu local generation stalls >5s (CPU inference, long prompt prefill, cold loader, or the child process hung/crashed mid-stream).

Common situations: CPU-only device, GPU busy/OOM, subprocess died silently so the generator never yields again, heavily loaded machine.

Related errors


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

Appendix: source

Thrown at request_llms/bridge_jittorllms_pangualpha.py:136

        if len(observe_window) >= 1: observe_window[0] = load_message + "\n\n" + pangu_glm_handle.info
        if not pangu_glm_handle.success:
            error = pangu_glm_handle.info
            pangu_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 pangu_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 pangu_glm_handle
    if pangu_glm_handle is None:
        pangu_glm_handle = GetGLMHandle()
        chatbot[-1] = (inputs, load_message + "\n\n" + pangu_glm_handle.info)
        yield from update_ui(chatbot=chatbot, history=[])
        if not pangu_glm_handle.success:
            pangu_glm_handle = None

View on GitHub (pinned to d6bde0fa54)