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 - #913

Merged
juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup
Oct 28, 2026
Merged

juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

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

Supersedes #905.

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. The extents run shard by shard, so a part holds one shard open at a time however many shards it spans. 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.
  • crates/gpu/src/parts.rs test: a_placed_source_plans_a_cards_parts_once_a_room also asks for a plan whose output.weight has other card bytes at the same room and expects a fresh plan, so a memo key that ignored the card's tensors would fail it.
  • tools/gate-batch.sh: script_refs skips a quoted string touched by a glob star, so the case pattern *"release/build.sh"* in tools/box.sh is no longer taken for a script the file runs. Without it the fixture --classes walk fails once tools/release/build.sh changes. New self-test case sr-pat.
  • 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, and cargo clippy was clean for bloomery-gpu-gates and bloomery-model-hf. 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. 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 with just release-build 0.3.10 in a clean checkout of each side, 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, and the mutant each test must catch. The parts:: gate ran on a GB10. The part:: tests ran on another Linux machine, on an ext4 drive that takes direct reads. The third call ran on a GB10.

$ bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- parts::
test result: ok. 7 passed; 0 failed; 1 ignored; 0 measured; 432 filtered out; finished in 0.05s
$ cargo test -p bloomery-model-hf --lib part::tests
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 89 filtered out; finished in 0.05s
$ bash tools/gate.sh --gpu --oxide -p bloomery-gpu --release --lib -- --include-ignored context_tests::hw_a_refused_cubin_loads_its_ptx
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 439 filtered out; finished in 17.24s
  • Taking a tensor's bytes from its extent's start instead of its own offset fails four of the part:: tests, including the folder against GGUF equality tests.
  • Holding every visited shard open fails a_whole_stack_over_more_shards_than_open_files_reads under a soft limit of 32 open files with "Too many open files".
  • Staging in arrival order instead of plan order fails a_run_stages_in_order_as_its_reads_arrive.
  • A memo key that compares only the room and the host bytes fails a_placed_source_plans_a_cards_parts_once_a_room (left: 2, right: 3).
  • Never taking the refusal arm of load_or_ptx fails hw_a_refused_cubin_loads_its_ptx with the driver's 209 (this mutant ran on the measured revision).
  • The same test reads the PTX through file_ptx from a copy of the test binary whose .oxart is renamed to .oxart.ptx with objcopy, as the release build does. Pointing PTX_SECTION at another section name fails it, because the copy then yields no PTX.
  • 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: a maintainer runs the full library gate.

Not run: the x86-64 archive install, a start under the oldest supported driver (R580), the tests that need an RTX 5090 machine, and cargo clippy on bloomery-gpu. 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 초안 리뷰는 제가 직접 했습니다.

…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.
…uses an answer

The test held the same card tensors in both plans, so a key without the card's tensors
still passed. A plan whose card tensor has other bytes is now planned again.
@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 failure paths for the reader threads, the extent merge, the cubin fallback and the release step, and the code blocks each one.

Non-blocking

⚠ The refusal set is checked on one driver only: crates/gpu/src/lib.rs:2585. refuses_image accepts three codes. The cubins are linked by driver 595 and docs/serving.md supports R580+. The PR body says the R580 start was not run and the refusal was made by editing the SM byte. If R580 returns another code for a cubin it cannot load (for example CUDA_ERROR_INVALID_SOURCE), the server fails at start with the driver's error, with no PTX fallback. Please run one start on the oldest driver you can reach, or say in the PR which codes it returned.

⚠ The open-file-limit test can pass without checking anything: crates/model-hf/src/part.rs:1203. When Wholes::read returns None (a temp dir whose filesystem refuses direct reads), the test prints a line and passes. The mutant "hold every visited shard open" then stays green. Direction: create the shards where direct reads work, or fail the test on None and let the machine without direct reads skip it by name.

⚠ Wholes::read is new and complex on its own (crapper 19): crates/model-hf/src/part.rs:413. It builds extents, sizes the buffer, opens shards and fills slots. The extent build (first loop) is the part that could stand alone. Not needed now.

Checked

  • Duplicates: 9 new items checked (load_or_ptx, refuses_image, file_ptx, read_staged, Extent, Wholes, cubin, cubin_bundle, GLOB_QUOTE), none duplicated; no other cuLink* call or .oxart.ptx reader exists. dryer: 0 pairs.
  • Complexity: Wholes::read is a new complex function (⚠ above). oxart_jit::run 12 to 19 is one added branch that delegates to cubin_bundle; harmless. bloomery_serve::drive::run 36 to 44: the diff changes only a string constant and a doc there, so the rise is not from this change.
  • Silent failure: 7 sites followed (reader mask, read, stage, no-PTX refusal, non-refusal driver error, short direct read, empty link image). Each ends in a named error. Reader hang paths (a failing mask, a panicking reader, a stage failure) all end the recv loop or drop the receiver.
  • Extent merge: sorted by (path, start); start <= e.end() merges touching spans only; slots stay DIRECT_ALIGN multiples; the EOF check is per tensor.
  • Tests: mutants named in the PR body match production lines. The stage-order test fails on arrival-order staging. The open-file test fails on held shards where direct reads work (⚠ above).
  • Gates: no band or tolerance moved. The unsafe ratchet PIN is dated, and its 5 blocks match the 5 unsafe blocks in cubin.
  • Escape catalog: C1 to C4 checked on build.sh and gate-batch.sh. No match (set -euo pipefail in build.sh; no pipe swallows gpu-gate.sh's exit code).
  • Performance: load path only; no decode or prefill code changed.

Notes

  • The PR body measures an "earlier revision" of the head and names no head commit hash, and its base 625bf506c2f6 is not this PR's base. The CONTRIBUTING.md evidence list asks for both hashes, so gpu.json says no evidence.

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

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit d74b53e into midagedev:main Oct 28, 2026
7 checks passed
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