Skip to content

spark-server: hash fenced code blocks once in the semantic-loop guard - #47

Closed
AzeezIsh wants to merge 1 commit into
mainfrom
fix/simhash-guard-code-fence
Closed

AzeezIsh wants to merge 1 commit into
mainfrom
fix/simhash-guard-code-fence

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

The streaming sentence-level Jaccard loop guard split fenced code on . : and blank lines and tripped on the first near-duplicate "sentence". Docstrings make that a false positive by construction — _left_child / _right_child twins share almost every bigram.

Measured (nvidia/Qwen3.8-27B-NVFP4, GB10): the decode-floor gate's MinHeap request, streamed, stops at 660 tokens on three heads (2d871d385, 9264bf4ec, 0513921e5) with SimHash semantic-loop watchdog fired (paraphrased sentence repeat) ring_len=16; the identical request unstreamed (stream: false, same serve flags) runs to the full 1500-token budget on all three spec arms (MTP K=4 / K=2 / serial) with no repetition, and the text at the cut is the helper methods with prompt-mandated docstrings inside one ```python fence opened at char 0. The 717–718 "natural stop" the gate's vacuity pin was calibrated against was the same cut at an earlier head — the model does not stop there.

Fix: the streaming consumer tracks ``` fences (simhash_step, unit-testable state machine). Inside a block no sentence boundary or 1 KB force-flush is evaluated; the block is hashed once at its closing fence (the design the F22 note already describes); the pending buffer is bounded at 16 KB; prose outside fences is unchanged; the token-level period watchdog stays active everywhere. Byte-offset slicing is kept on char boundaries (multibyte tails). `decode_floor` doc comments corrected (pin value 700 unchanged).

Test plan

  • 22/22 loop_simhash tests (11 existing unchanged + 11 new: docstring twins in an open fence never trip; prose loop after the fence trips on the 2nd sentence; two identical blocks trip at the 2nd close; split marker across chunks; 16 KB cap; multibyte tails; char-chunked fuzz with fence-parity check) — run standalone on macOS since spark-server test binaries need CUDA to link
  • cargo fmt, typos, git diff --check, clippy -p spark-server --tests
  • GB10 (queued as simhash-fence-verify): cargo test -p spark-server loop_simhash; decode-floor --pull-request-gate on nvidia/Qwen3.8-27B-NVFP4 — expect 3 × 1500 tokens (finish_reason=length), zero watchdog fires, PASS; a streamed prose-loop probe still trips

Generated with Devin

The sentence-level Jaccard guard split fenced code on `.` `:` and blank
lines and tripped on the first near-duplicate "sentence". Docstrings make
that a false positive by construction: `_left_child`/`_right_child` twins
share almost every bigram. Streaming the decode-floor MinHeap prompt
against nvidia/Qwen3.8-27B-NVFP4 stopped at 660 tokens on three heads
with `paraphrased sentence repeat`, while the identical unstreamed request
ran to the 1500-token budget with no repetition; the 717-718 "natural
stop" the gate's vacuity pin was calibrated on was the same cut.

The streaming consumer now tracks ``` fences: inside a block no sentence
boundary or 1 KB force-flush is evaluated, the block is hashed once at
its closing fence (the design the F22 note describes), and the pending
buffer is bounded at 16 KB. Prose outside fences is unchanged, and the
token-level period watchdog stays active everywhere. Tests cover
docstring twins inside an open fence, a prose loop after the fence, two
identical blocks, a marker split across chunks, and the cap.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Merged into feat/flashnext-nvidia as 7190719fe — lands with #35 (its decode-floor gate is the consumer). Verified on GB10 in job 183: streamed decode-floor 960/1500/1500 tokens, 0 watchdog fires, PASS.

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