mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 23:08:36 +00:00
nvfp4_convert: spool converted tensors to a temporary file
llama.cpp's converter repacks the ModelOpt NVFP4 experts eagerly and the GGUF writer keeps every added tensor in RAM until it writes the file. For Qwen3.8-Flash-Next that is ~76 GB, so the conversion was killed at a 24 GB memory limit after layer 16 of 48. Pass --use-temp-file: each tensor goes to a temporary file as it is added and RAM stays near one layer (2.8 GB anonymous memory measured). The temporary file sits next to the output unless TMPDIR is set. docs/NVFP4.md states the RAM and disk needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58ee322772
commit
f398bd89a7
2 files changed
+12
-1
No files matched your search
@@ -36,6 +36,9 @@ python terminal/tools/iq_pack.py --gguf <model>.gguf --out <pack dir>
|
||||
- `nvfp4_convert.py` runs llama.cpp's own converter (`third_party/llama.cpp`, the commit setup pins) with the type
|
||||
policy the engine needs. The experts are repacked without loss. `terminal/tools/nvfp4_verify.py` compares them with the
|
||||
checkpoint bit for bit, and `terminal/tools/nvfp4_verify_gguf.py` checks the GGUF.
|
||||
- Each tensor goes to a temporary file as it is converted, so the conversion needs about 3 GB of RAM, and free disk
|
||||
for the GGUF twice (~76 GB each for Qwen3.8-Flash-Next). The temporary file is next to `--outfile`; `TMPDIR` puts
|
||||
it on another disk.
|
||||
- The small projections the BF16 kernels read (routers, SSM gates, indexer, PLE and hyper-connection projections) are
|
||||
written as BF16.
|
||||
- Everything served natively goes to Q8_0: attention, `ssm_out`, the shared experts, the output head and the token
|
||||
|
||||
@@ -25,8 +25,10 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
ENGINE = pathlib.Path(__file__).resolve().parents[1]
|
||||
@@ -96,7 +98,13 @@ def main() -> int:
|
||||
install_policy()
|
||||
import convert_hf_to_gguf as C # noqa: E402 (after the policy is installed on the class)
|
||||
|
||||
argv = [str(model), "--outtype", "q8_0", "--outfile", str(out)]
|
||||
# The converter repacks the NVFP4 experts eagerly (one merged tensor per layer and projection) and the GGUF writer
|
||||
# keeps every added tensor in RAM until the file is written: ~76 GB for Qwen3.8-Flash-Next. --use-temp-file spools
|
||||
# each tensor to a temporary file as it is added, so RAM stays at about one layer. The temporary file needs as much
|
||||
# disk as the output; it goes next to the output unless TMPDIR names another folder.
|
||||
if not os.environ.get("TMPDIR"):
|
||||
tempfile.tempdir = str(out.parent)
|
||||
argv = [str(model), "--outtype", "q8_0", "--outfile", str(out), "--use-temp-file"]
|
||||
if a.dry_run:
|
||||
argv.append("--dry-run")
|
||||
sys.argv = ["convert_hf_to_gguf.py"] + argv
|
||||
|
||||
Reference in new issue
Block a user