## EXL3 conversion script ### Arguments #### Basic - **-i / --in_dir *directory***: The source model to convert, in unquantized HF format. The directory should contain at least a `config.json` file, a `tokenizer.json` file and one or more `.safetensors` files containing weights. - **-o / --out_dir *directory***: The destination directory for the converted **EXL3** model. Will be created if it doesn't exist, or overwritten if it does. - **-w / --work_dir *directory***: Working directory for temporary files. It should have enough free space to store an entire copy of the output model. This is also where checkpoints are stored and the only required argument if **-r / --resume** is specified. - **-ss / --shard_size *float***: Output shard size, in megabytes. Default is 8192. Set this to 0 to disable sharding. Note that writing very large `.safetensors` files can require a lot of system RAM. - **-b / --bits *float***: Target average number of bits per weight. - **-hb / --head_bits *int***: Number of bits per weight for the lm_head (output) layer of the model. Must be an integer from 1 to 8, default is 6. - **-hq / --hq**: Increase the bitrate of select layers, such as attention and shared-expert layers. Final model bitrate may be somewhat higher than requested by `--bits`, but for MoE models this is typically a very small increase in size (0.05 - 0.10 bpw) for a disproportionately large increase in model fidelity. #### Advanced (generally disregard these options) - **--out_scales *str***: Force enable or disable output channel scales. Options are "always" (default), "never" and "auto". Mostly for debug purposes. #### Checkpoints - **-cpi / --checkpoint_interval *int***: Interval (in seconds) between checkpoints. - **-r / --resume**: Resume an interrupted job pointed to by **-w / --work_dir** from the latest checkpoint. If resuming a job, all other arguments such as input and output directories, bitrate etc. are restored from the old job, though some can be overridden. Note that resuming is now explicit, reversing the behavior from ExLlamaV2. #### Performance - **-d / --devices *list***: Comma-separated list of GPU device IDs to use during quantization. By default only the first visible device (device 0) is used. Adding more devices can speed up quantization if there is sufficient PCIe bandwidth between them. This does not affect memory usage on the first GPU, and very little memory is used on the others, since only the most compute intensive operation (trellis encoding) is distributed. - **-dr / --device_ratios *list***: Ratio as comma-separated list. Determines how the encoding workload is distributed when using multiple devices. This is useful if using GPUs with dissimilar compute performance, to prevent slower GPUs from becoming bottlenecks. Ratios are relative, i.e. `1,1,3` is the same ratio as `3,3,9`. Recommendation is to omit this argument; by default, ratios are autotuned to maximize usage across GPUs. - **-pm / --parallel_mode**: Deprecated (no-op). Parallel mode is now the default: multi-GPU quantization distributes one linear layer to each GPU at a time whenever a layer has at least as many tensors as there are devices. Layers with fewer tensors than devices (e.g. the lm_head, alone in its layer) fall back to splitting the trellis encoding workload across devices, with small tensors capped to as many devices as they can feed (~1M weights per device). #### Debug stuff (ignore these) - **-lcpi / --last_checkpoint_index *int***: If specified, don't save checkpoints after this module index. - **-cr / --cal_rows *int***: Number of rows of calibration data. - **-cc / --cal_cols *int***: Number of columns of calibration data. - **-v / --verbose**: Extra debug output while quantizing. - **--override_anyway**: Allow resuming even when overriding settings that will break the existing job. - **-img / image_dump**: Save all tensors as images in the working directory. May require a large amount of system memory and disk space, can be slow. ### Examples #### Converting ```sh python convert.py -i /mnt/models/llama3.1-70b-instruct \ -o /mnt/models/llama3.1-70b-instruct-exl3-3.75bpw \ -w /mnt/temp/exl3 \ -b 3.75 ``` #### Resuming Resume the job started above if it was interrupted: ```sh python convert.py -w /mnt/temp/exl3 -r ``` #### Multi-GPU quant Convert a model on the first three devices: ```sh python convert.py -i /mnt/models/llama3.1-70b-instruct \ -o /mnt/models/llama3.1-70b-instruct-exl3-3.75bpw \ -w /mnt/temp/exl3 \ -b 3.75 \ -d 0,1,2 ``` Convert a model on the first three devices, using CUDA:2 as the primary device. Also keep attention etc. in higher precision with `-eb`. Final model size will be slightly larger than the 4.00 bpw requested in this example, but since this is an MoE model, the increase will be on the order of 0.05 - 0.1 bpw: ```sh python convert.py -i /mnt/models/qwen3.5-35b-a3b \ -o /mnt/models/qwen3.5-35b-a3b-4.00bpw-plus \ -w /mnt/temp/exl3 \ -b 4.00 \ -eb \ -d 2,0,1 ```