Skip to content

Keep captured chat logprobs in stream order - #350

Closed
jonathan308 wants to merge 1 commit into
fix/cluster-qwen-expert-reductionfrom
fix/cluster-event-bound-logprobs
Closed

jonathan308 wants to merge 1 commit into
fix/cluster-qwen-expert-reductionfrom
fix/cluster-event-bound-logprobs

Conversation

@jonathan308

Copy link
Copy Markdown

Captured logprobs can reach an out-of-band queue before their text is consumed, causing metadata for future tokens to appear on an earlier chat frame. This adds a typed metadata event to the ordered server stream and makes the canonical chat encoder consume metadata with content. Collected JSON keeps captured entries in order; absent metadata fields stay omitted.

Depends on #346. The provider companion supplies these events from the real engine bridge. Native capture support is unchanged. Reasoning/tool source spans remain unclassified, so their metadata can carry to the next visible content; trailing entries without content are omitted from streaming. The existing pending window remains bounded to the freshest 4096 entries.

Before

flowchart TD
  E["Engine produces tokens"] --> T["Text stream"]
  E --> Q["Separate metadata queue"]
  T --> C["Chat encoder emits content"]
  Q --> D["Drain can include future tokens"]
  C --> R["Earlier frame receives later metadata"]
  D --> R
  classDef normal fill:#e8f1ff,stroke:#3366aa,color:#172b4d;
  classDef problem fill:#ffe5e5,stroke:#b42318,color:#5a1414;
  class E,T,Q,C normal;
  class D,R problem;
Loading

After

flowchart TD
  E["Engine produces tokens"] --> S["Ordered logprobs and text events"]
  S --> B["Request-owned bounded buffer"]
  B --> C["MLXOpenAIService consumes content"]
  C --> R["Chat frame receives consumed metadata"]
  B --> J["Collected JSON retains capture order"]
  classDef normal fill:#e8f1ff,stroke:#3366aa,color:#172b4d;
  classDef fixed fill:#dcfce7,stroke:#27834a,color:#14532d;
  class E,S,B,C normal;
  class R,J fixed;
Loading

Validation: actual 362-source Common, 35-source Server and 875-source ProviderCore modules/objects compile. The combined focused executable passes 26 tests in six suites across ten final repeats, including seven strict multi-token local/distributed HTTP parity cases, producer-ahead ordering, parser holdback/flush, cancellation/error, terminal capture, bounded pending state, bridge ordering and warmup accounting. Test engines are fabricated; these results do not qualify model capture. SDK strict formatting, test organization and fork coverage pass. Full-package CI and live model tests remain separate gates.

Independent correctness/refactor review is clear after fixing warmup metadata counting. All 59 provider/SDK postimages and 72 evidence hashes were verified; the SDK publication adds only reviewed changelog/fork documentation. No further cleanup was warranted.

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