Repository navigation
Conversation
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Captured kernels read each parameter through the address and strides fixed at capture. A same-address layout change such as transpose_() kept the old signature and replayed with a stale layout. Key the graph state on each parameter's address, device, dtype, shape and strides instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…lifecycle Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com> # Conflicts: # tests/unit/v1/test_hybrid_engine_rollout_v1.py
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
The static graph path captured only the model forward. After every replay the host chose the next token, wrote the position, cache position and attention mask, and checked eos_mask.all(), which waits for the device on every step. Capture the token selection with the forward: the graph now applies the repetition penalty over a device output buffer, picks the token, records EOS, and advances the position and mask for the next replay. The host only replays and checks for EOS every 16 steps. Sampling, repetition penalty and EOS ids join the graph signature. The generator state is restored after warmup so the graph draws the same random numbers as generate(). Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
This branch has not been deployed
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.
Summary
On the static graph path (
use_graph_capture=Truewithoutcontinuous_batch_size) only the model forward is captured. After every replay the host chooses the next token, writes it to the output, advances the position / cache position / attention mask, and callseos_mask.all(), which synchronizes with the device on every generated token.This PR captures the whole decode step:
multinomial) + EOS bookkeeping + position / mask / output-buffer updateeos_mask.all()syncreplay_graphfinishedflag; rows that finished keep receiving pad, as beforegenerate(); graph-sampled output matches the eager path bitwise for a fixed seed.generation_configsettings stay unsupported on the graph path, as before.inference-engine.rstupdated.Relation to #8602
Independent of segment KI: everything is plain PyTorch ops, so any HF model on the graph path gets it. #8602 rewrites the same decode loop and adds a
decode_step_graphCUDA kernel that does in-graph token selection only for batch size 1; this PR covers every batch size, so that kernel would no longer be needed. Whichever lands second rebases.Tests
test_static_graph_stops_once_every_row_has_produced_eos: forces every row to hit EOS on its third token and checks that graph output equals the eager rollout and that the graph is replayed fewer thanmax_new_tokens - 1times (i.e. the periodic EOS check stops decoding).model.generate()cover the in-graph selection.tests/unit/v1/test_hybrid_engine_rollout_v1.py: 26 passed, 1 skipped (pretrained-model test, needsDEEPSPEED_PRETRAINED_ROLLOUT_MODEL)tests/unit/runtime/rollout/test_hybrid_engine_rollout.py: 63 passed, 1 skippedHardware: 1x NVIDIA H20, torch 2.13.0+cu130, transformers 5.17.
Performance
Decode throughput is unchanged where decode is GPU-bound (Llama-3.1-8B, H20, prompt 128, 512 new tokens, greedy, EOS disabled; decode tok/s):
The gain comes from removing per-token host work and the per-step sync. It grows as the forward gets faster and host time becomes a larger share of the step, and it lets EOS-terminated rollouts stop without a sync on every token.