{"record":{"id":"c5ce63955fa99ff4","repo":"binary-husky/gpt_academic","slug":"error-c5ce63","errorCode":null,"errorMessage":"程序终止。","messagePattern":"程序终止。","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_jittorllms_rwkv.py","lineNumber":136,"sourceCode":"        if len(observe_window) >= 1: observe_window[0] = load_message + \"\\n\\n\" + rwkv_glm_handle.info\n        if not rwkv_glm_handle.success:\n            error = rwkv_glm_handle.info\n            rwkv_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 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']):\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 rwkv_glm_handle\n    if rwkv_glm_handle is None:\n        rwkv_glm_handle = GetGLMHandle()\n        chatbot[-1] = (inputs, load_message + \"\\n\\n\" + rwkv_glm_handle.info)\n        yield from update_ui(chatbot=chatbot, history=[])\n        if not rwkv_glm_handle.success:\n            rwkv_glm_handle = None","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_jittorllms_rwkv.py#L118-L154","documentation":"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.","triggerScenarios":"Local RWKV generation stalls >5s between yields — CPU inference, big context prefill, cold model, or the loader subprocess hung/died mid-stream.","commonSituations":"CPU-only device, GPU OOM killing the child, first generation after load (warm-up), system under load.","solutions":["Verify the RWKV child process is alive; check stderr/OOM messages.","Raise watch_dog_patience to >=60s or refresh observe_window[1] each yield.","Use GPU/quantized weights to reduce inter-token latency.","Recreate the handle (restart) if the subprocess is dead — the global handle caches a broken streamer."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import time\nwindow = ['', time.time()]\n# refresh window[1] per poll; set patience per hardware","typeGuard":null,"tryCatchPattern":"try:\n    resp = rwkv_predict_no_ui_long_connection(..., observe_window=window)\nexcept RuntimeError as e:\n    if '程序终止' in str(e):\n        window[1] = time.time()\n        resp = rwkv_predict_no_ui_long_connection(..., observe_window=window)","preventionTips":["watch_dog_patience >= 60s on CPU","Watch child stderr for OOM","Warm up model before timing-sensitive streams"],"tags":["jittorllms","rwkv","watchdog","timeout","local-model"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}