Skip to content

[Engine] strata-inkling CUDA: refuse a layer split when a later GPU's experts would go to host RAM - #6986

Open
GautamtmD wants to merge 1 commit into
Niko1221:mainfrom
GautamtmD:inkling-ls-peer-host-experts
Open

GautamtmD wants to merge 1 commit into
Niko1221:mainfrom
GautamtmD:inkling-ls-peer-host-experts

Conversation

@GautamtmD

Copy link
Copy Markdown

Problem and result

On a layer split, host-RAM (hybrid) experts only run on the first stage. The hybrid branch in run_visit requires cur_stage == 0. When a later stage's experts do not fit its VRAM budget, load_from_model_file still gives them tier 2 (host RAM). On that stage launch_ink_moe skips tier > 1 experts. The engine starts, runs, and produces wrong output with no error.

This happens with:

  • an explicit --layer-split that gives a GPU more layers than it can hold;
  • a --vram-experts-gb cap;
  • a second GPU that is partly in use.

Measured with --layer-split 12,12 --vram-experts-gb 5.5 on two 16 GB cards:

Load Mean KLD vs all-VRAM run Top-1 PPL
main (6a6db7f) experts=1317+1095 GPU / 660 host; 441 of the second GPU's experts skipped 0.691638 77.28% 8.694
this PR init: Layer-Split: the experts of GPU 0 do not fit in its VRAM (host-RAM experts only run on the first GPU); give it fewer layers (--layer-split), use --layer-split auto, or free VRAM, exit 1

Related discussion

None needed: this is a focused fix. I found no existing issue or PR about it.

Approach

When assigning a stage > 0 expert to host RAM, return a load error instead. The message says how to fix it.

  • I chose an error over rebalancing the split automatically. It is the smallest change that stops wrong output.
  • An auto-rebalance, or running host experts on later stages, would be a larger change and a design decision for the maintainers.

Compatibility: a setup that used to start and quietly give wrong answers now refuses to start. Every setup whose experts fit is unchanged.

Validation

Environment:

  • Windows 11, RTX 5070 Ti 16 GB (runs the desktop) + RTX 5060 Ti 16 GB, no P2P, driver 621.01.
  • CUDA 13.0, MSVC 14.44.
  • strata-inkling built from engine/src/inkling2 with -DSTRATA_ENABLE_CUDA=ON -DSTRATA_INK_CUDA_ARCHS=120.
  • Model: Inkling-2-Mini SQ-20.
  • main is 6a6db7f and this PR is 6a6db7f plus this commit.
  • CUDA_DEVICE_ORDER=PCI_BUS_ID, so CUDA device 0 is the 5070 Ti.

Passed:

  • Load refusal: strata-inkling --native Inkling-2-Mini-SQ-20.strata --gpus 1,0 --layer-split 12,12 --vram-experts-gb 5.5 --draft off --max-context 8192 --gen 8.
    • main starts and generates.
    • This PR exits 1 with the message above.
  • The damage this prevents, measured with main:
    • Reference: --dump-ref ref.bin ... --layer-split 6,18 --kv fp16 --prompt-ids <first 2048 tokens of docs/DETAILS.md>, all experts in VRAM.
    • --kld-eval ref.bin --gpus 1,0 --layer-split 12,12 --vram-experts-gb 5.5 --kv fp16 gives Mean KLD=0.691638 | Top-1=77.28% | PPL=8.694.
    • The reference's split differs; on its own that accounts for about 0.01 KLD.
  • Default path unchanged. strata-inkling --native ... --draft off --max-context 8192 --gen 64 gives the same greedy token ids (md5) as main for:
    • --gpus 1,0 --layer-split auto
    • --gpus 1,0 --layer-split 12,12
    • --gpus 1,0 --layer-split ep2
    • --gpu 1 --gpus 1
  • strata-inkling --selfcheck --native ... --gpus 1,0 --layer-split auto: PASS.
  • python tools/check --only py-tools: 1839 passed, 94 skipped, 2 failed. The same 2 fail on main in the same environment (see Failed).

Failed:

  • python tools/check --only py-tools: terminal.tools.test_exit_with_parent test_a_packer_ends_with_the_process_that_started_it and test_the_control_cli_ends_with_the_host_that_started_it.
    • They fail identically on unmodified main (6a6db7f) on this machine (fresh venv with terminal/requirements.txt and requirements-dev.txt, Python 3.12, Windows 11).
    • They test process lifetime in terminal/tools, not the engine.
  • Nothing else observed.

Not run:

  • Linux build and run.
  • CUDA 12.x builds and architectures other than sm_120. The change is host-side C++ in the loader.
  • HIP, SYCL, Metal: not applicable. Their Inkling backends use their own sources.
  • 3 or more GPUs. The check applies to every stage > 0 the same way, but I could not run it.

Limits

  • The engine refuses to start instead of fixing the split itself. With --layer-split auto the automatic partition already keeps later stages within their VRAM, so this mostly affects explicit splits and VRAM caps.

🤖 Generated with Claude Code

…st-RAM experts

Host-RAM (hybrid) experts only run on the first stage. When a later stage's
experts did not fit its VRAM (an explicit --layer-split, a --vram-experts-gb
cap, or a busy card), they were assigned to host RAM anyway and launch_ink_moe
skipped them: the engine ran and produced wrong output with no error.

Fail at load with a message that says what to change instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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