Skip to content

Probe verdict reads the GPU back on every step, defeating async scheduling #177

Open

Description

@lastras

Problem

On any checkpoint with probe slots, GraniteSwitchForCausalLM.compute_logits makes the CPU wait for the GPU on every engine step, even when no request in the batch is a probe request. With async scheduling (on by default in vLLM 0.26, vllm/config/vllm.py:1059-1107) this removes the CPU/GPU overlap that async scheduling exists to provide. Output stays correct; throughput and latency suffer. Checkpoints without probe slots are unaffected (probe_head is None returns before any of this).

Where

_apply_probe_verdict, src/granite_switch/vllm/granite_switch_model.py:768-802 (origin/main 3b53f62):

Line Code Effect
789 if not bool(is_probe.any()): GPU→CPU read. Runs on every step, probe requests or not
795 rows = is_probe.nonzero(as_tuple=True)[0] nonzero has a data-dependent size: another read
797 for r in rows.tolist(): another read
798 row_slot = int(slot_int[r]) one read per probe row
800 torch.tensor(ids, dtype=torch.long, device=logits.device) one CPU→GPU copy from a Python list per probe row
801 logits[r, label_ids] = verdict[r, : len(ids)] one small indexing kernel per probe row

So every step pays at least one read; a step with probe rows pays 2 + 2 × (probe rows) reads and copies, plus a Python loop.

Why this defeats async scheduling

Under async scheduling the worker queues step t's forward, then sample_tokens(t) calls compute_logits (vLLM 0.26 Model Runner V2: vllm/v1/worker/gpu/model_runner.py:1085-1092), returns, and goes on to prepare and launch step t+1 while the GPU is still busy with step t. The read at line 789 depends on the logits, so the worker thread blocks until step t's forward and LM head have finished on the GPU. Only then does it queue sampling, return, and prepare step t+1. While the CPU schedules and prepares step t+1, the GPU sits idle. That gap, once per step, is exactly what async scheduling hides for every other model.

compute_logits is also called for prompt logprobs (model_runner.py:1447-1454), so those pay the same reads per scheduled chunk.

The size of the effect has not been measured. It is roughly the CPU time to schedule and prepare one step, paid every step, so it matters most where steps are short: decode at small batch.

Suggested fix: no reads, fixed shapes

Build two small tables once in GraniteSwitchModel.__init__ (row 0 is the sentinel; non-probe slots and row 0 are all zeros):

  • _probe_label_ids_t, [num_slots + 1, L] long: each slot's label token ids, padded by repeating its first id;
  • _probe_label_src_t, [num_slots + 1, L] long: the verdict column each entry takes, with pads pointing at column 0.

Then the rewrite becomes:

is_probe = (slot_int == safe_idx) & slot_mask[safe_idx]           # [R]
ids = self.model._probe_label_ids_t[safe_idx]                     # [R, L]
src = self.model._probe_label_src_t[safe_idx]                     # [R, L]
probe_vals = verdict.gather(1, src).to(logits.dtype)
logits.masked_fill_(is_probe[:, None], float("-inf"))
vals = torch.where(is_probe[:, None], probe_vals, logits.gather(1, ids))
logits.scatter_(1, ids, vals)

Pads write the same value as the entry they repeat, and non-probe rows write back their own values, so the scatter is deterministic. There is no Python loop and no read back.

Cost: one pointwise pass over the [rows, vocab] logits per step, even when there are no probe rows. That is small next to an LM head over the same rows, and it replaces a full pipeline stall.

Verification

  • Equivalence: the existing probe GPU tests (tests/vllm/test_probe_chunked_prefill.py) plus a unit test comparing old and new _apply_probe_verdict on random inputs. Cover:
    • mixed probe and non-probe rows;
    • slots with fewer labels than max_probe_labels;
    • out-of-range slot values (the profiling-run case in the docstring);
    • a batch with no probe rows.
  • No reads: run _apply_probe_verdict under torch.cuda.set_sync_debug_mode("error"); it must not raise.
  • Impact: decode time per token on a probe checkpoint at batch 1 and 16, with async scheduling on and off, before and after the fix. Today, turning async scheduling off should change little on a probe checkpoint; after the fix, async on should be faster.

Activity

  1. added
    vllm
    investigation
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigationvllm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions