{"record":{"id":"b93f6754d15d214a","repo":"fishaudio/fish-speech","slug":"invalid-quantization-mode-mode-needs-to-be-one-o","errorCode":null,"errorMessage":"Invalid quantization mode {mode} needs to be one of [int8, int4, int4-gpptq]","messagePattern":"Invalid quantization mode (.+?) needs to be one of \\[int8, int4, int4-gpptq\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/llama/quantize.py","lineNumber":486,"sourceCode":"            (dst_name / vq_model).unlink()\n        quantize_path = dst_name / \"model.pth\"\n\n    elif mode == \"int4\":\n        print(\n            \"Quantizing model weights for int4 weight-only affine per-channel groupwise quantization\"\n        )\n        quant_handler = WeightOnlyInt4QuantHandler(model, groupsize)\n        quantized_state_dict = quant_handler.create_quantized_state_dict()\n\n        dir_name = checkpoint_path\n        dst_name = Path(f\"checkpoints/fs-1.2-int4-g{groupsize}-{now}\")\n        shutil.copytree(str(dir_name.resolve()), str(dst_name.resolve()))\n        if (dst_name / vq_model).exists():\n            (dst_name / vq_model).unlink()\n        quantize_path = dst_name / \"model.pth\"\n\n    else:\n        raise ValueError(\n            f\"Invalid quantization mode {mode} needs to be one of [int8, int4, int4-gpptq]\"\n        )\n\n    print(f\"Writing quantized weights to {quantize_path}\")\n    quantize_path.unlink(missing_ok=True)  # remove existing file if one already there\n    torch.save(quantized_state_dict, quantize_path)\n    print(f\"Quantization complete took {time.time() - t0:.02f} seconds\")\n\n\nif __name__ == \"__main__\":\n    quantize()\n","sourceCodeStart":468,"sourceCodeEnd":498,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/tools/llama/quantize.py#L468-L498","documentation":"tools/llama/quantize.py supports only the modes int8, int4, and int4-gpptq; any other --mode value falls through to ValueError before weights are written.","triggerScenarios":"Running quantize.py --mode int8x or --mode q4f16 etc. — any string outside the supported set.","commonSituations":"Typos, or assuming a quantization format from other tools (GGUF, AWQ) is supported here; outdated docs naming different modes.","solutions":["Use one of: int8, int4, int4-gpptq","Check `python tools/llama/quantize.py --help` in your checkout for the currently supported list","Update fish-speech if you need a mode added in newer versions"],"exampleFix":"# before\npython tools/llama/quantize.py ... --mode int4_gptq\n# after\npython tools/llama/quantize.py ... --mode int4-gpptq","handlingStrategy":"validation","validationCode":"assert mode in {\"int8\", \"int4\", \"int4-gpptq\"}, f\"unsupported mode: {mode}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enum-validate CLI modes before running","Read --help for the installed version"],"tags":["quantization","cli","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}