Repository navigation
[Engine] --layer-split on one GPU: PcieAuto gives the second stage CUDA0's share instead of reading an empty stage list - #7612
Open
JayOfTheKeyboard wants to merge 1 commit into
Conversation
…are instead of reading an empty stage list (Niko1221#7611) --layer-split K on a machine with one card sets split_same: the split has two stages but `stages` stays empty. pcie_auto_step read stages[0] for stage 1 as soon as a decode window produced a new share, a NULL read (SIGSEGV on the first long prompt, RTX 2080 Ti). A stage without a GpuStage now takes CUDA0's share, the rule the per-request path already uses. split_rules::stage_gpu_index holds the rule; split_rules_test checks it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
Fixes #7611.
--layer-split Kon a machine with one GPU setssplit_same. The split has two stages, butstagesstays empty because no stage gets its own GPU. When PcieAuto refines the share after a decode window,pcie_auto_stepreadsstages[st - 1]for every stage after the first. On a same-GPU split that isstages[0]of an empty vector, and the engine dies with a NULL read on the first long, varied prompt. The core dump and the trigger are in the issue.After this change a stage with no GpuStage of its own takes CUDA0's share. That is the rule the per-request path already uses (generate.cpp:21445,
st == 0 || split_same). Multi-GPU splits behave as before.Related discussion
#7611. This is a focused crash fix, so no scope agreement was needed.
Approach
The rule "which
stagesentry does stagestuse, if any" goes intosplit_rules.hppasstage_gpu_index(st, split_same, n_gpu_stages). It returns -1 for stage 0, for a same-GPU split, and for an index past the list.pcie_auto_stepcalls it and gives CUDA0's share to any stage that gets -1. I put the rule insplit_rules.hppbecause that file already holds the GPU-free split rules andsplit_rules_test(already in ctest) tests them without a card.I checked the other
stages[st - 1]reads in generate.cpp. The ones I found sit behindmulti_gpu,pipe(which needs!split_same) or an explicitsplit_samebranch.pcie_auto_stepwas the only unguarded one I found, so the PR touches only that loop.Validation
Passed:
split_rules_testat b38acc8, built withg++ -std=c++20 -Iengine/includeon Fedora 44 (x86-64):split_rules_test: ok. It has 7 new checks, including the crashing case (split_same, stage 1, empty list).|| split_sameremoved from the rule it fails at split_rules_test.cpp:281. With the bounds check removed it fails at lines 282 and 283.cmake --preset cpu-check, then a build andctest(Fedora 44, GCC). At b38acc8: 183 tests, 0 failed, includingsplit_rules_test. At the parent 8db8753: the same result. Both runs skipped the same 4 tests (io_priority_test,expert_multi_test,expert_parity,pool_test).backends.yml) at b38acc8, run on my fork: CUDA 12.9, CUDA 13.0, HIP ROCm 7.2 and SYCL oneAPI 2026.1 all compiled (https://github.com/JayOfTheKeyboard/Strata/actions/runs/46649742458).--layer-split 24in the0.2.23-cuda13Docker image. The log confirms the same-GPU split:layer split: layers 0-23 (CUDA0), 24-47 (CUDA0). The patched engine is tag v0.2.23 plus this same diff, built for sm_75 (-DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=75, Release, CUDA 13.0 toolkit) and added withstrata components add-build. It is not built from main, but the diff applies to both unchanged.PCIe share: the CPU pool takes 207 us per missed expert ... -> pcie_frac 0.65, then-> 0.60).split_rules_testalso passes in that CUDA build tree (ninja targetsplit_rules_test).Failed:
None observed.
Not run:
Limits
split_rules_testcovers the rule, not the call site. If someone later stops callingstage_gpu_indexinpcie_auto_step, the test still passes. I found no GPU-free way to drivepcie_auto_stepitself.The rule also returns -1 for a stage past the end of
stageson a real multi-GPU split. That stage then gets CUDA0's share instead of crashing. I know of no path that reaches this today.The per-request reset at generate.cpp:21445 keeps its own inline
split_samecheck. I left it alone to keep this PR to the crash. It could usestage_gpu_indextoo if you want the rule in one place.Only PcieAuto's per-stage refinement changes. Whether a same-GPU layer split is a useful setup at all on one card is a separate question. This PR only stops it from crashing.