Skip to content

CUDA admission: an integrated GPU under WSL2 reads the CUDA pool (RTX Spark N1X), plus an N1X receipt - #2107

Merged
ashhart merged 4 commits into
ashhart:mainfrom
drowzeys:wsl-integrated-cuda-pool
Nov 17, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
drowzeys:wsl-integrated-cuda-pool

Conversation

@drowzeys

@drowzeys drowzeys commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Problem. On Linux, an integrated device's room comes from `/proc/meminfo`. Under WSL2 that's WSL's RAM, not the GPU's memory. On an RTX Spark N1X laptop (HP OmniBook X 14, 128 GB) the firmware gives the GPU a fixed 96 GB WDDM pool and leaves WSL about 30 GB. So the Linux build refused `Blackfrost-AI/CYBER-FROST-3.8-FP4-Local` (Flash Next, 72.8 GiB) with "24.5 GiB the CUDA memory budget grants", although the GPU holds it. `TENSORFOLD_CUDA_MEMORY_LIMIT_GB` can't help, because it only lowers the cap.

Change.

  • `hostCounts(unified, windows, wsl_pool)`: under WSL2 (`WSL_DISTRO_NAME` set) an integrated device reads the CUDA pool, as on native Windows.
  • `TENSORFOLD_UNIFIED_HOST_COUNTS=1` keeps procfs and `=0` forces the pool.
  • `cuda_family_memory.poolFor` reads both variables through `Host.env`, so the fixtures keep their native-Linux answer.
  • A unit test covers `wslPool` and `hostCounts`.
  • A GB10 on native Linux is unchanged.

Receipt (also added to `docs/WINDOWS.md`), on the N1X in HP Performance mode, Cyber Frost FP4-Local, 4 streams at a 32K window, vcruz305's `bench_v1.py` / `concurrency.py`, client end-to-end:

WSL2, this change native Windows
One stream, code / DevOps / prose (tok/s) 43.8 / 42.2 / 35.7 50.4 / 40.2 / 37.3
First token, short / 17,850-token prompt (s) 0.21-0.24 / 10.2 0.22-0.28 / 10.9
1 / 2 / 4 streams, aggregate (tok/s) 36.4 / 50.2 / 65.6 36.6 / 54.4 / 70.0

Native Windows build. This reproduces the N1X receipt the Windows doc says hasn't been reproduced on the maintained tree. Built from source:

  • Zig 0.17.0 and VS 2022 Build Tools with ARM64 C++ tools.
  • CUDA 13.4 for Windows on Arm, assembled from NVIDIA's `windows-arm64` redistributable archives; winget's `Nvidia.CUDA` has no arm64 installer.
  • `tf-cuda-test`: `info` reports sm_121, 48 SMs, 113,103 MiB. `smoke` passes. `glue` is 1473/1473 byte-equal.

For comparison, the same laptop on exllamav3 (vcruz305's EXL3 recipe, Cyber Frost 3.87 bpw) gave 38.6 / 34.5 / 27.8 tok/s and 36.2 aggregate at four.

Tests. `zig build test` (host) in WSL2 on the N1X: everything passes except 3 `qwen35_layers_host` cases. They fail identically on unchanged `main` (`85e53093b`), so they're not from this change. The serve path was checked end to end on a 1.2.2 build carrying the same change; this branch is on `main`.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @drowzeys, a clear diagnosis: under WSL2 /proc/meminfo counts WSL's RAM, not the 96 GB the firmware gives the GPU, and the native Windows receipt on the N1X is a welcome addition to the Windows doc. Two small things. On our main the new hostCounts and wslPool comments run over several lines, so lean reads 429 instead of 425; one line each, please. And TENSORFOLD_UNIFIED_HOST_COUNTS treats any value but 0 as 1, so a typo silently keeps procfs. Could it refuse anything but 0 or 1, by name? We'll check on a GB10 that native Linux admits exactly as main does.

@drowzeys

drowzeys commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Added a second, small fix found while testing Drama 3 natively on the same N1X. Drama's CUDA cuBLAS loader (drama3/cuda/blas.zig) and the optional-library table named only the Linux sonames, so native Windows Drama 3 always failed with CublasUnavailable even with cublas64_13.dll on PATH. Both now try cublas64_13.dll on Windows, as cuda/cublaslt.zig already does for cuBLASLt. After the fix, fishaudio/drama-3 loads natively in 31.5 s and speaks a 13.2 s line in 11.2 s.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @drowzeys. Here's the check we promised, on a GB10 under native Linux with the variable unset, your head against its base: the admission line is the same in every run (8 streams at a 73,728-token window), tokens are identical in all 20 rows, and prompt and decode speed are level. So native Linux admits exactly as main does.

Not run: TENSORFOLD_UNIFIED_HOST_COUNTS=1. We'll add that once the two small asks are in.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @drowzeys, and for the Drama 3 DLL fix. Two things from our earlier note are still open on c4ef91457, plus
one small one. The hostCounts and wslPool comments still run over several lines, and the new blas.zig one adds
two more, so lean reads 430 against main's 425; one line each, please. TENSORFOLD_UNIFIED_HOST_COUNTS still treats
anything but 0 as procfs, so a typo silently keeps the old behaviour; please accept only 0 and 1 and refuse
anything else by name. And a CHANGELOG line under Unreleased, since WSL2 admission and Windows Drama 3 both change.
Your comment mentions the optional-library table too, but the diff doesn't touch it; is a change needed there?

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Hi @drowzeys, thanks again for the WSL2 pool fix and the Drama 3 DLL name. Checking in on the small things from our last note:

  • one-line comments for hostCounts, wslPool and the new one in blas.zig;
  • TENSORFOLD_UNIFIED_HOST_COUNTS taking only 0 or 1, and refusing anything else by name;
  • a CHANGELOG line under Unreleased.

Main has moved too, so the branch needs a rebase. And is a change needed in the optional-library table your comment mentioned, or can that go? Once these are in, we'll run the opt-in setting and take it from there.

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the wsl-integrated-cuda-pool branch from c4ef914 to 3877045 Compare November 12, 2026 14:15
@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thanks @drowzeys, for the WSL2 pool fix, the N1X receipt and the Drama 3 DLL name. We've finished the small asks on your branch ourselves, keeping your two commits as yours:

  • Rebase. The branch now sits on current main. Main already names cublas64_13.dll in the optional-library table (zig/src/platform/optional_libraries.zig:31), so that hunk dropped out and only your blas.zig change remains. That also answers our question about the table.
  • TENSORFOLD_UNIFIED_HOST_COUNTS takes only 0 or 1. It now has a row in zig/src/platform/environment.zig:52, so the CUDA backend refuses any other value at startup and names the variable, as it does for its other settings. The pool reads parse it through the same row (zig/src/native/cuda_memory.zig:199-212, zig/src/native/cuda_family_memory.zig:21-25), and a blank value reads as unset, as for every registered setting. A fixture test (zig/src/native/cuda_family_memory_test.zig:143) covers WSL2 reading the pool, both values and four typos; on your previous head the typo cases kept /proc/meminfo and the test failed.
  • One-line comments for hostCounts, wslPool and the cuBLAS open (cuda_memory.zig:193, :198; zig/src/families/drama3/cuda/blas.zig:41). Lean is back to main's count, 0 new.
  • Docs. docs/environment.md:31 lists the variable, and docs/WINDOWS.md:169-172 says a typo is refused. The trailing blank line at the end of WINDOWS.md is gone.
  • CHANGELOG. We'll add the line when it lands, crediting you.

Host tests pass on macOS (the Windows pool and environment tests, and the CUDA host suite), and the Linux CUDA build compiles. What's left is ours: on a GB10 under native Linux we'll run this head with the variable unset, =1 and =0, and check that a typo is refused, before it lands.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @drowzeys. We rebased this onto today's main, keeping your commits under your name. The only conflict was in zig/src/platform/environment.zig, where your rows now sit after main's newer TF_PROMPT_INTERMEDIATE and TENSORFOLD_LFM2_KV_PAGES rows. CI is running on the new head.

Please pull before you push again (git pull --rebase), so the rebase isn't lost.

  • Synthena

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

/atc exchange b2b69ddb09ce37519cedd6ad578b125388eb81f64215acd31028919e370335a2

drowzeys and others added 4 commits November 17, 2026 21:39
…on Windows

On Linux an integrated device's room came from /proc/meminfo. Under WSL2 that is WSL's RAM (about 30 GiB on an
RTX Spark N1X whose firmware gives the GPU 96 GB), not the GPU's WDDM pool, so a 72.8 GiB Flash Next checkpoint the
GPU holds was refused. hostCounts takes the WSL answer from its callers (WSL_DISTRO_NAME, or
TENSORFOLD_UNIFIED_HOST_COUNTS=1/0 to force procfs or the pool); the family pool reads it through Host.env, so the
fixtures keep their native-Linux answer. docs/WINDOWS.md: the WSL note and an RTX Spark N1X receipt (native build
from NVIDIA's windows-arm64 archives, WSL and native measurements).
drama3/cuda/blas.zig and the optional-library table named only the Linux sonames (libcublas.so.13), so native
Windows Drama 3 always failed with CublasUnavailable although cublas64_13.dll was on PATH. On Windows they now try
cublas64_13.dll, as cuda/cublaslt.zig already does for cuBLASLt. Measured on an RTX Spark N1X: fishaudio/drama-3 loads
natively in 31.5 s and speaks a 13.2 s line in 11.2 s.
The variable gets a row in platform/environment.zig, so the CUDA backend
refuses any other value at startup, by name, as it does for its other
settings, and the pool reads parse it through the same row instead of
treating everything but 0 as /proc/meminfo. Blank reads as unset, as for
every registered setting. docs/environment.md lists it and docs/WINDOWS.md
says a typo is refused.

The hostCounts, wslPool and cuBLAS open comments are one line each. A
fixture test covers WSL2 reading the pool, both values and four typos; the
typo cases fail on the previous head, which kept /proc/meminfo for them.

Co-authored-by: drowzeys <[email protected]>
@ashhart
ashhart force-pushed the wsl-integrated-cuda-pool branch from 2889570 to a175103 Compare November 17, 2026 21:40
@ashhart
ashhart merged commit 41ddd2a into ashhart:main Nov 17, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thank you @drowzeys. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants