Skip to content

Port three host fixes from the official TensorFold: RDMA GID auto-detect, NCCL cuMem off, page cache release - #22

Merged
Elevatormusic merged 4 commits into
deepseek-v41-tp2from
port-official-host-fixes
Oct 21, 2026
Merged

Elevatormusic merged 4 commits into
deepseek-v41-tp2from
port-official-host-fixes

Conversation

@Elevatormusic

@Elevatormusic Elevatormusic commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Three host fixes for the DeepSeek-V4.1 TP path. Each one follows an idea from the official TensorFold (ashhart/TensorFold, Zig engine, Apache-2.0) and is written again in Python. No official code is copied. The notices are in NOTICE, THIRD_PARTY_NOTICES.md and tools/dsv41/ATTRIBUTION.md.

  1. NCCL cuMem off. The engine sets NCCL_CUMEM_ENABLE=0 and NCCL_CUMEM_HOST_ENABLE=0 before NCCL starts, unless the user set them (official PR GLM-5.3-Flash on two CUDA ranks: linears packed to 4, 6 or 8 bits ashhart/TensorFold#995: on GB10 the driver ran out of memory at 8 to 16 streams, and later 2-rank starts failed until a reboot).
  2. RDMA GID auto-detect. rdma.py read a fixed index (5, or NCCL_IB_GID_INDEX). cuda/roce_gid.py now reads /sys/class/infiniband/<dev>/ports/1/gids and gid_attrs/types and takes the lowest RoCE v2 IPv4 entry of each port. TF_RDMA_GID_INDEX or NCCL_IB_GID_INDEX with a value of 0 or more still fixes the index. Unset, empty or -1 means detect. Before, -1 went to ibv_query_gid and failed. The gather takes one index per device. The engine also sets NCCL_IB_GID_INDEX to the detected index when it is unset and every port that NCCL_IB_HCA lets NCCL use has the same one (a set value, also -1, stays).
  3. Page cache release after the weight load (official PRs core: a checkpoint's pages out of the page cache once a loader is done with them ashhart/TensorFold#766 and core: a direct read the file system refuses goes through the page cache ashhart/TensorFold#916). Shards.close and RankCache.close call posix_fadvise(DONTNEED) on the files they read, so the page cache of those files goes back to the node (the weight files are about 106 GB a rank when read from the rank cache). TF_DS_RELEASE_PAGE_CACHE=0 turns it off. The load log now ends with the node's MemAvailable. A restart reads the files from disk, not from the page cache. The rank cache key includes weights.py, so the first start after this change writes the rank cache again.

Refs Elevatormusic/DeepSeek-V4.1-Flash-1017-EXL3-TensorFold-2x-DGX-Spark#21 (host memory only).

Type

  • type: fix: a bug fix, or a fix after review findings
  • type: feature: new code (a feature, tool or add-on)
  • type: docs: docs only
  • type: results: run results or a close-out
  • type: research: a study or failure research, with no fix
  • type: spec: a plan or spec before the work

Receipt

  • Environment: TensorFold commit 269967a on deepseek-v41-tp2 20277f6 (base image e2b282c50724, PyTorch 2.13.0a0 nv26.07), 2x DGX Spark (GB10), DeepSeek-V4.1-Flash-1017 EXL3 2.9 bpw, --vision, --parallel 4, 5 drafts, context 262144, prefill chunk 2048, rank cache on. The base image and the PR image were each started several times on the same two nodes.
  • Exactness: 4 short greedy prompts (48 tokens each) give the same token_sha on the base image and on the PR image in every start: c2ab0d41bf03, 16295b26740f, 32288eae41c4, 4202d7acb4b6 (4 base starts, 16 PR starts). tools/bench_concurrent.py --alone --serial was not run. No token path changes.
  • Decode tok/s before and after: not measured with tools/bench_openai.py. The decode path does not change.
  • Prefill tok/s, cold unique prompts, two starts for each image (base with NCCL cuMem on, PR with it off): 4K prompt base 1252 and 1828, PR 1811 and 1851. 16K prompt base 1954 and 1804, PR 2197 and 2157. 32K prompt base 2056 and 2128, PR 2181 and 2103. The prompt gathers over NCCL are not slower with cuMem off. The first base start was a cold start. tools/prefill_cold.py was not run.
  • RDMA GID, both ranks, both ports (rocep1s0f1, roceP2p1s0f1): the log shows RDMA GID index of <dev> port 1: 3 (detected), and the engine sets NCCL_IB_GID_INDEX=3. Both nodes have index 3 now, so a node pair with different tables and a link flap were not tried. On the base image, NCCL_IB_GID_INDEX=-1 makes both ranks refuse the gather (ibv_query_gid failed), and decode gathers fall back to NCCL. On the PR image the same setting starts the gather with detected indices. Other checks: TF_RDMA_GID_INDEX=3 logs (fixed), a set NCCL_IB_GID_INDEX stays. On these nodes ibv_query_gid with index -1 returns an error, and with the old default 5 it returns an all-zero GID.
  • NCCL cuMem: the log line names NCCL_CUMEM_ENABLE=0 NCCL_CUMEM_HOST_ENABLE=0 on both ranks. The 8 to 16 stream driver failure of official PR GLM-5.3-Flash on two CUDA ranks: linears packed to 4, 6 or 8 bits ashhart/TensorFold#995 was not tried, because it can need a node reboot.
  • Page cache release, release on against off, same rank cache, MemAvailable and page cache in the log line after the load (the node is full: 99 GiB of weights are in GPU memory, so the kernel reclaims page cache in both modes, and the page cache peaks at 40 to 45 GiB in both): head MemAvailable 10.8 GiB on (8 starts, 10.6 to 11.1) against 9.6 GiB off (4 starts, 9.4 to 9.7). Worker MemAvailable 9.9 GiB on (8 starts, 6.7 to 10.7, one low outlier) against 8.2 GiB off (4 starts, 7.5 to 8.9). Page cache left after the load, runs that log it: 2.0 to 2.4 GiB (head) and 1.8 to 1.9 (worker) on, 6.4 and 7.6 off (1 off start). Load time is the same (24 s against 23 s from the rank cache). So the gain on this setup is 1.3 to 1.7 GiB MemAvailable, not the full 106 GB.
  • Tests run: tests/test_dsv41_host_env.py, 37 tests. In the engine image (PyTorch): 37 pass, 0 skip. On a CPU host without PyTorch: 34 pass, 3 skip (the loader tests and the real posix_fadvise call skip on Windows). CI checks pass. ruff finds nothing in the new files.
  • Not run, and why: the other deepseek_v41 test files (the changed code paths are start-up only); a real link flap; 8 to 16 concurrent streams (see above).

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No token path changes. token_sha is compared with the base image in the Receipt.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No arithmetic changes.)
  • Prompt processing is no slower than the last release. (Loading and start-up only.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.
AI disclosure

AI: Claude Sonnet 5.5 via Claude Code
Checked: read every line of the diff, wrote the tests, ran them on CPU and in the engine image, and ran the live check on the 2x Spark pair (20 starts, numbers in the Receipt).

…ache after a weight load

The GID index of each RDMA port is read from sysfs at start (lowest RoCE v2 IPv4 entry).
TF_RDMA_GID_INDEX or NCCL_IB_GID_INDEX with a value of 0 or more still fixes it; unset, empty
or -1 means detect. The gather takes one index per device. The engine sets NCCL_IB_GID_INDEX to
the detected index when it is unset, and NCCL_CUMEM_ENABLE=0 and NCCL_CUMEM_HOST_ENABLE=0 unless
the user set them. Shards.close and RankCache.close call posix_fadvise(DONTNEED) on the files
they read; TF_DS_RELEASE_PAGE_CACHE=0 turns it off.
@Elevatormusic Elevatormusic added the type: fix a correction after review findings or a bug fix label Oct 21, 2026
@Elevatormusic

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T02:10:58.625410Z 269967a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 079e87f790

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2911757036

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tensorfold/families/deepseek_v41/cuda/engine.py Outdated
Comment thread src/tensorfold/cuda/roce_gid.py Outdated
@Elevatormusic

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 2911757036

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Elevatormusic

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 0dce299e94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Elevatormusic

Copy link
Copy Markdown
Owner Author

@codex review

@Elevatormusic

Copy link
Copy Markdown
Owner Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 269967ab62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Elevatormusic
Elevatormusic merged commit 083b4ad into deepseek-v41-tp2 Oct 21, 2026
5 checks passed
@Elevatormusic
Elevatormusic deleted the port-official-host-fixes branch October 21, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix a correction after review findings or a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant