Skip to content

dgx-spark: P0, the host crates and the engine build on aarch64 (design R) - #14

Merged
midagedev merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-p0
Oct 10, 2026
Merged

midagedev merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-p0

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

What and why

P0 of docs/contrib/dgx-spark.md, with answer 1 of §5. Part of #13. The tree did not compile on aarch64:
crates/qdot/src/lib.rs imports std::arch::x86_64 unconditionally, and the AVX2 code in qdot, deepseek2/attn.rs,
ops.rs and markov-accept is reached by every engine crate. With this change the host chain and generate_qwen3moe
build on a DGX Spark and Qwen3.6-35B-A3B runs whole on its card. The x86_64 source is unchanged apart from added cfg
lines, and its generated code is the same.

  • Every AVX2 function, #[inline(always)] helper, table and x86-only test carries #[cfg(target_arch = "x86_64")],
    per item, so no #[target_feature] body moves or splits. The only removed lines take dot_row_avx2 out of an import
    list in crates/qdot/tests/qdot.rs.
  • Off x86_64 (design R), qdot::has_features is false, so supports, fuses, has_tile and has_lanes are too.
    dot_row and quantize_col are the scalar mirrors. The host union refuses its stacks through the existing
    HostStack { why: UnsupportedType }, so a plan with host experts stops with the tensor named instead of taking the
    f32 round trip. flash_simd is false, kq_dot_simd and markov-accept panic by name, and warm_touch reads the line
    it would prefetch. tile, r8_tile, pack_group and lanes are unreachable! there, behind tile_kind,
    has_features(Q3_K) and check_lanes.
  • Tests that compare the AVX2 twin with the scalar path, and would pass vacuously off x86_64, are x86_64-only too (the
    flash SIMD and KV prefetch lever pairs).
  • tools/mac-check.sh takes the triple from BLOOMERY_CHECK_TARGET for check and combos, reads that triple's
    BINDGEN_EXTRA_CLANG_ARGS_<triple>, and refuses a value that is not a Linux triple. lint and combos --ledger
    refuse another target, since the lint ratchet and the ledger keys are x86_64's. The header gains the aarch64 pieces,
    and the name has its lever-registry row.
  • tools/recipes.py's self-test pinned qdot's non-pure reason to "x86_64 intrinsics". With that code under cfg, the
    Mac-side classifier reports it from bloomery-threads' Linux paths, which the real-tree line now checks; the
    synthetic cases still cover the x86 rule.

Left out on purpose. .cargo/cuda-oxide.toml keeps its flat target-cpu=znver3, which makes rustc SIGSEGV on aarch64
(#13), so the DGX Spark builds below use a local target-cpu=native copy until S2. The docs are unchanged; this PR
leaves stale the S1 row of docs/contrib/dgx-spark.md ("not done") and "Compile on aarch64" in its §6, and
docs/contrib/local-check.md:14 and :50, whose tools/mac-check.sh:1-12 and :31-35 become :1-15 and :35-39.

Code shape

  • No second copy. The off-x86_64 items hand the call to the scalar code that exists.
  • Model code holds only architecture facts.
  • Dead code is gone. Tables, constants and test helpers only the AVX2 code uses are x86_64-only too, so aarch64
    builds with no warning.
  • No silent failure. Off x86_64 the host tier, kq_dot_simd and markov-accept refuse by name.
  • Comments state what is true now.
  • No relaxed gate.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed: flash_segment_heads repeats its two scalar calls under
cfg(not(target_arch = "x86_64")) so the x86_64 lines stay as they are; folding them into an early return changed the
x86_64 code generation of its caller.

What I ran

On a Mac with the pinned nightly and the CUDA 13.3 headers, the static tier and the aarch64 cross check:

just mac-static upstream/main
mac-static: fmt-check rc 0 in 5 s — rustfmt diff blocks: 0
mac-static: lint rc 0 in 44 s — mac-check: lint ^warning: 41 = the ratchet 41 in tools/lint-ratchet.txt; target <tree>/target, 17 bloomery crates checked or compiled
mac-static: combos rc 0 in 72 s — mac-check: combos rc 0; 37 shapes run, 0 red, 7 skipped (scoped), in 72 s (recipes.py combos: 37 of 37 commands to run, 202 distinct (package, target, mode, features) tuples, 0 green in the ledger, 0 with no input changed since 9d5a106c4, 7 left out by name)
mac-static: check-arch rc 0 in 11 s
mac-static: check-comments rc 0 in 10 s
mac-static: check-defaults rc 0 in 0 s
mac-static: check-levers rc 0 in 7 s
mac-static: check-loads rc 0 in 70 s
mac-static: check-recipes rc 0 in 480 s
mac-static: check-rustflags rc 0 in 0 s
mac-static: check-unsafe rc 0 in 2 s
mac-static: check-waits rc 0 in 0 s
mac-static: total 480 s, base upstream/main, ledger ~/.cache/bloomery/mac-static-ledger.tsv
mac-static: ok
BLOOMERY_CHECK_TARGET=aarch64-unknown-linux-gnu tools/mac-check.sh check
mac-check: check rc 0; target <tree>/target, 17 bloomery crates checked or compiled

tools/mac-check.sh --self-test and python3 tools/recipes.py --self-test pass. The x86_64 assembly of
bloomery-qdot and bloomery-model (--emit=asm, one codegen unit) equals main's apart from the line numbers in panic
locations. The box's gates (just ptx-scan, gate-qdot, gate-ops and the rest of just affected) are yours to run.

On a DGX Spark, in nvidia/cuda:13.3.1-devel-ubuntu24.04 with LLVM 21.1.8 and cargo-oxide at 4da6c138:

cargo oxide doctor                                    # passes
cargo check --workspace --all-targets --features gpu,bloomery-gpu-gates/deepseek41,bloomery-gpu-gates/vision,bloomery-gpu-gates/glm5next,bloomery-gpu-gates/mimo2,bloomery-gpu-gates/clef
    Finished `dev` profile [unoptimized + debuginfo] target(s)
cargo oxide build --arch sm_86 -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe
✓ Cargo build succeeded
BLOOMERY_REF_MODEL=Qwen3.6-35B-A3B-Q4_K_M.gguf target/release/generate_qwen3moe --prompt "The capital of France is" -n 32
whole fit at ctx 4096: the whole load on GB10: fits: need 23799485796 B … of 125095268352 B the card had
load arch=qwen35moe resident_bytes=22788310856 ctx=4096 cache=f16 layers=40 mode=graph … in 13.4 s (runtime value)
text " Paris.\nThe capital of France is Paris.\nThe capital of France is Paris.\nThe capital of France is Paris.\nThe capital of France is"

The tools/recipes.py host-nightly units pass in 17 of the 19 crates. bloomery-qdot (9) and bloomery-model (16)
fail in tests of the fused host tier, which design R refuses: P1's starting list. One is numeric:
swiglu_clamp_matches_ik_rule is one ulp off because swiglu_clamp without AVX2 uses libm's exp.

The 25 tests
  • bloomery-qdot: quantize_col_non_finite_panics_on_both_paths, quantize_col_q8k_first_max_ties,
    quantize_col_random_bit_identical, quantize_col_rounding_ties, quantize_col_saturation_ends,
    quantize_col_subnormal_tiny_scales, quantize_col_zero_blocks_bit_identical (each stops in
    require_quantizer_avx2), rejects_unaligned_k (the supported-type table), swiglu_clamp_matches_ik_rule.
  • bloomery-model: arch::coverage::tests::{a_glm5next_routed_stack_runs_on_a_card_or_the_host, a_qwen38_routed_stack_runs_on_a_card_or_the_host, the_real_mimo2_file_lists_nothing, what_the_mimo2_body_does_not_run_is_an_item}, moe::tests::{a_step_union_reads_the_tier_from_its_slots, a_tier_slot_is_lent_or_refused_by_name, a_warm_lists_what_the_leg_reads_and_never_fills, a_warm_of_a_sidecar_layer_carries_the_groups_of_the_pass, host_layer_build_refuses_a_stack_without_a_fused_kernel, routed_scratch_refuses_a_list_past_its_width, ten_a_column_through_the_narrow_claims, union_call_on_glm_stacks_matches_its_columns, union_call_with_an_up_on_other_bytes_matches_its_columns},
    ops::tests::{matmul_refuses_weight_types_without_an_activation_format, union_stack_refusals_carry_their_context, union_stack_refuses_row_lane_layouts_where_they_do_not_stand}; each meets HostStack/UnsupportedType or a
    fuses that is false.

Hardware

A DGX Spark (NVIDIA GB10, cc 12.1, 48 SMs, 128 GB unified LPDDR5x; 10 Cortex-X925 and 10 Cortex-A725 cores), DGX OS
7.6.0 (Ubuntu 24.04.5, kernel 6.17.0-1032-nvidia), driver 595.84. The host keeps DGX OS's CUDA 13.0; the build ran
in the container above with NVIDIA_DISABLE_REQUIRE=1. No speed numbers here.

AI help

An AI coding agent wrote the code changes and this description, ran the commands above on my machines, and compared
the x86_64 assembly. I did the code review of the diff and the review of this pull request myself.

…"x86_64"), design R off it

P0 of docs/contrib/dgx-spark.md with answer 1 of its section 5. Each AVX2 function, helper, table and x86-only test
carries the cfg per item, so no #[target_feature] body moves or splits; the x86_64 text is otherwise unchanged and its
assembly equals the parent's but for panic-location line numbers.

Off x86_64 qdot's has_features is false: dot_row and quantize_col are the scalar mirrors, the host union refuses its
stacks by name (HostStack, UnsupportedType), flash_simd is false, kq_dot_simd and markov-accept panic by name,
warm_touch reads the line it would prefetch, and the tile and row-lane dispatchers are unreachable behind tile_kind,
has_features and has_lanes. Tests that would pass vacuously off x86_64 (the flash SIMD and KV prefetch lever pairs) are
x86_64-only too. recipes.py's self-test finds qdot's non-pure reason in bloomery-threads' Linux paths.
…es (aarch64-unknown-linux-gnu for a DGX Spark)

check and combos take the triple and read its own BINDGEN_EXTRA_CLANG_ARGS_<triple>. A value that is not a Linux triple
is a named 64, and so are lint (tools/lint-ratchet.txt counts the x86_64 lint) and combos --ledger (its keys do not carry
the target) under another triple. The header says how the aarch64 pieces are made; the lever registry gains the name's
row.
@midagedev

Copy link
Copy Markdown
Owner

완전 감사합니다!!!

@juliankang4

Copy link
Copy Markdown
Collaborator Author

바로 이어서 작업하겠습니다. 다음 PR에 메인테이너께서 해주셨으면 하는 것들 정리해서 적어둘게용!!

@midagedev

Copy link
Copy Markdown
Owner

Thank you. We checked it on our x86 box, rebased on main:

  • just mac-static passes.
  • The ptx-scan of the covering bins is identical to the base.
  • The fixture-tier landing batch passes: 132 gates, red=0.

Merging now. We will update the stale doc lines you listed (dgx-spark.md S1 and §6, local-check.md:14 and :50) in a follow-up commit.

@midagedev
midagedev merged commit f4672a1 into midagedev:main Oct 10, 2026
midagedev added a commit that referenced this pull request Oct 10, 2026
…the contributor's aarch64 record, mac-check.sh line refs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
midagedev added a commit that referenced this pull request Oct 10, 2026
@juliankang4 juliankang4 added dgx-spark The DGX Spark (aarch64, GB10) port host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 13, 2026
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 host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants