Class QuantizedHfLoader
java.lang.Object
smile.llm.quant.QuantizedHfLoader
Loads HuggingFace GPTQ / AWQ / FP8 / NVFP4 SafeTensors into Llama linears
(shard-then-pack for TP when
tpSize > 1).
Marlin path: batch-reads each safetensors shard once, dequantizes AWQ/GPTQ
on CPU (with HF→Meta RoPE rearrange on q_proj/k_proj), requants
to Marlin layout in parallel, then installs on the model graph (main thread)
with serial H2D copies.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgroupSizeFromConfig(Path checkpointDir) Readsgroup_sizefromconfig.json, defaulting to128.static voidinstallLlamaLinears(LlamaModel model, Path dir, QuantFormat format, WeightGemmBackend backend, Device device, int groupSize, int tpSize, int tpRank, ScalarType outDtype) Installs quantized projections for every Llama block.static voidinstallLlamaLinears(LlamaModel model, Path dir, QuantFormat format, WeightGemmBackend backend, Device device, int groupSize, int tpSize, int tpRank, ScalarType outDtype, int modelLoaderThreads) Installs quantized projections for every Llama block.
-
Method Details
-
installLlamaLinears
public static void installLlamaLinears(LlamaModel model, Path dir, QuantFormat format, WeightGemmBackend backend, Device device, int groupSize, int tpSize, int tpRank, ScalarType outDtype) throws IOException Installs quantized projections for every Llama block.- Parameters:
model- target model.dir- checkpoint directory.format- detected quantization format.backend- GEMM backend to install.device- target device.groupSize- quantization group size.tpSize- tensor-parallel world size.tpRank- this rank.outDtype- compute dtype for FP8 / NVFP4 output.- Throws:
IOException- if checkpoint IO fails.- See Also:
-
installLlamaLinears
public static void installLlamaLinears(LlamaModel model, Path dir, QuantFormat format, WeightGemmBackend backend, Device device, int groupSize, int tpSize, int tpRank, ScalarType outDtype, int modelLoaderThreads) throws IOException Installs quantized projections for every Llama block.- Parameters:
model- target model.dir- checkpoint directory.format- detected quantization format.backend- GEMM backend to install.device- target device.groupSize- quantization group size.tpSize- tensor-parallel world size.tpRank- this rank.outDtype- compute dtype for FP8 / NVFP4 output.modelLoaderThreads- pack/read concurrency hint (0= auto).- Throws:
IOException- if checkpoint IO fails.
-
groupSizeFromConfig
Readsgroup_sizefromconfig.json, defaulting to128.- Parameters:
checkpointDir- model directory.- Returns:
- group size.
- Throws:
IOException- if config IO fails.
-