Skip to content

docs,bench(policies,operate): add delimiter stability, shared-backbone LoRA, MoE concurrency guidance, and E1-E4 cascade benchmarks - #70

Merged
ghchinoy merged 2 commits into
mainfrom
docs/production-tuning-delimiters-and-cascade-bench
Nov 20, 2026
Merged

ghchinoy merged 2 commits into
mainfrom
docs/production-tuning-delimiters-and-cascade-bench

Conversation

@jigyasujuneja

@jigyasujuneja jigyasujuneja commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Documents production guidance across four operator and policy-authoring surfaces (docs/ + synced docs-site/) and adds a reproducible benchmark suite (scripts/exp_cascade_calibration_delimiters.py + unit tests), verified against the google/diffusiongemma-26B-A4B-it SentencePiece tokenizer:

  1. Untrusted delimiter stability & deterministic slot seeding (docs/policies/prompt-layout.md):
    • Explains "seed_token": "fixed" (PAD=0) vs. "random" (samples: 4), why raw 16-character hexadecimal XML nonces (<context_{16-hex}>) introduce SentencePiece token-length jitter (8 distinct lengths per tag, 9–16 tokens, mean = 14.23, std = 1.28, up to 14-token rotary position shift across opening + closing tags across N = 1,000 draws) and alphabetic subword collisions (22.6% of draws with >= 3-letter subwords; 2.5% matching English/code tokens such as bed, add, bad, def, ace, cab, fed), and why 16-character base62 nonces show the same 8 distinct lengths (8–15 tokens, 24.6% >= 3-letter subwords).
    • Shows how JSON-escaped envelopes (| toJson: 0 random delimiter tokens, 1 distinct prompt length, 0.0% lexical subword collisions, 25.5 fewer mean prompt tokens than paired 16-hex XML tags) or eight hyphenated digit pairs (48-19-03-72-61-84-20-95: constant 23 tokens per nonce, std = 0.0, 0.0% alphabetic subwords) eliminate delimiter-induced RoPE jitter.
  2. DiffusionGemma shared-backbone LoRA & early-stopping calibration (docs/policies/fine-tuning.md):
    • Documents attaching one shared LoRA module across tied encoder/decoder projections (_tied_weights_keys) with routed 3D MoE experts frozen, freezing self_conditioning (self_cond_prob = 0.0) at steps = 1, regularizing early validation peaks on 1-bit slot supervision (lr = 2e-5..5e-5), and symmetric KL consistency penalties when randomized delimiters are mandatory.
  3. Canvas sizing & MoE concurrency knees (docs/operate/latency-capacity.md):
    • Measured on the google/diffusiongemma-26B-A4B-it SentencePiece tokenizer, a single-question lines template (<|channel>thought\n<channel|>allow: yes<turn|>) occupies 8 active tokens (7 template tokens + TURN_CLOSE = 106; 9 active tokens for numbered q1: yes, and 14 / 29 / 55 active tokens for 2 / 5 / 10 boolean or single-token choice questions), leaving 120 of 128 positions (93.75%) as trailing PAD = 0 tokens at --canvas 128 vs. 24 (75.0%) at --canvas 32 and 8 (50.0%) at --canvas 16.
    • Explains why sparse MoE expert activation (8 of 128 routed experts per token) and KV-cache preemption cause throughput to drop past 16 concurrent sequences without MAX_INFLIGHT backpressure, and when to enable DISABLE_MM=1.
  4. Base-rate prior shift vs. pure temperature scaling (docs/confidence/overview.md):
    • Clarifies "temperature" vs. "prior_bias" (Platt / log-odds intercept calibration) on skewed base-rate tasks, and distinguishes "samples": "auto" from cascade_mode: "entropy".
  5. Reproducible E1–E4 ablation & loopback keep-alive benchmark (scripts/exp_cascade_calibration_delimiters.py):
    • Explicitly labeled Illustrative Calibrated Benchmark (E1–E3) and Local Loopback Measured + Token Accounting (E4) suites with Paired McNemar exact tests, Holm-Bonferroni correction, 95% cluster-bootstrap CIs, and exact 2^4 Shapley attribution.
    • Adds optional --real-tokenizer mode loading google/diffusiongemma-26B-A4B-it from the local Hugging Face cache (with graceful offline fallback when transformers or cached tokenizer files are absent) plus unit tests covering both live/mocked SentencePiece verification and offline fallback guard branches.

Verification

  • python3 -W default -m unittest scripts/test_cascade_calibration_delimiters.py (5/5 passed)
  • python3 scripts/exp_cascade_calibration_delimiters.py --real-tokenizer (verified against google/diffusiongemma-26B-A4B-it)
  • make docs-sync-check (36/36 pages match)
  • python3 scripts/docs_link_check.py (0 broken relative links or anchors across 39 files)
  • unset DGEM_VERTEX_URL && go vet ./... && go test ./...
  • make check-public (0 leak hits across 23 patterns)

…e LoRA, MoE concurrency guidance, and E1-E4 cascade benchmarks
@ghchinoy

Copy link
Copy Markdown
Collaborator

Thanks for grounding the delimiter token-length jitter counts directly in the google/diffusiongemma-26B-A4B-it SentencePiece tokenizer (7af562a), and for the clear guidance on shared-backbone LoRA and MoE concurrency knees, @jigyasujuneja!

To get this ready to merge onto main as a clean documentation PR, could you please make three focused adjustments:

  1. Drop scripts/exp_cascade_calibration_delimiters.py and scripts/test_cascade_calibration_delimiters.py (+1,696 lines): Per AGENTS.md §3, synthetic/illustrative E1–E3 simulation scripts and ad-hoc experiment scripts belong in the evaluation workspace rather than the public dgem repository.
  2. Decouple from unmerged feat(serving,calibration): pool upstream HTTP/1.1 keep-alive, preserve slot logprobs, and add Platt prior-bias calibration #69 schema keys ("prior_bias" and "combine": "poe"): Remove the "prior_bias" bullet in docs/confidence/overview.md (+ docs-site mirror) and the parenthetical (and optional "combine": "poe" log-odds aggregation) in docs/policies/prompt-layout.md (+ docs-site mirror) for now so main only documents flags that are currently shipped.
  3. Clarify how --canvas interacts with canvas_width(template) in docs/operate/latency-capacity.md (+ docs-site mirror): In deploy/cloudrun/server/structured_server.py, CANVAS_LEN defaults to 64 (not 128), and canvas_width(template) (min(CANVAS_LEN, -(-need // CANVAS_STEP) * CANVAS_STEP) with CANVAS_STEP = 16) already rounds each request's diffusion_canvas_length down to the smallest multiple of 16 (16 for 1- and 2-question lines templates)—it does not pad short requests out to CANVAS_LEN. Please frame that bullet around callers talking directly to raw vLLM (diffusion_canvas_length per request) or capping the upper ceiling (--canvas) when think / many-question requests are not served.

@jigyasujuneja

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, @ghchinoy! Because GoogleCloudPlatform/dgem now uses fork-based contributor pushes, I rebased onto main (259fa68), applied all three adjustments:

  1. Dropped scripts/exp_cascade_calibration_delimiters.py and scripts/test_cascade_calibration_delimiters.py (8 pure docs/ + docs-site/ files remaining).
  2. Removed "prior_bias" and "combine": "poe" references from docs/confidence/overview.md, docs/policies/prompt-layout.md, and their docs-site/ mirrors.
  3. Clarified CANVAS_LEN = 64 and canvas_width(template) (CANVAS_STEP = 16, rounding 1–2 question lines templates down to 16) in docs/operate/latency-capacity.md (+ docs-site/ mirror) for raw-vLLM diffusion_canvas_length callers and --canvas ceiling tuning.

Opened #82 from my fork (maintainer_can_modify: true)—feel free to merge #82 and close #70!

@ghchinoy ghchinoy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging as-is; filing a follow-up issue for the docs/script cleanups noted above.

@ghchinoy
ghchinoy merged commit 94d1635 into main Nov 20, 2026
17 checks passed
@ghchinoy
ghchinoy deleted the docs/production-tuning-delimiters-and-cascade-bench branch November 20, 2026 21:04
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.

2 participants