Skip to content

feat(ds4): opt-in GPU F16 HC fn mirrors for ROCmFPX#546

Draft
Graffioh wants to merge 4 commits into
Luce-Org:mainfrom
Graffioh:codex/ds4-rocmfpx-hc-gpu-mirror
Draft

feat(ds4): opt-in GPU F16 HC fn mirrors for ROCmFPX#546
Graffioh wants to merge 4 commits into
Luce-Org:mainfrom
Graffioh:codex/ds4-rocmfpx-hc-gpu-mirror

Conversation

@Graffioh

@Graffioh Graffioh commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Opt-in performance feature for ROCmFPX builds: GPU F16 mirrors for quantized HC fn weights, gated behind DFLASH_DS4_ROCMFPX_HC_GPU (default off).

ROCmFPX-quantized HC fn tensors cannot feed the __half HC pre kernels, so HC pre falls back to CPU on every layer, every token. With the flag on, the existing host F16 copy of each in-range layer's attn/ffn fn weights is uploaded once per shard cache and the GPU HC pre path consumes it.

Stack

Stacked on #507. The per-shard DeepSeek4LayerRangeCache and per-device HC scratch this feature builds on land there. Rebase after #507 merges.

Implementation

  • adds the deepseek4_cuda_hc_upload_f16 / deepseek4_cuda_hc_free device-memory primitives (select device, malloc + H2D upload; best-effort free on the owning device)
  • mirrors live on HcWeightsCpu (fn_f16_device + size + owning device id), uploaded in initialize_layer_range_cache for the shard's layer range only
  • hc_fn_device_ptr returns fn->data for F16 tensors (unchanged), the mirror for quantized tensors when the flag is on, else nullptr → CPU HC per layer
  • a failed upload logs an explicit CPU-HC fallback and degrades gracefully
  • mirrors are freed with the owning shard cache, on the owning device
  • the output HC projection is not mirrored — it runs once per step, not per layer

Validation / TODO before ready

  • with the flag unset, behavior is byte-identical to fix(ds4): correct layer-split HC handoff and per-device state #507
  • perf numbers and VRAM cost on gfx1151 (per layer: hc_dim x mix_dim F16, x2 for attn + ffn) still required
  • hardware validation on lucebox3/lucebox5 still required
  • decide promotion once validated: flip default-on (env becomes opt-out) or remove the flag

Graffioh and others added 2 commits July 19, 2026 11:27
@Graffioh
Graffioh force-pushed the codex/ds4-rocmfpx-hc-gpu-mirror branch from 1c69b8a to 8d59290 Compare July 19, 2026 09:28
Graffioh and others added 2 commits July 19, 2026 11:53
Also size the shared scratch for the requested shapes: the bounded
buffers (mix/post/comb) are allocated at their kMaxHc maxima and the
working buffer tracks n_embd capacity, instead of staying at whatever
dims the first call happened to use.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mx99uuhcriPweAFggPwfce
ROCmFPX-quantized HC fn tensors cannot feed the __half HC pre kernels,
so HC pre always fell back to CPU on ROCmFPX builds. Behind
DFLASH_DS4_ROCMFPX_HC_GPU (default off), upload the existing host F16
copy of each in-range layer's attn/ffn fn weights once per shard cache
and let the GPU HC pre path consume it.

Mirrors are owned by the shard's DeepSeek4LayerRangeCache, keyed to the
owning device, and freed on that device. A failed upload logs an
explicit CPU-HC fallback and degrades gracefully. The output HC
projection is not mirrored: it runs once per step, not per layer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mx99uuhcriPweAFggPwfce
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.

1 participant