usage: ./llama-quantize [--allow-requantize] [--leave-output-tensor] [--pure] models/llama/ggml-model.gguf [models/llama/ggml-model-quant.gguf] type [nthreads]
| 111 | // ./llama-quantize [--allow-requantize] [--leave-output-tensor] [--pure] models/llama/ggml-model.gguf [models/llama/ggml-model-quant.gguf] type [nthreads] |
| 112 | // |
| 113 | [[noreturn]] |
| 114 | static void usage(const char * executable) { |
| 115 | printf("usage: %s [--help] [--allow-requantize] [--leave-output-tensor] [--pure] [--imatrix] [--include-weights] [--exclude-weights] [--output-tensor-type]\n", executable); |
| 116 | printf(" [--token-embedding-type] [--tensor-type] [--keep-split] [--override-kv] model-f32.gguf [model-quant.gguf] type [nthreads]\n\n"); |
| 117 | printf(" --allow-requantize: Allows requantizing tensors that have already been quantized. Warning: This can severely reduce quality compared to quantizing from 16bit or 32bit\n"); |
| 118 | printf(" --leave-output-tensor: Will leave output.weight un(re)quantized. Increases model size but may also increase quality, especially when requantizing\n"); |
| 119 | printf(" --pure: Disable k-quant mixtures and quantize all tensors to the same type\n"); |
| 120 | printf(" --imatrix file_name: use data in file_name as importance matrix for quant optimizations\n"); |
| 121 | printf(" --include-weights tensor_name: use importance matrix for this/these tensor(s)\n"); |
| 122 | printf(" --exclude-weights tensor_name: use importance matrix for this/these tensor(s)\n"); |
| 123 | printf(" --output-tensor-type ggml_type: use this ggml_type for the output.weight tensor\n"); |
| 124 | printf(" --token-embedding-type ggml_type: use this ggml_type for the token embeddings tensor\n"); |
| 125 | printf(" --tensor-type TENSOR=TYPE: quantize this tensor to this ggml_type. example: --tensor-type attn_q=q8_0\n"); |
| 126 | printf(" Advanced option to selectively quantize tensors. May be specified multiple times.\n"); |
| 127 | printf(" --keep-split: will generate quantized model in the same shards as input\n"); |
| 128 | printf(" --override-kv KEY=TYPE:VALUE\n"); |
| 129 | printf(" Advanced option to override model metadata by key in the quantized model. May be specified multiple times.\n"); |
| 130 | printf("Note: --include-weights and --exclude-weights cannot be used together\n"); |
| 131 | printf("\nAllowed quantization types:\n"); |
| 132 | for (auto & it : QUANT_OPTIONS) { |
| 133 | if (it.name != "COPY") { |
| 134 | printf(" %2d or ", it.ftype); |
| 135 | } else { |
| 136 | printf(" "); |
| 137 | } |
| 138 | printf("%-7s : %s\n", it.name.c_str(), it.desc.c_str()); |
| 139 | } |
| 140 | exit(1); |
| 141 | } |
| 142 | |
| 143 | static int load_imatrix(const std::string & imatrix_file, std::string & imatrix_dataset, std::unordered_map<std::string, std::vector<float>> & imatrix_data) { |
| 144 | std::ifstream in(imatrix_file.c_str(), std::ios::binary); |