{"record":{"id":"f83db06e4f596337","repo":"binary-husky/gpt_academic","slug":"moss","errorCode":null,"errorMessage":"不能正常加载MOSS的参数！","messagePattern":"不能正常加载MOSS的参数！","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"request_llms/bridge_moss.py","lineNumber":119,"sourceCode":"        \"\"\"\n        self.prompt = self.meta_instruction\n        self.local_history = []\n\n    def run(self): # 子进程执行\n        # 子进程执行\n        # 第一次运行，加载参数\n        def validate_path():\n            import os, sys\n            root_dir_assume = os.path.abspath(os.path.dirname(__file__) +  '/..')\n            os.chdir(root_dir_assume + '/request_llms/moss')\n            sys.path.append(root_dir_assume + '/request_llms/moss')\n        validate_path() # validate path so you can run from base directory\n\n        try:\n            self.moss_init()\n        except:\n            self.child.send('[Local Message] Call MOSS fail 不能正常加载MOSS的参数。')\n            raise RuntimeError(\"不能正常加载MOSS的参数！\")\n\n        # 进入任务等待状态\n        # 这段代码来源 https://github.com/OpenLMLab/MOSS/blob/main/moss_cli_demo.py\n        import torch\n        while True:\n            # 等待输入\n            kwargs = self.child.recv()   # query = input(\"<|Human|>: \")\n            try:\n                query = kwargs['query']\n                history = kwargs['history']\n                sys_prompt = kwargs['sys_prompt']\n                if len(self.local_history) > 0 and len(history)==0:\n                    self.prompt = self.meta_instruction\n                self.local_history.append(query)\n                self.prompt += '<|Human|>: ' + query + '<eoh>'\n                inputs = self.tokenizer(self.prompt, return_tensors=\"pt\")\n                with torch.no_grad():\n                    outputs = self.model.generate(","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_moss.py#L101-L137","documentation":"Raised in the MOSS loader thread when self.moss_init() throws: the code first validate_path()s into request_llms/moss, then the bare except sends '[Local Message] Call MOSS fail' to the parent and raises RuntimeError('不能正常加载MOSS的参数！'). Root causes (missing weights, transformers version mismatch, CUDA OOM) are discarded.","triggerScenarios":"First use of the local MOSS model: moss_init fails to load the MOSS weights/config (missing moss-github checkout, failed download, transformers or torch version incompatible, insufficient GPU memory).","commonSituations":"Fresh clone without the MOSS model files, old transformers version incompatible with MOSS modeling code, LOCAL_MODEL_DEVICE=cuda on a CPU box, GPU with too little VRAM.","solutions":["Reproduce outside the thread: chdir to request_llms/moss and call the same moss_init logic to see the real traceback.","Fetch the MOSS weights/config exactly as request_llms/bridge_moss.py documents and pin the required transformers/torch versions.","Check GPU memory and LOCAL_MODEL_DEVICE; MOSS needs tens of GB VRAM (or quantization).","MOSS is unmaintained — prefer a maintained local backend if it cannot load."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def moss_loadable() -> bool:\n    import os\n    return os.path.isdir(os.path.join(ROOT, 'request_llms', 'moss'))  # weights dir present\n# gate the MOSS entry on moss_loadable() plus a dry import of moss_init deps","typeGuard":null,"tryCatchPattern":"try:\n    handle = GetGLMHandle()\nexcept RuntimeError as e:\n    if 'MOSS' in str(e):\n        log.error('MOSS load failed: %s', e)","preventionTips":["Pre-download MOSS weights; pin transformers/torch versions","Verify VRAM fits MOSS before selecting it","Smoke-test moss_init standalone at startup"],"tags":["moss","local-model","startup","model-loading"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}