[PR #5098] [Other] nvfp4_convert: spool converted tensors to a temporary file #5308

Open
opened 2026-11-07 16:34:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5098
Author: @Tsury
Created: 11/3/2026
Status: 🔄 Open

Base: main ← Head: fix-nvfp4-convert-temp-file


📝 Commits (1)

  • 6357ee0 nvfp4_convert: spool converted tensors to a temporary file

📊 Changes

2 files changed (+12 additions, -1 deletions)

View changed files

📝 docs/NVFP4.md (+3 -0)
📝 tools/nvfp4_convert.py (+9 -1)

📄 Description

Problem and result

On v0.2.10 (ffa80d73), tools/nvfp4_convert.py needs about as much RAM as the output GGUF. llama.cpp's converter repacks the NVFP4 experts eagerly, and its GGUF writer keeps every added tensor in memory until it writes the file. For Qwen3.8-Flash-Next that is about 76 GB. On a 64 GB machine the conversion swapped and slowed to about one tensor per 2 minutes. On a host with a 24 GB memory limit it was killed by the OOM killer after layer 16.

After this change, the converter passes llama.cpp's own --use-temp-file. Each tensor is spooled to a temporary file as it is added, so RAM stays at about one layer. The temporary file goes next to --outfile unless TMPDIR is set, because the system temp folder is often a small RAM disk. docs/NVFP4.md states the RAM and disk need.

Validation

On ffa80d73 + this change, Linux, Python 3.14, llama.cpp at the commit setup pins:

  • Passed: tools/nvfp4_convert.py on d0xin Swift-1.5 NVFP4-FP8PLE-Rank2-Abliterated (a Qwen3.8-Flash-Next ModelOpt NVFP4 checkpoint) finished in 1567 s. Peak anonymous memory was 2.8 GB. Without the change, the same run was OOM-killed at 24 GB after layer 16.
  • Passed: tools/nvfp4_verify.py on the result: the experts match the checkpoint bit for bit. tools/nvfp4_verify_gguf.py: the GGUF passes.
  • Passed: the engine (0.1.56) loads and serves the converted model.
  • Not run: no engine or setup code changes.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5098 **Author:** [@Tsury](https://github.com/Tsury) **Created:** 11/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-nvfp4-convert-temp-file` --- ### 📝 Commits (1) - [`6357ee0`](https://github.com/Niko1221/Strata/commit/6357ee00f25ff77f76ccd7dc382fd9d0680233ce) nvfp4_convert: spool converted tensors to a temporary file ### 📊 Changes **2 files changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/NVFP4.md` (+3 -0) 📝 `tools/nvfp4_convert.py` (+9 -1) </details> ### 📄 Description ## Problem and result On v0.2.10 (ffa80d73), `tools/nvfp4_convert.py` needs about as much RAM as the output GGUF. llama.cpp's converter repacks the NVFP4 experts eagerly, and its GGUF writer keeps every added tensor in memory until it writes the file. For Qwen3.8-Flash-Next that is about 76 GB. On a 64 GB machine the conversion swapped and slowed to about one tensor per 2 minutes. On a host with a 24 GB memory limit it was killed by the OOM killer after layer 16. After this change, the converter passes llama.cpp's own `--use-temp-file`. Each tensor is spooled to a temporary file as it is added, so RAM stays at about one layer. The temporary file goes next to `--outfile` unless `TMPDIR` is set, because the system temp folder is often a small RAM disk. `docs/NVFP4.md` states the RAM and disk need. ## Validation On ffa80d73 + this change, Linux, Python 3.14, llama.cpp at the commit setup pins: - **Passed:** `tools/nvfp4_convert.py` on d0xin Swift-1.5 NVFP4-FP8PLE-Rank2-Abliterated (a Qwen3.8-Flash-Next ModelOpt NVFP4 checkpoint) finished in 1567 s. Peak anonymous memory was 2.8 GB. Without the change, the same run was OOM-killed at 24 GB after layer 16. - **Passed:** `tools/nvfp4_verify.py` on the result: the experts match the checkpoint bit for bit. `tools/nvfp4_verify_gguf.py`: the GGUF passes. - **Passed:** the engine (0.1.56) loads and serves the converted model. - **Not run:** no engine or setup code changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5308
No description provided.