{"record":{"id":"6929917ceb234200","repo":"binary-husky/gpt_academic","slug":"error-692991","errorCode":null,"errorMessage":"程序终止。","messagePattern":"程序终止。","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_jittorllms_pangualpha.py","lineNumber":136,"sourceCode":"        if len(observe_window) >= 1: observe_window[0] = load_message + \"\\n\\n\" + pangu_glm_handle.info\n        if not pangu_glm_handle.success:\n            error = pangu_glm_handle.info\n            pangu_glm_handle = None\n            raise RuntimeError(error)\n\n    # jittorllms 没有 sys_prompt 接口，因此把prompt加入 history\n    history_feedin = []\n    for i in range(len(history)//2):\n        history_feedin.append([history[2*i], history[2*i+1]] )\n\n    watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可\n    response = \"\"\n    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']):\n        print(response)\n        if len(observe_window) >= 1:  observe_window[0] = response\n        if len(observe_window) >= 2:\n            if (time.time()-observe_window[1]) > watch_dog_patience:\n                raise RuntimeError(\"程序终止。\")\n    return response\n\n\n\ndef predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):\n    \"\"\"\n        单线程方法\n        函数的说明请见 request_llms/bridge_all.py\n    \"\"\"\n    chatbot.append((inputs, \"\"))\n\n    global pangu_glm_handle\n    if pangu_glm_handle is None:\n        pangu_glm_handle = GetGLMHandle()\n        chatbot[-1] = (inputs, load_message + \"\\n\\n\" + pangu_glm_handle.info)\n        yield from update_ui(chatbot=chatbot, history=[])\n        if not pangu_glm_handle.success:\n            pangu_glm_handle = None","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_jittorllms_pangualpha.py#L118-L154","documentation":"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.","triggerScenarios":"PanGu local generation stalls >5s (CPU inference, long prompt prefill, cold loader, or the child process hung/crashed mid-stream).","commonSituations":"CPU-only device, GPU busy/OOM, subprocess died silently so the generator never yields again, heavily loaded machine.","solutions":["Check the JittorLLMs child process is alive and its stderr for crashes/OOM.","Increase watch_dog_patience (>=60s for CPU) or update observe_window[1] per yield.","Move to GPU / smaller model to keep inter-token latency low.","Restart the app to recreate a hung handle if the subprocess is dead."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import time\nwindow = ['', time.time()]\n# refresh window[1] each poll; keep patience >= worst-case inter-token gap","typeGuard":null,"tryCatchPattern":"try:\n    resp = pangu_predict_no_ui_long_connection(..., observe_window=window)\nexcept RuntimeError as e:\n    if '程序终止' in str(e):\n        window[1] = time.time()\n        resp = pangu_predict_no_ui_long_connection(..., observe_window=window)","preventionTips":["watch_dog_patience >= 60s on CPU","Verify GPU free memory before long sessions","Restart the app to rebuild a hung handle"],"tags":["jittorllms","pangualpha","watchdog","timeout","local-model"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}