ds4 icon indicating copy to clipboard operation
ds4 copied to clipboard

--dist-replay-check is a silent no-op on the CLI coordinator path

Open datanerdie opened this issue 3 months ago • 1 comments

On the standalone coordinator path (./ds4 --role coordinator -p ...), --dist-replay-check produces no output at all — neither its pass message nor its failure message ever appears.

Expected one of:

  • ds4_distributed.c:3860 — "ds4: distributed replay check passed: logits exact match across reset/replay"
  • ds4_distributed.c:3852 — "ds4: distributed replay check failed: mismatches=..."
  • ds4_distributed.c:3964 — "ds4: distributed replay prompt processing failed: ..."

Observed: none of the three, on any run.

Reproduce (Metal, two Macs over Thunderbolt, Flash q2-q4):

# worker
./ds4 --metal -m ds4flash.gguf --role worker --layers 24:output --coordinator <ip> 1234
# coordinator
./ds4 --metal -m ds4flash.gguf --role coordinator --dist-replay-check \
      --layers 0:23 --listen <ip> 1234 -p "Explain in one sentence why the sky is blue." -n 16 --temp 0

Output contains distributed route ready and the throughput line, but nothing from the replay check. Flag position makes no difference.

It does not look like an argument-parsing problem: --debug, parsed by the identical mechanism a few lines below at ds4_distributed.c:8281, works from the same command line and produces its route/telemetry logs as expected. --dist-replay-check is matched at ds4_distributed.c:8273 and sets opt->replay_check, which dist_run_coordinator copies to state.replay_check at :5725, and dist_run_coordinator_generation gates the block on at :3941. Every step looks right by inspection, so the fault is somewhere I could not identify from reading.

Version: 6747e77. Not urgent — noting it because the diagnostic silently provides no assurance rather than failing loudly, which is the worst mode for a correctness check.

For what it is worth, the property it is meant to verify does hold on this setup: dumping --dump-logits from a single-process run and from a 0:23/24:output distributed run of the same prompt gives byte-identical files, 129280/129280 vocab entries matching. So this looks like a reporting bug rather than a correctness one.

datanerdie avatar Aug 05 '26 04:08 datanerdie

Root cause found, and it is static — no live debugging needed.

The replay check is implemented only in dist_run_coordinator() (ds4_distributed.c:5707, consuming state.replay_check set at :5725). But ds4_dist_run — the only way to reach it — is invoked for workers only: ds4_cli.c:2153 gates on role == DS4_DISTRIBUTED_WORKER, and the server's call at ds4_server.c:13385 sits in the worker branch too. A CLI coordinator (your exact command) goes through the session machinery instead: ds4_dist_session_create copies the flag into d->state.replay_check (ds4_distributed.c:5441) and nothing ever reads that copy. So the check's code is unreachable for the coordinator role, and the flag on the live path is stored-but-ignored — hence the perfect silence you observed: not a subtle logic bug, a wire that was never connected.

Independent confirmation on CUDA (RunPod RTX 3090, ds4f-q2, commit c1d4597, --ssd-streaming):

./ds4 -m ./ds4flash.gguf --cuda --ssd-streaming --ctx 4096 \
  --role coordinator --listen 127.0.0.1 7813 --layers 0:20 \
  --dist-replay-check -p "hi" -n 4

Zero occurrences of "replay" in the output, matching your Metal observation — backend-independent, as the analysis predicts.

Two possible fixes, and the choice is a design call:

  1. wire the session/coordinator path to actually run the check (re-prefill + logits compare inside the session flow);
  2. until then, warn loudly when the flag is accepted on a path that ignores it.

I have (2) written and validated (the warning prints exactly where today there is silence) and can PR it, or take a shot at (1) if that is the preferred direction.

tedin7 avatar Aug 28 '26 05:08 tedin7