Skip to content

gpu: a parts load stages each part as it and the parts before it are read, so a run's staging overlaps its reads - #905

Closed
juliankang4 wants to merge 3 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup
Closed

juliankang4 wants to merge 3 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

DGX Spark(GB10)에서 bloomery-serve -m <폴더>로 FP4-Local 체크포인트를 띄울 때 서버가 시작해서 health가 열리기까지의 시간을 줄이는 PR입니다. release archive가 GPU 코드를 미리 컴파일해 담고, 체크포인트 읽기를 줄입니다.

Part of #565.

What and why

bloomery-serve -m <folder> on a DGX Spark spends its start in two places: the driver compiling the GPU code on the first start, and reading the checkpoint from disk. This PR shortens both for an FP4-Local folder.

  • tools/release/build.sh: the GB10 archive carries its kernels compiled. oxart_jit --cubin links each bundle's PTX with the driver on the GB10 that builds the archive. The binary's .oxart section then holds those cubins and the PTX stays beside it as .oxart.ptx; --check requires both sections. A first start from the archive compiles nothing. If the driver refuses a bundle's cubin (the invalid-image, no-binary-for-GPU or unsupported-PTX-version errors), load_or_ptx in crates/gpu/src/lib.rs loads that bundle's PTX from .oxart.ptx and the server prints one line saying so. Any other failure, and a refusal with no PTX to fall back on, keeps its original error. The x86-64 archive and a source build are unchanged.
  • crates/model-hf/src/part.rs: a folder part reads the stored tensors that touch as one extent into one buffer, with one open per shard. Before, each tensor was opened, probed with a 4 KiB read and read again in a small request. Wholes::read replaces read_whole. A shard on a filesystem without direct reads now sends the whole part through the mapping, where it used to send only that one tensor.
  • crates/gpu/src/parts.rs: read_staged runs a load's readers on scoped threads, each set to the pool's CPUs first, while the main thread stages parts in plan order as they arrive. Staging overlaps the reads. The host peak is unchanged, because a run's parts coexist until release as before. A read, mask or stage failure ends the load with a named refusal. tools/spawn-allow.txt has one row for these readers.
  • The unsafe ratchet moves gpu-gates from 109 to 114 blocks with a dated PIN, for the five driver calls oxart_jit --cubin makes to link a bundle, each with a SAFETY line.
  • Docs and text that said the first start compiles the GPU code now say the GB10 archive carries it compiled: README.md, docs/performance.md, docs/evaluating.md, docs/serving.md, docs/contrib/dgx-spark.md, tools/release/README.release.md, and the first-start line in bloomery_serve.rs and gate_clef_serve.rs.

The cost is a larger archive binary and a longer release build, both listed under What I ran. Decode and prefill code are not touched.

Release notes: Changed: the GB10 release archive carries its GPU code compiled, and an FP4-Local folder loads with fewer reads, so a DGX Spark server starts sooner.

Code shape

  • No second copy. Direct reads reuse DirectFile and aligned_span, masks reuse set_mask and the pool's topology, and the bundle rebuild reuses oxide_artifacts::ArtifactBundleSpec. The per-tensor Whole and read_whole are removed.
  • Model code holds only architecture facts. No model file changed.
  • Dead code is gone. read_whole and the per-tensor Whole are deleted, and Extent::end has two callers.
  • No silent failure. A reader's mask failure, a read failure and a stage failure each end the load with a named refusal. A cubin refusal prints a line before the PTX is loaded, and a refusal with no PTX keeps the driver's error.
  • Comments state what is true now. The new comments carry no dates, numbers or issue numbers.
  • No relaxed gate. No band, tolerance or lint moved. The unsafe ratchet rose with a dated PIN for new code only.
  • cargo fmt and cargo clippy are clean on what I touched: cargo fmt --check passed on the three changed crates on the measured head, and cargo clippy was clean for bloomery-gpu-gates and bloomery-model-hf on an earlier head of this branch. bloomery-gpu needs CUDA to lint and was not linted here.

Duplication found or removed (path:line), or "none": none. The duplicate scan reported no candidates.

What I ran

All timed runs are on one DGX Spark with an installed archive, built and installed with the release scripts for each side. The base is main at 625bf506c2f6, and the head is this branch's three commits on that base; they were then rebased onto current main without a conflict, and main changed none of their code files. The model is nvidia/Qwen3.8-Flash-Next-FP4-Local at revision b9ce18a6887e18c089fdea8509a33e63429a3300, served with bloomery-serve -m <folder> and no other flag.

Build both archives, install each with tools/release/install.sh --version v0.3.10 --prefix <dir>, then start each binary three rounds, base cold, head cold, base warm, head warm. A cold start uses an empty driver JIT cache and a dropped page cache for the checkpoint, and a warm start keeps both. The metric is the time from spawn to a 200 from /health.

RELEASE-BUILD arm=base rc=0 seconds=509
RELEASE-BUILD arm=head rc=0 seconds=527
release: checks passed on <head archive>/bin
INSTALL arm=base rc=0
INSTALL arm=head rc=0
GREEDY-SAME=1 replies=26

Each cell is the median of three starts with its range in parentheses.

Metric Base Head Difference Ranges overlap
Start to health, cold 76.34 s (75.62 to 76.80) 49.38 s (49.15 to 50.71) -26.96 s (-35.3%) no
Start to health, warm 61.18 s (58.79 to 61.99) 49.19 s (49.13 to 49.37) -11.99 s (-19.6%) no
Checkpoint upload, cold 44.19 s (44.00 to 45.38) 34.84 s (34.82 to 35.93) -9.35 s no
Checkpoint upload, warm 46.23 s (43.96 to 47.31) 34.66 s (34.60 to 34.76) -11.57 s no

Cold start to health is 26.96 s shorter (76.34 s to 49.38 s); warm start is 11.99 s shorter (61.18 s to 49.19 s); the ranges do not overlap. The driver JIT cache after a cold start is 34,811,323 B on the base and 0 B on the head, which compiled nothing. The 26 greedy replies of the head's starts are identical to the base's. The installed bloomery-serve grows from 62,722,432 B to 75,092,768 B, the archive from 17,574,765 B to 20,294,039 B, and the release build from 509 s to 527 s.

Refused cubin: on the same card I changed the SM byte in each of the head's five .oxart cubins to another card's, so the driver returns its no-binary-for-GPU error. The base's loader fails at once on that image. The head loads the PTX and serves.

STARTUP arm=refused-pre-fix up=0 up_s=3.59
bloomery-serve: failed to load embedded CUDA module: DriverError(209, "no kernel image is available for execution on the device")
STARTUP arm=refused-head up=1 up_s=67.16
bloomery-gpu: the driver refused the GPU code compiled for the card (DriverError(209, ...)); loading its PTX, which the driver compiles
GREEDY-SAME=1 replies=26

Tests on the same GB10, each with a planted mutant that must fail. The part:: tests ran on an earlier commit of this branch whose part.rs equals the head's.

$ cargo test -p bloomery-model-hf --lib part::
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out
$ cargo test -p bloomery-gpu --release --lib (parts::tests::a_run_stages_in_order_as_its_reads_arrive, context_tests::hw_a_refused_cubin_loads_its_ptx)
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 437 filtered out; finished in 18.10s
  • Taking a tensor's bytes from its extent's start instead of its own offset fails four of the six part:: tests, including the folder against GGUF equality tests.
  • Staging in arrival order instead of plan order fails a_run_stages_in_order_as_its_reads_arrive.
  • Never taking the refusal arm of load_or_ptx fails hw_a_refused_cubin_loads_its_ptx with the driver's 209.
  • cargo fmt --check on bloomery-gpu, bloomery-model-hf and bloomery-gpu-gates ended with exit 0 on another Linux machine.

The checkpoint upload is still the largest part of a head start, 34.84 s of 49.38 s cold.

just gate-gpu-lib not run: the full library gate was not run on this head, and a maintainer runs it.

Not run: the x86-64 archive install on this head, a start under the oldest supported driver (R580), the tests that need an RTX 5090 machine, and cargo clippy on bloomery-gpu. A decode A/B was not run because decode and prefill code are untouched. The refusal was made on driver 595.84 by changing a real cubin, so the code a different driver returns for an unusable cubin may differ from the three the fallback accepts.

Hardware

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

One DGX Spark, Linux aarch64.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: I built five failure scenarios against the staged read, the extent merge and the cubin fallback; code in the diff blocks each one.

Non-blocking

⚠ The descriptor-limit test passes when direct reads are unsupported: crates/model-hf/src/part.rs:1203. On a filesystem that refuses O_DIRECT, Wholes::read returns None before it opens a second shard. The inner test only prints, so the planted mutant (every shard held open) stays green. Direction: panic on None in the inner test and skip by name in the outer test when the temp dir cannot do direct reads.

⚠ The ordering test does not check overlap on a one-thread pool: crates/gpu/src/parts.rs:654. read_staged starts pool.threads().clamp(1, run.len()) readers; with one reader the parts arrive in order, so the arrival-order mutant passes. Direction: assert that the pool has at least 2 threads.

⚠ object has a literal version in crates/gpu/Cargo.toml:41, while oxide-artifacts comes from the workspace. gpu-gates reads .oxart through oxide-artifacts with object-read (ptx.rs:148). Question: can exe_ptx read .oxart.ptx through that feature without a new direct dependency?

Also 1 minor: the new run branch in oxart_jit.rs could be a write_cubins function.

Checked

  • Duplicates: 11 new items checked, none duplicated; dryer found 0 pairs. The two FIRST_START strings were already a pair and both are updated.
  • Complexity: Wholes::read 19 is a new function and fits R12. oxart_jit::run 12 → 19 is a branch added to an existing function (minor item above).
  • Silent failure: 9 sites followed; each ends in a named refusal or the original error; None from a refused shard falls back to the mapping.
  • Scenarios blocked: stage error while readers run, touching or duplicate names in one extent, short read at end of file, no PTX section on x86, empty run.
  • Tests: the mutants in the PR body map to assertions; two weak spots are the ⚠ items.
  • Gates: unsafe ratchet 109 → 114 with a dated PIN; the five new unsafe blocks carry // SAFETY:. No band, tolerance or lint moved.
  • Performance: load path only.
  • Escape catalog: C1 to C4 do not match in build.sh.

Notes

  • just gate-gpu-lib and cargo clippy -p bloomery-gpu were not run, as the PR body says. A maintainer must run the gate before merge.
  • The body has no head hash and the tests ran with cargo test, not just gate-*: the GPU evidence is incomplete.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/gate_clef_serve.rs, crates/gpu-gates/src/bin/oxart_jit.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

…river's cubins, so a first start compiles nothing

oxart_jit --cubin links each .oxart bundle's PTX through the driver on the building GB10 and writes a section of the same bundles with the cubin as their payload; the release build makes it the binary's .oxart and keeps the PTX as .oxart.ptx. cuda-core's loader takes a bundle's cubin before its PTX; when the driver refuses that cubin as an image it cannot run, bloomery-gpu's bundle loader loads the same bundle's PTX from .oxart.ptx instead and says so on one line.
…into one buffer, one open a shard

A routed expert stack of Qwen3.8's FP4 folder is about 4,000 stored tensors. Each was read alone: an O_DIRECT open, a probe read, a buffer of its own and one small read, so seven parallel part reads took the drive at under 2 GB/s of its 5. The part now opens each shard once and reads tensors whose aligned spans touch as one extent.
…read, so a run's staging overlaps its reads

A run of a folder load read every part, then staged them one by one while the drive sat idle; on Qwen3.8's FP4 folder the drive alternated between 3.3 GB/s and nothing each second. Readers now hand each part to the staging thread as they finish, and the parts still stage in plan order.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-usab-startup branch from dfaeb52 to c58a5aa Compare October 28, 2026 05:34

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: carried from dfaeb525, not re-reviewed.

The approval of dfaeb525 stands for c58a5aa2. This pull request's 3 commits are the same patches in the same order: git patch-id --verbatim (the changed lines, the lines around them and whitespace) and the subject are equal for every commit. That review ran under the reviewer instructions, tools and slag ledger that review this head, and it approved.

The base moved, and changed none of the files this pull request changes.

A carry covers each patch's own lines and the lines around them. What the base changed elsewhere is covered by CI on this head and by the landing gates.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/gate_clef_serve.rs, crates/gpu-gates/src/bin/oxart_jit.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

Superseded by #913.

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

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant