Skip to content

Merge upstream main - #108

Merged
plotarmordev merged 277 commits into
mainfrom
feat/158-merge-upstream-main
Nov 20, 2026
Merged

plotarmordev merged 277 commits into
mainfrom
feat/158-merge-upstream-main

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

I merged origin/main into my branch after it had moved past the branch's base (34 commits, up to 7bfc0ee6d). The merge was clean with no conflicts, and I left every changelog.d/ entry as it was.

My branch carries the upstream merges plus the local fixes they needed:

  • core json_read: a value parses with parse_numbers = false
  • hy4_flash: config.json is read without std.json's int path, so tensorfold-native links libSystem's memcpy
  • dsv41 metal: the vision test expects ZeroHeads, which check() returns for a head count of 0
  • upstream's h3 image work from cards 145 and 152, unchanged

Verification on the merge head:

  • zig build test test-golden passes
  • swarm scan . origin/main..HEAD prints clean: gitleaks clean, built-in clean

BadAd84 and others added 30 commits November 20, 2026 11:10
…e SMs, and the disk key reads the setting

The tile kernels take the SM count at load, where the lane had it only with TF_FLASHNEXT_PROMPT_BF16 on; any
tile gives the same bytes. TF_FLASHNEXT_READOUT_FUSED joins the kept-state key as bit 1 of the hc_fuse slot, so
with it unset the key is unchanged. The device comparisons now run the five launches on the engine's lane, with
qmmf's BF16 prompt tiles loaded, and check that lane against the plain one.
safetensors.File.release asks Linux for the pages of a range it has
finished with (madvise MADV_DONTNEED) and drops the file's page-cache
pages. Windows has neither: the pages of a checkpoint a load has
uploaded stay in the process's working set, and on a unified-memory
host, where the device's memory is the system's, they crowd the
allocations that come next out of the budget.

The trim is the process's whole set, so it is taken once a step rather
than once a shard: core's Checkpoint.release and releaseExcept, and the
qwen3_5 loader's per-layer release. The pages go to the standby list,
where a later read faults them back softly, so a trim that is too eager
costs a refault and never a byte.

platform/working_set.zig is the call, next to the other Win32
declarations, behind the sys module every module already imports; it is
a no-op elsewhere, where the per-range advice already covers this.
…nt only to the hub's own host

The token is HF_TOKEN, then HUGGING_FACE_HUB_TOKEN, then the one token file the hf tools read: HF_TOKEN_PATH,
else $HF_HOME/token, else ~/.cache/huggingface/token. Pull follows redirects itself, so a hop to another scheme,
host or port, such as the storage a download is redirected to, goes without it; std.http.Client keeps the header
on such hops. A 401 or 403 from the hub names the repo and whether a token is missing or lacks access, and is not
retried.
Every multi-rank family reads its own rank variables today, so no
two launch alike. mesh.launch resolves the server's flags and a
family's legacy world and rank variables once, field by field: a
partial or malformed pair refuses as the family readers did, a flag
and an alias that disagree refuse, GLM keeps refusing a launch with
neither, and alias-only values reach the family's own check.
The per-family rank variables become aliases of --tp and --rank, so
each needs a row that names its flag and the release from which the
server refuses it. Six rows, two family scopes and a semantic-version
retired() helper do that; the names keep parsing as whole numbers,
and GLM's start-up check now names their accepted forms.
--tp only took 1, 2, 4 or 8, so GLM at three ranks had to launch
through its own variables. It now takes 1 to 64, each family keeps
its own admission, --pp takes 1 until stages serve, and the engine
learns which of --tp and --rank were named, so a lone --rank can
wait for a family's world alias and an unranked family refuses it.
Without the CLI's --tp choices, Flash Next took --tp 3 or a lone
--rank 1 into memory admission, which exited with BadRank and a
trace. A given --rank not below --tp now refuses with main's text,
and a family listing its worlds refuses others by name, both before
admission; the alias release is one constant set at landing.
GLM's load-time race summed the 2-, 4- and 8-row windows and one draft step of its classic and factored NVFP4 expert
forms, then ran every decode window on the winner. A sum hides the widths it loses: at TP=4 the factored form wins at
1 and 8 rows but loses at 4 and 6, so four streams without drafts decode about 2% slower than on classic.

Both forms give the same bits (the NVFP4 fact contract holds the factored tiles and waves to the decode form's sums),
so each window can take either. The race now times both forms at all ten widths, keeps classic at a width unless
factored is more than 1% faster there, and prices each width at its kept form's time instead of timing the table
again. A window runs on the form of the narrowest timed width that holds it: rank 0 sends the forms as a bit a row
count, and the record keeps a bit a width. Records carry the build's hash in their key, so no record of a single-form
build is read for its forms.

The race sweeps every width five times on both forms, untimed, before it times a window, then each width's timed
windows take the two forms in turn, classic first on even rounds and factored first on odd ones. Timed one form after
the other, the order picked the form: on four GB10s at TP=4 a log of every run showed classic's narrow widths up to
60% over their later time in a load's first 4 s, and a 4 to 6% drift through the race on one form, so two launches of
one build kept different forms at 3, 4, 6 and 12 rows. Five sweeps of both forms take about 5.4 s there.

TF_GLM_EXPERT_FORM now names one form for every width: the warm-up sweeps that form ten times and the load times the
windows and the draft step at it, and a load that times nothing sends it to every rank for every row count. The
startup line names one form when every width shares it, else the more common form and the widths where the other runs
(experts factored, classic at 4 and 6 rows).
A checkpoint no native backend serves was told the Python engine 0.6.6 may serve it, even for types 0.6.6 refuses
too (hy_v4_flash). zig/src/native/no_backend.zig keeps the one list of 0.6.6's model types and builds the refusal
for metal.zig and none.zig: a listed type keeps the install hint word for word; any other is told no TensorFold
release serves it yet and pointed to the recipe book and the runbook. test-no-backend-host covers both.
ashhart and others added 27 commits November 20, 2026 20:38
A checkpoint whose vision tower ModelOpt quantizes, as nvidia/Qwen3.8-Flash-Next-FP4-Local
stores attention as MXFP8 and the MLP and merger as NVFP4, was refused by the CUDA tower's
reader, which expects bf16 for every tensor. The tower's linears now decode on the host as
they load: an e4m3 code times the e8m0 power of two of its 32 inputs for MXFP8, and an e2m1
code times the e4m3 scale of its 16 inputs times the tensor's global scale for NVFP4, each a
product of exactly representable factors in fp32 and rounded to bf16 once, nearest even, so
a row is the stored value read as the format defines it rather than an approximation of it.

The tower still runs in bf16: its kernels, launches, scratch and rows are the ones a
floating-point tower gets, and its device bytes are the same, because the arena is sized for
bf16 weights either way. The decode holds one linear in host memory at a time and frees it
once the upload holds its own copy, so a failed load leaves nothing behind.

A floating-point tower is read as stored, byte for byte, so a checkpoint that loads today
loads to the same bytes; only a tower whose linear's dtype is e4m3 or u8 takes the new path,
and a stored plane, scale or global scale of another shape, a width that is not a whole
number of scale groups, and an extra tensor the reader does not take all stop the load
naming the tensor. Nothing of the tower loads without --vision, so text serving is untouched.

docs/vision.md says which towers CUDA reads now, and CHANGELOG names the change under
Unreleased.
…longer claims a floating-point tower leg

The floating-point tower leg was refused before any weight was read on both images, so the receipt says it has no result.
The current head is mapped to the measured revision by its source files, which are byte equal.
sharedEvents created its events with signal = wait = 1, which is
ZE_EVENT_SCOPE_FLAG_SUBDEVICE, while the comment says DEVICE. Every rank
waits on events another card signals, and only DEVICE scope (2) promises
cache flushes "sufficient for global device access and peer device access".
Every Metal pipeline Hy4-flash loads registers with the kernel contract, in eight groups (zig/tests/contract/metal_hy4_*.zig,
records in zig/src/core/contract/hy4_*_records.zig), each with planted controls. The lane projection's 8-bit reg and
inline-sums variants join the affine probe, and their launches record gate 5 at Hy4-flash's served widths. Twelve gate-1
findings on non-finite inputs are recorded as known, with entries of their own and lines in docs/kernel-contract.md.
…CUDA product compiles again

cdbdc5a registered Muse Spark in the native CUDA product, and its `open` and kept-state hooks reach fabric/tp's
POSIX socket session (pollfd, MSG.NOSIGNAL, open/clock_gettime, pthread mutexes, -1 handles), so `zig build -Dgpu=...`
for Windows stopped compiling (every error traced through muse_spark/native.zig's open and snap_drop).

As flashnext/cuda_rank_wire.zig already does for its rank link, a comptime gate keeps the fabric out on Windows:
`open` returns error.MuseSparkTpPlatform before anything touches the session, explained as "Muse Spark is served at two
TP ranks, and tensor parallelism across ranks runs on Linux only: serve it from a Linux build", and Engine.send returns
early, since a Windows engine never has a session. On Linux and macOS both gates are comptime-false, so their code is
unchanged; one-rank families on Windows are untouched. A host test checks the refusal's explanation.
…ct, and CI runs it

The zig-windows CI job ran host tests only, so nothing compiled the Windows CUDA product and the break above went
unseen. `zig build compile-native-cuda-windows` builds the sm_120 product for x86_64-windows-gnu (x86_64_v4,
ReleaseSafe, the release's own options) from any host. Its kernel images are empty files, as images below a kernel's
minimum SM already are, so it needs neither nvcc nor -Dfatbins; nothing asks for the binary, so the compiler checks
every reachable path without emitting or linking (about 15 s warm). product.zig's CUDA server takes its target, mode
and image source as arguments for this; the -Dgpu build passes its options through unchanged.

It runs in the zig-windows job after test-pull-security, and in the nightly Linux compile shard (linux_compile).
…on the staged tiles (for ashhart#3516)

At worlds where a rank's fused KDA input is not eight columns wide (3, 5, 6, 7), its rows are not 16-byte aligned, so
prompt windows ran on tf_glm_bmm_rows and never on the staged tiles, which give the same bytes. The stack is now always
padded at load to its own width rounded up to eight columns and stays row-major bf16: prompt windows take
tf_glm_bmm_tile and tf_glm_bmm_tile1, decode windows keep tf_glm_bmm_decode. TF_GLM_KDA_PAD=1 keeps main's common
width and still tiles the stack for glm_mm. No kernel changes, no new switch.

glm-ref checks both of TP=3's shapes and the f_b view at 144 row counts from 1 to 2,048: every byte as the uneven rows'.
Forward cuLaunchKernelEx to the existing Capture.launch recorder, as the adjacent TP3 test already does. Keep the test assertions and production PDL default unchanged.
…ream-main

# Conflicts:
#	zig/tests/cuda/contract_limits.zig
…ream-main

# Conflicts:
#	zig/src/core/contract/registry_joins.zig
@plotarmordev
plotarmordev merged commit 923e22a into main Nov 20, 2026
@plotarmordev
plotarmordev deleted the feat/158-merge-upstream-main branch November 20, 2026 23:44
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.