Skip to content

feat(parsers): gemma4 on the v2 UnifiedParser — one ordered stream, with Dynamo request modes - #166

Merged
keivenchang merged 6 commits into
mainfrom
keivenchang/DIS-2562__gemma4-unified
Sep 1, 2026
Merged

keivenchang merged 6 commits into
mainfrom
keivenchang/DIS-2562__gemma4-unified

Conversation

@keivenchang

@keivenchang keivenchang commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Overview:

This PR moves Gemma4 onto the v2 UnifiedParser so reasoning, visible content, and tool calls stay in one ordered stream. Gemma4 only; every other family keeps its current path.

This is standalone on current main. #178, #174, and #194 already provide the shared parser interface, request modes, and guided-streaming contract.

Gemma4 conformance matrix

Example (before → after):

Case UNIFIED.12.b — a tool call opens inside a reasoning span:

before: reasoning = "I should check. <|tool_call>"   ← markup leaks into reasoning; the call is lost
after:  reasoning = "I should check. ", tool_call = get_weather, reasoning = " now answer"

Details:

  • Gemma4 supplies its markers, emitter, and reasoning specification to the shared ScannerUnified; registration is one family row.
  • ReasoningSpec.start_label strips Gemma4's structural thought\n role label instead of exposing it as reasoning text.
  • Native recovery keeps lexical call: prose, skips wrapper-shaped data inside argument strings, and resynchronizes after malformed or incomplete wrappers.
  • The current capture is dynamo_v2-0.3.3+pr166, separate from the released 0.3.3 identity. Historical columns use immutable sparse overlays, and released base hashes remain unchanged.

Verification:

  • cargo fmt -- --check, parser clippy, and conformance clippy pass.
  • The v2 parser package passes 450 unit tests plus its integration and doc-test binaries.
  • The full conformance package passes. python3 -m pytest conformance/utils/tests passes 191 tests.
  • The generated v2 matrix contains all 292 unified cases with no postdates that build placeholders.
  • The archive audit verifies 28 manifest hashes and sizes, four released hashes, 12 sparse counts, and the four removed archive names.

Where should the reviewer start?

parsers/v2/src/unified/gemma4.rs, then parsers/v2/src/tool_calling/scan.rs and parsers/v2/src/tool_calling/v1core/gemma4/parser.rs

/coderabbit profile chill

@keivenchang
keivenchang requested a review from a team as a code owner July 30, 2026 20:08
@keivenchang
keivenchang marked this pull request as draft July 30, 2026 20:09
@keivenchang keivenchang self-assigned this Jul 30, 2026
@github-actions github-actions Bot added the feat label Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

📊 Conformance matrix rendered — view in CI summary

@keivenchang
keivenchang force-pushed the rmccormick/keiven-qwen-unified-fix branch 3 times, most recently from 645365c to 4bedf3a Compare July 31, 2026 04:13
@keivenchang keivenchang changed the title feat(parsers): UnifiedParser for gemma4 — one ordered reasoning/text/tool stream feat(parsers): gemma4 on the UnifiedParser — one ordered stream, with Dynamo request modes Jul 31, 2026
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from bfc3024 to d3eb844 Compare July 31, 2026 04:33
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from d3eb844 to 827d4c0 Compare July 31, 2026 05:21
@keivenchang
keivenchang changed the base branch from rmccormick/keiven-qwen-unified-fix to keivenchang/DIS-2565__family-registry July 31, 2026 16:18
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch 2 times, most recently from da43cb2 to 2c7ca39 Compare July 31, 2026 16:32
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2565__family-registry branch from 9cb43a6 to 6f05a50 Compare July 31, 2026 17:21
@keivenchang
keivenchang changed the base branch from keivenchang/DIS-2565__family-registry to rmccormick/keiven-qwen-unified-fix July 31, 2026 17:26
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from 2c7ca39 to 2911511 Compare July 31, 2026 17:26
@keivenchang
keivenchang force-pushed the rmccormick/keiven-qwen-unified-fix branch 3 times, most recently from ad6a087 to 8b50a4e Compare July 31, 2026 19:33
@keivenchang keivenchang changed the title feat(parsers): gemma4 on the UnifiedParser — one ordered stream, with Dynamo request modes feat(parsers): WIP (BIG) — gemma4 on the UnifiedParser, one ordered stream with Dynamo request modes Jul 31, 2026
@keivenchang
keivenchang force-pushed the rmccormick/keiven-qwen-unified-fix branch 6 times, most recently from d9fb490 to 09d1fe0 Compare August 1, 2026 05:47
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from 2911511 to 49205ef Compare August 3, 2026 18:23
keivenchang added a commit that referenced this pull request Aug 21, 2026
… Dynamo request modes (#166)

Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from 4539f6e to b035226 Compare August 21, 2026 20:02
Comment thread parsers/v2/src/tool_calling/gemma4.rs
Comment thread parsers/v2/src/tool_calling/v1core/gemma4/parser.rs Outdated
Comment thread parsers/v2/src/tool_calling/gemma4.rs
Comment thread parsers/v2/src/tool_calling/gemma4.rs
keivenchang added a commit that referenced this pull request Aug 21, 2026
… Dynamo request modes (#166)

Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
@keivenchang
keivenchang force-pushed the keivenchang/DIS-2562__gemma4-unified branch from b035226 to 6cd3e15 Compare August 21, 2026 20:46
Comment thread conformance/utils/src/gen_unified_golden.py Outdated
Comment thread parsers/v2/src/unified/mod.rs Outdated
Comment thread conformance/utils/lib/parsers/UNIFIED_CASES.md Outdated
Comment thread parsers/v2/tests/vendor_registry.rs Outdated
@keivenchang

Copy link
Copy Markdown
Contributor Author

Pushed e3df430a with the remaining Gemma4 v2 review fixes and capture updates.

The parser now preserves lexical call: prose and resynchronizes after malformed or incomplete Gemma wrappers in both tool-only and unified modes at every UTF-8 split. The capture set now keeps released bases immutable, fills historical columns through sparse overlays, and records this PR under 0.3.3+pr166.

Local validation passes: format and clippy, 450 parser unit tests plus integrations/docs, the full conformance package, 191 Python utility tests, and a 292-case matrix with no historical placeholders. CI for e3df430a is still in progress. I published the three prepared replies and left all eight reviewer threads open for Ryan.

Comment thread parsers/v2/src/tool_calling/v1core/gemma4/parser.rs Outdated
Comment thread parsers/v2/src/tool_calling/scan.rs Outdated
Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
Comment thread parsers/v2/src/tool_calling/scan.rs Outdated
Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
Comment thread parsers/v2/src/unified/mod.rs Outdated
Comment thread parsers/v2/src/unified/mod.rs Outdated
Comment thread parsers/v2/src/unified/gemma4.rs
Comment thread parsers/v2/src/unified/mod.rs Outdated
Comment thread parsers/v2/src/tool_calling/kimi_k2.rs Outdated

@indrajit96 indrajit96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@keivenchang thanks for adding this
Left a few comments on streaming changes with a possible perf issue.
SOme gemma specific behavior is still present in unified/mod.rs
The existing tests all pass.

Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>

@indrajit96 indrajit96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
Conditional approval with one corner case comment here #166 (comment)

Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
@keivenchang

Copy link
Copy Markdown
Contributor Author

Indrajit’s conditional approval is addressed in 2a6d200 — the parser now preserves a balanced recovery candidate across trailing whitespace at EOF, with native and unified coverage at chunk sizes 1, 4, and 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants