Skip to content

glm: add native prefill and FP4-Local support for dual DGX Spark - #199

Merged
AzeezIsh merged 41 commits into
Atlas-Inf:mainfrom
Mango-kid:release/glm53-nvfp4
Nov 1, 2026
Merged

AzeezIsh merged 41 commits into
Atlas-Inf:mainfrom
Mango-kid:release/glm53-nvfp4

Conversation

@Mango-kid

@Mango-kid Mango-kid commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add native GLM-5.3-Flash support on two DGX Sparks for NVIDIA NVFP4 and FP4-Local checkpoints, with FP8 target cache and optional separately downloaded DFlash2 weights. Atlas builds and dispatches its own KDA and sparse-MLA prefill kernels. The integration includes RC2/RC4 correctness, KV sharding and prefix restoration, native compressed-scale/MXFP8 loading, optional exact prefill optimizations, and a constrained tool-call-or-JSON-answer path.

This branch now integrates main at e29809db9f3fd75611b7a1ed491f55275d34df0e. Main already includes the earlier GLM implementation through #174; the remaining diff contains the native prefill integration and subsequent improvements. Main's newer Qwen/Nemotron support and rustls 0.23.46 update are preserved. Checkpoint-native GLM MTP and new Strix functionality remain outside this release.

Current update

Server runtime tested at 5d652f8e0835231ead3bcac91d66e22632c08cbe. Later edits are documentation and a test-only ownership correction at 3dbb41fb494f3db3993d9e620de1b8009adc901d; the server binary is unchanged.

  • CPU: 7,602 passed, 0 failed, 221 ignored. Standard and all-features Clippy, all-features test compilation, formatting, static checks and rustdoc passed. The test-only correction also passed focused Clippy and five ownership tests.
  • Core CUDA: 6/6 passed, covering byte-exact prefill paths and MXFP8 reference behavior.
  • Existing NVFP4: both 32K-pool profiles passed C1/C4 API, tools, strict JSON, two-turn tools/JSON union and cancellation checks. All 11 benchmark answer and reasoning pairs were identical with the four prefill switches off versus on. Approximately 10K-token synthetic prose/code/structured TTFT improved by 2.3–2.4%; decode remained flat. Separate random-token C1 decode was 106.11→106.25 tokens/s and C4 aggregate decode 168.18→168.85 tokens/s. These are bounded measurements, not statistical superiority or enlarged-context claims.
  • FP4-Local: all six real-checkpoint GPU tests passed. Both 32K-pool serving profiles passed the same API/tool/JSON/cancellation checks plus positive red/blue image probes; all 13 benchmark/vision answer and reasoning pairs were identical between settings. Chat TTFT decreased by 0.8–1.1%, while the single random C1 TTFT increased by 1.6%; decode was effectively flat. Random C1 decode was 95.14→94.75 tokens/s and C4 aggregate 164.38→163.68 tokens/s. All four ranks exited cleanly with zero swap, no OOM and at least 12.18 GiB host memory available. These small samples do not establish a general speedup.
  • Optional 64K random-input check: passed one request with 65,536 random input tokens and 512 output tokens: client TTFT 29.684 s, scheduler prefill-to-first-token 29.644 s (~2,211 tokens/s), C1 decode 97.19 tokens/s. The server retained four slots (only one active request), with a 131,072-token aggregate pool and 98,304 session limit. Later chunks use Atlas's sparse/plain fallback beyond the 32K native sparse limit. An initial single-slot startup was correctly refused for insufficient workspace; the retry changed configuration only. No OOM/swap; both ranks exited cleanly. This is not a context-maximum or retrieval-quality result.

The four switches remain opt-in. Their documented default-promotion criterion requires repeated interleaved comparisons and isolation of each switch's contribution. Results and limits record timing definitions, thinking behavior, memory minima and advisories.

Previous main-integration qualification

The following results belong to the preceding merge and do not qualify the new runtime. Merged implementation: a37b789bec6dc2def8128c257d465f923c07a4a8.

  • Fresh CPU suite: 7,501 passed, 0 failed, 205 ignored. Formatting, both Clippy configurations, all-features test compilation, rustdoc, and six static checks passed. CPU linking stubs do not execute CUDA.
  • A fresh native GLM image passed four bounded profiles on the pair: API/schema/tools, C1/C4 repeated output parity, cancellation/reuse, approximately 6.4K-token needle checks, resident prefix reuse, and actual KV/SSM restores from both NVMe modes on both ranks. All eight rank processes exited cleanly, no swap or memory-guard trips occurred, and the original service was restored and verified. Runtime advisories and allocation-accounting limitations remain recorded.
  • Seven cross-model GPU gates passed: warm/cold TTFT, vision fidelity, video fidelity, SSM state poisoning, decode floor, and agentic webserver (10/10 cases).
  • Concurrency sweep failed its C16 throughput floor. The merged build measured 63.1 aggregate tokens/s against 72.0 required. A fresh controlled run of unmodified main at e29809db reproduced the failure at 63.2 tokens/s, using the same hardware, checkpoint, builder, benchmark settings, and thresholds. Both completed every request with 320 output tokens and zero request errors. This is a failure also present on main, not a passing qualification; neither result was overwritten and no threshold was lowered.
  • The 1,004-case tool-calling accuracy gate failed its normalized floor: overall 86.45 met the 86.10 floor, but normalized 85.07 missed 86.50. The separate 995-case run was interrupted after 559 cases when restoration began; it has no completed score. There is no corresponding main-branch accuracy control, so the accuracy failure is not attributed to main. These terminal results supersede the earlier in-progress status; thresholds and failed receipts are unchanged.

The committed October 15 results retain their original measured revision and do not qualify this merge. The deployment recipe provides both ranks' commands, a bounded FP8-cache starting configuration, explicit optional DFlash2, and network/VPN guidance.

Notes for reviewers

Atlas owns loading, scheduling, distributed KV/SSM state and kernel dispatch, and builds its prefill sources without serving through another engine. The new checkpoint loader touches shared scale decoding, file loading and ownership tracking. The tool/JSON union changes shared grammar and sampling code. CPU tests and bounded GLM checks cover the current update; the cross-model GPU results above retain their preceding source revision.

Source pins, licenses and contributor credits are in docs/glm-prior-art.md, docs/porting/glm53-fp4local-sources.json, the prefill source ledger and native vendor notices, including Jason McCartney's Enntity/SparkGLM work. Apache-2.0 vLLM/FlashInfer reference functions used by test generators retain their notices in third_party/csf_references; small NVIDIA checkpoint fixtures retain separate upstream terms in test_data/FP4_LOCAL_NOTICE.md. Target and optional draft checkpoint terms remain separate. This integration is AI-assisted; Reiner Schmidt is the submitting contributor. Reiner confirms that he has Jason McCartney's permission to use his work. Atlas maintainers should confirm whether that permission satisfies their CLA and commercial-relicensing requirements and resolve the remaining contribution-policy questions. No CLA signature or additional grant is asserted on another contributor's behalf.

Historical benchmarks retain their measured revisions. The current GLM validation is bounded; no enlarged-capacity or general accuracy claim is made.

CLA

Mango-kid and others added 30 commits October 15, 2026 02:30
Extract the model-independent compiler flag and closure-attestation prerequisite from native GLM integration. No GLM kernel sources or model registration are included.

Provenance: exact patch from d8bef5fc1e540707a6af58c32f78534e92ef8464 by Reiner Schmidt; underlying Atlas build and provenance machinery retains its original contributors.
Extract the generic arena accounting and hybrid dense/MoE reader-sizing fixes. Existing latent and normalization allocations now contribute to the reservation total. Dense models retain their sizing, while hybrid models reserve the activation formats their enabled readers consume.

Provenance: selected exact final hunks from65706c9b; sizing work by Jason McCartney in536dde355f622bb9ffede185d24f832451b4e974 and imported history e0bdf666. Original Atlas buffer implementation retains its contributors.

Validation: total-byte tests failed on the two missing allocations; hybrid test failed on absent scratch. All19 buffer tests pass with CI fail-fast GPU link stubs.
Extract reusable positional record I/O, reserved files, exclusive owner-only creation, filesystem classification and stale-file cleanup. Keep cache/model policy out of this storage prerequisite.

Provenance: exact atlas-tier subtree delta from Jason McCartney,361e54ecaa02071e916cdf3dd3a27c7d68e89e40, preserved at65706c9b. Existing Atlas storage authorship remains intact.

Validation: atlas-tier unit/integration/doc tests pass, including concurrent runs and direct I/O on the local filesystem.
Expose process-owned memory growth using NVML and the allocation ledger, plus anonymous and pinned host memory accounting. Keep GLM admission and KV budgeting policy in the dependent model change.

Provenance: runtime-only hunks from63fc8c473fefe6489fb1cb3d351fe0832c3eb701 by Jason McCartney; only patch context was adapted to omit unrelated PDL wiring. Existing Atlas allocator authorship remains intact.

Validation: spark-runtime CPU unit suite passes324 tests with4 ignored GPU tests, using CI fail-fast GPU library stubs.
Extract the complete generic communication subsystem: per-rail GID discovery, bootstrap agreement and deadlines, peer lifetime monitoring, host command ring, and graph-capturable one-shot collectives. No GLM model code is required by this prerequisite; dependent model code supplies optional kernel handles.

Provenance: exact final spark-comm and atlas-rdma subtrees and common rdma_oneshot.cu from 65706c9b. Jason McCartney source series includes dad333c8, b9a3b2a8, 380ff734, 6bee4a38, 9a89b8db and 2987a78f. Preserve in-source attribution to Jason Cook/local-inference-lab b12x RoCEnante and mmastrac arx for protocol ideas; no code imported from unlicensed sources.

Validation: default-profile CPU tests pass (26 atlas-rdma, 47 spark-comm); real verbs Rust paths type-check under explicit cfg without linking. All six prerequisite crates pass clippy --tests and fmt. NIC, CUDA execution and C verbs compilation remain untested on this host.
Extract the checked native ABI, source build, canonical layout and preload
contract before GLM model wiring so numerical and allocation requirements
can be reviewed independently. No external GLM engine or adapter is used.

Source: cf4bcc705934742f05fb876d345681e32f545495, 0404448f69a5882f30532b1cb413e0123cb76f5c,
59295a453401772e90eada42e4419fd2f4935920, 147cf69b450c1050a4d7ffe17275ff80aa25fe08.
Device code: MoonshotAI/FlashKDA at 1ce47ea3bb22c84eb9cc665028399cf35e8ffb0b;
MIT license, copyright, source hashes and modifications retained in vendor/.
Integration prior art: Jason McCartney / Enntity and Atlas contributors.

Validation: spark-runtime CPU unit/integration/doc tests, clippy and fmt.
This extraction has not been independently GPU-qualified.
Extract Jason McCartney / Enntity compiler changes from 5f5e8e9 and 4030dd6 as an independent prerequisite. Preserve source bytes and attribution; leave server rejection policy and GLM scheduling to later changes.
Keep Poolside function headers buffered until validation and flush pending
content consistently when streaming generation finishes. Add parser and
sanitizer regression coverage independent of model-specific call sites.

Extract exact source from corrected native core 65706c9b. Credit Jason
McCartney / Enntity for 8d260cb8 and upstream 1f98cd0 (import e0bdf666),
and Reiner Schmidt for c7cc091a. Existing licenses and notices are retained.

Validation: 2408 server tests passed, 12 ignored; spark-server clippy --tests;
workspace fmt. Earlier unrelated TUI environment/timing failures are retained
in the local extraction audit. No GLM runtime or scheduler wiring is included.
Route remote video through the video MIME policy, carry media for every
independently scheduled blocking choice, and honor raw-completion context
budgets and explicit request deadlines. Cover request decoding, remote media,
and real blocking dispatch with model-independent fixtures.

Extract source from corrected native core 65706c9b. Credit Jason McCartney /
Enntity for upstream 1f98cd0 (import e0bdf666) and Reiner Schmidt for the
pre-existing multi-choice media fix 5e483b06. Preserve original license notices.

The vision regression uses the original test path with a local generic app
fixture instead of the native core's GLM fixture. Its baseline witness fails
on choice 1 losing media; the production fix passes. The native-core stage
will restore its original consolidated fixture and test registration.

Validation: API and completion regression tests, parser/grammar coverage,
spark-server clippy --tests, and workspace fmt. GPU qualification applies to
the integrated source receipts only, not this independently derived branch.
Load the NVIDIA NVFP4 checkpoint and execute GLM attention, KDA, routed
experts, native sparse prefill and optional DFlash through Atlas. Keep
replicated KV in this first model stage; restore token sharding and NVMe
prefix caching separately. Retain SSM spill agreement and anonymous-file
cleanup, allocation rollback, numerical tests and native source notices.

This is a dependency-aware extraction of corrected core65706c9b, derived
from the Enntity candidate and reconciled with Atlas base7ffd183f. Shared
compiler, transport, memory, storage, KDA and server fixes are prerequisites.
Developer performance harnesses follow separately. The generic blocking
media regression fixture now shares the qualified GLM fixture again.

Credit: Jason McCartney / Enntity for the imported GLM architecture,
communication, context and verification work; Atlas contributors for the
base runtime; NVIDIA and MoonshotAI for credited native device sources.
Full original commits, licenses and source pins remain in docs/porting,
docs/glm-prior-art.md and vendor provenance manifests.

Source:65706c9b045cdc3569ddb0b1857406a683528017.
Context extraction:8e2ea922de58c52b497223935f41867dc58938b8.
Historical GPU measurements do not independently qualify this boundary.

Co-authored-by: Jason McCartney <[email protected]>
The retained BF16 GEMM and FP8 split-K probes share this module. Keep the exact helper from65706c9b with its current consumers; the optional MoE benchmark will reuse it in the following stage. Credit: Jason McCartney / Enntity and Atlas contributors.
Restore initial context features after the replicated-cache native core.
Keep shard geometry, ownership, sparse attention, prefix records, disk I/O,
configuration and their tests together. Shared SSM agreement and anonymous
file safety already remain in the core; consolidate them with the full
context helpers here. Performance-only developer harnesses follow separately.

Source: Jason McCartney / Enntity commits361e54ecaa02071e916cdf3dd3a27c7d68e89e40
and8b07f620d1f1dd496bc1dd6d2914919a658bbcc3, reconciled in corrected
native core65706c9b045cdc3569ddb0b1857406a683528017. Native Atlas prefill
and subsequent allocation/safety fixes remain intact. The exact feature
restore patch is checked against the preserved source tree.

Co-authored-by: Jason McCartney <[email protected]>
Restore the standalone performance examples, paired communication probe,
and CUDA microbenchmarks after their native runtime dependencies. Keep
correctness oracles, bit checks and native qualification tests with the
implementation. The example declarations and optional NCCL feature travel
with the examples they enable.

Source: corrected core65706c9b045cdc3569ddb0b1857406a683528017.
Credit: Jason McCartney / Enntity and the Atlas contributors named in the
preserved source history and prior-art documentation.

Co-authored-by: Jason McCartney <[email protected]>
Restore RC2 canonical verification, copy drafts, sharded disk prefixes and
context optimizations on the explicit initial context prerequisites.

Exact staged source: cb74ee4af8b968b86b9c41dc994776b6043f24bd.
Original imported source credits, license notices and history maps remain
in docs/porting and native device-code provenance. Original human work by
Jason McCartney / Enntity and Atlas contributors is retained. This is a
local dependency stack; historical receipts retain their measured revisions.

Co-authored-by: Jason McCartney <[email protected]>
Carry the previously reconciled native RC4 optimization and context work
without merging external engine adapters.

Exact staged source: 7b2bfe516d609053e9b9cd9b0603b74ed6fffb06.
Original imported source credits, license notices and history maps remain
in docs/porting and native device-code provenance. Original human work by
Jason McCartney / Enntity and Atlas contributors is retained. This is a
local dependency stack; historical receipts retain their measured revisions.

Co-authored-by: Jason McCartney <[email protected]>
Update the locked TLS dependency for RUSTSEC-2026-0346 through RUSTSEC-2026-0349. Keep all other dependency versions unchanged.
Port Jason McCartney / Enntity SparkGLM tool-choice and response-format union support, including branch-mass selection and reasoning/speculation boundaries. Keep strict response-format requests fail-closed when the selected parser has no tool grammar.

Original commits and source credits are recorded in docs/porting/tool-json-union.json. Validation: 2771 server unit tests passed; all-features clippy, rustdoc and static checks passed. The live two-turn probe is included for subsequent GPU validation.
Adapt Jason McCartney / Enntity side-projection packing, planar KDA convolution, fused HC input normalization and sequence-parallel seam overlap. Preserve Atlas native KDA/sparse kernels and current-main Qwen prefill pipelines. Check all four switches in rank startup agreement.

Exact upstream commits, adaptations and validation limits are recorded in docs/porting/GLM_5_3_FLASH_PREFILL.md. All switches remain opt-in pending local GPU equivalence and timing. Focused CPU tests: 32 passed; spark-model clippy and rustdoc, formatting and kernel shadow checks passed. No GPU result is claimed.
Keep the initial FP8 cache bounded, identify the pinned checkpoint layout and avoid linking a public API document to a private constant.
@Mango-kid Mango-kid changed the title glm: add native prefill and RC2/RC4 updates for dual DGX Spark glm: add native prefill and FP4-Local support for dual DGX Spark Oct 20, 2026
@github-actions github-actions Bot added the needs-rebase Conflicts with main — its green checks are NOT real (GitHub skips merge-commit workflows) label Oct 21, 2026
@AzeezIsh

Copy link
Copy Markdown
Contributor

@Mango-kid I rebased this onto current main + #198 (Qwen FP4-Local TP2) as draft #223, stacked on #198, with full credit to you. There were 12 conflicted files; each resolution is written up in docs/ports/199-on-198.md on that branch. CUDA builds and a Qwen regression gate are running on our two-GB10 pair, and SparkGLM qualification comes next. If you'd rather keep it here, I can push the merge to your branch instead. Tracking: #220.

AzeezIsh added a commit that referenced this pull request Oct 28, 2026
#198's host-decode set scooped every module with no registered native
consumer into mxfp8_to_bf16. On glm5_next (no registered consumers) the
FP8_PB_WO shared experts — E4M3 weights with 128x128 FP32 block scales —
hit that codec and failed its per-32 E8M0 shape check at build:
GLM-5.3-Flash FP4-Local would not load on port/199-on-198.

Restrict host_decode_modules to MXFP8 plus NVFP4-family modules without a
native consumer, and have expand_module require the declared MXFP8 algo
before calling mxfp8_to_bf16. FP8_PB_WO tensors stay resident for the
model's own loader (#199's shared_expert_requantizes_from_fp8_blocks
path). Qwen FP4-Local unchanged (byte-identical).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
a9770b5 (tool-guard fixture opt-out in glm_tool_boundary_tests) and
9e5b619 (qsa-aux-kv-budget on kv_carveout) both adjust #199-added code
and were dropped from the lower stack per the restack rules; they land
here on top of the merge.
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
The merged parser produced None for field-less quantized_layers entries;
Enntity stores a plain string default, and consumers (incl. the #199
parse test's 438 MXFP8 count via Some("")) expect Some("").
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@maplepaladin73

Copy link
Copy Markdown
Contributor

GLM-5.3-Flash NVFP4 on our dual DGX Sparks, using the recipe branch (Mango-kid/atlas@release/glm53-nvfp4, commit 34399129d, image atlas-glm53-flash:local 696a3e3150a8, built on both hosts, ids match). Checkpoints: nvidia/GLM-5.3-Flash-NVFP4 and incoai/GLM-5.3-Flash-DFlash2, local dirs on both hosts, same files on both.

Our env vs the recipe: HEAD_FABRIC_IP=192.168.200.1, IFACE=enp1s0f0np0, HCA=rocep1s0f0,roceP2p1s0f0 (the two RoCE rails that are up on our pair), otherwise the recipe's 32K config verbatim. Preflight on both ranks: 116-117 GiB available, 0 swap, no GPU processes.

  • Run A (plain decode, recipe as written): failed at preflight. Both ranks exited during load with: Error: independent GLM C4 requires ATLAS_GLM_C4_DECODE=1 and exact glm5_next. The recipe's --max-batch-size 4 selects the independent C4 decode path, which additionally requires ATLAS_GLM_C4_DECODE=1. Rerunning with that flag added (or dropping batch-4) should start; we didn't rerun it in this window.
  • Run B (DFlash2, --dflash --dflash-gamma=8 --dflash-window-size=2048 --mtp-gate=force): all tests passed. 2+2 = "4"; tool call get_weather {city: Toronto} correct; 12,098-token prompt: TTFT 6.13 s, decode 47.7 tok/s, small request 53.7 tok/s. Rank logs saved (B-rank0/1.log, ~700 lines each).
  • Run C (four prefill switches): skipped, since A failed.

Full startup logs and the test script are on our side; happy to paste either here. Drafted by Emily (AI assistant, Mistral Large 4) for maplepaladin73.

@AzeezIsh
AzeezIsh merged commit 8fc1a96 into Atlas-Inf:main Nov 1, 2026
1 check passed
AzeezIsh added a commit that referenced this pull request Nov 1, 2026
…series; data-angel)

Qwen-side KL + bench gate on reiner + spark2 (#220, receipts on the PR) at fa528fc: KL 0 vs main over 34,245 x2 + 36,765 positions incl. vision, BFCL 87.54/86.85 = main, greedy 8/8, tools 21/21, bench neutral. 354da21 = fa528fc + main (only the #310 conflict area changed). GLM-side results are data-angel's (see the PR). CI green except the PR benchmark gate.
@Mango-kid

Copy link
Copy Markdown
Contributor Author

@maplepaladin73 Thanks for testing both paths and reporting the plain-decode startup failure. Follow-up: #316 uses one active/admitted sequence for plain decode at 32K with FP8 KV, and explicitly reserves the native sparse path's 4100-row workspace. The optional DFlash2 profile retains four slots.

Adding ATLAS_GLM_C4_DECODE=1 alone would not repair this particular profile: independent C4 also requires BF16 KV, a smaller context and other policy settings. The follow-up changes only the recipe, with shell/argument checks; it has not had a fresh GPU launch test because our pair is serving other workloads.

I also answered the benchmark-profile question on #242. The 97.19 C1 and 168.85 C4 figures were from different checkpoints/context profiles, not a matched FP4-Local pair; the reply links the original receipts and gives the exact settings.

vcruz305 pushed a commit to vcruz305/atlas that referenced this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Conflicts with main — its green checks are NOT real (GitHub skips merge-commit workflows)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants