{"record":{"id":"0b42c7720443b015","repo":"sgl-project/sglang","slug":"load-path-is-required-for-sta-inference-mode","errorCode":null,"errorMessage":"load_path is required for STA_inference mode","messagePattern":"load_path is required for STA_inference mode","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/attention/STA_configuration.py","lineNumber":239,"sourceCode":"        print(\"\\nStrategy usage counts:\")\n        total_heads = time_step_num * layer_num * head_num  # Fixed dimensions\n        for strategy, count in strategy_counts.items():\n            print(f\"Strategy {strategy}: {count} heads ({count/total_heads*100:.2f}%)\")\n\n        # Convert dictionary to 3D list with fixed dimensions\n        mask_strategy_3d = dict_to_3d_list(\n            mask_strategy, t_max=time_step_num, l_max=layer_num, h_max=head_num\n        )\n\n        return mask_strategy_3d\n\n    else:  # STA_inference\n        # Get parameters with defaults\n        load_path: str | None = kwargs.get(\n            \"load_path\", \"mask_candidates/mask_strategy.json\"\n        )\n        if load_path is None:\n            raise ValueError(\"load_path is required for STA_inference mode\")\n\n        # Load previously saved mask strategy\n        with open(load_path) as f:\n            mask_strategy = json.load(f)\n\n        # Convert dictionary to 3D list with fixed dimensions\n        mask_strategy_3d = dict_to_3d_list(\n            mask_strategy, t_max=time_step_num, l_max=layer_num, h_max=head_num\n        )\n\n        return mask_strategy_3d\n\n\n# Helper functions\n\n\ndef read_specific_json_files(folder_path: str) -> list[dict[str, Any]]:\n    \"\"\"Read and parse JSON files containing mask search results.\"\"\"","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/attention/STA_configuration.py#L221-L257","documentation":"In STA_inference mode configure_sta loads a previously tuned mask strategy from load_path (default 'mask_candidates/mask_strategy.json'). Only an explicit None (kwargs['load_path']=None) triggers this error, since the default kicks in when the key is absent. After the check it open()s the file, so a bad path will instead raise FileNotFoundError.","triggerScenarios":"Calling configure_sta(mode='STA_inference') or any non-tuning mode with load_path explicitly set to None in kwargs. Merely omitting load_path uses the default 'mask_candidates/mask_strategy.json' and does not raise this.","commonSituations":"A config loader that reads load_path from a YAML/JSON config where the field is absent and null is forwarded verbatim; or code that conditionally builds kwargs and passes load_path=None when the user gave no value.","solutions":["Pass a real path: load_path='<path to mask_strategy.json produced by a tuning run>'","If the field is optional in your config, only include load_path in kwargs when it is non-null (don't pass None)","Run the STA_tuning / STA_tuning_cfg mode first to generate mask_strategy.json, then point load_path at it"],"exampleFix":"# before\nconfigure_sta(mode=\"STA_inference\", load_path=cfg.get(\"load_path\"))  # cfg lacks the key -> None\n# after\nkwargs = {\"load_path\": cfg[\"load_path\"]} if cfg.get(\"load_path\") else {}\nconfigure_sta(mode=\"STA_inference\", **kwargs)","handlingStrategy":"validation","validationCode":"lp = cfg.get(\"load_path\")\nsta_kwargs = {\"load_path\": lp} if lp else {}\nconfigure_sta(mode=\"STA_inference\", **sta_kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never forward load_path=None explicitly; omit the key instead","Wrap the subsequent open(load_path) in try/except FileNotFoundError to give a clearer message"],"tags":["sta","attention","sparse-tuning","kwargs-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}