Skip to content

[1/10] fix(runtime): retain references across partial and invalid streaming reads - #957

Merged
curnane-lab merged 2 commits into
mainfrom
codex/pr942-01-streaming-reads
Oct 22, 2026
Merged

curnane-lab merged 2 commits into
mainfrom
codex/pr942-01-streaming-reads

Conversation

@jiapingW

@jiapingW jiapingW commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

A partial or transiently invalid JSONL reference must not advance the reader past an unconsumed sample.

Modifications

Commit the byte offset only after complete records validate. Reopen and retry transient decode errors with bounded retries, and raise on persistent corruption. Preserve max_n, acknowledgement, and closed-source behavior.

Stack and dependencies

Layer 1/10 split from #942. Bottom layer; base: main. Review the diff against this PR's base branch; it contains only this layer. The full stack index is maintained in #942.

Actual prerequisites: No earlier feature is required; this layer uses existing main APIs.

The linear stack is the review/merge order. Model-specific optimizations are independently opt-in; the projection-checkpointing and attention layers expose shared capabilities. When merging a lower PR with squash, restack the remaining branches before merging them so already-reviewed commits do not reappear. The repository GPU test workflow only auto-runs for PRs targeting main; upper layers need that CI run when retargeted, while lint runs for all PRs.

Source: #942 at 211b87fc7d707e3a628cb95de5c73340af863c04, split onto main fdcc2eddf1b56b5b24a5a15d3abcb366adfeb5aa. The original branch is preserved.

Accuracy Test

  • This layer at bb9017afeca6: 36 tests run, zero failures/errors on H20 with Python 3.11.12 / PyTorch 2.13.0+cu130.
  • Final stack at eaa14f102d6a: 405 integration tests run, zero failures/errors; 2 skipped on H20 with Python 3.11.12 / PyTorch 2.13.0+cu130. Each module runs in a fresh process to isolate process-global distributed state. This is targeted regression coverage, not a full-suite or downstream task-accuracy claim.
  • Repository pre-commit checks passed for the final stack; each layer was formatted with the repository's pinned Black/isort versions.

Layer command (run in this branch's checkout, PYTHONPATH=.):

CUDA_VISIBLE_DEVICES=0 OMP_NUM_THREADS=4 python -m unittest \
  tests.test_runtime.test_streaming_ref_channel -v

Qwen3 tokenizer regressions reuse the cached official tokenizer with HF_HUB_OFFLINE=1 and HF_HUB_CACHE pointing to that cache. No training job was launched.

Benchmark & Profiling

No new end-to-end throughput or downstream accuracy benchmark was run for this split. Model-side tests exercise numerical parity and gradients; historical measurements remain in #942 with their original scope and caveats.

Checklist

  • Format changed code.
  • Run the layer's regression tests and final-stack integration tests.
  • Keep feature tests/documentation with their owning layer.
  • Complete GitHub CI and any required downstream accuracy/performance validation before merge.

@jiapingW
jiapingW requested a review from FrankLeeeee as a code owner October 14, 2026 03:26
@jiapingW jiapingW changed the title [1/11] fix(runtime): retain references across partial and invalid streaming reads [1/10] fix(runtime): retain references across partial and invalid streaming reads Oct 14, 2026
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
… to exp_read.me

Same base as the dense-1/8 branch (PR sgl-project#942 stack sgl-project#957-sgl-project#963 merged there, DDP-wrapped draft lookup for MoE
metrics, managed-local NCCL port pin); the experiment log is exp_read.me like on dense-1/8.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…yers 1-7 of the sgl-project#942 split), matching the dense-1/8 branch

The combined PR sgl-project#942 merge was reverted in the previous commit; this takes the split stack instead
(sgl-project#957 streaming-read fixes, sgl-project#958 DDP sync once per accumulation window, sgl-project#959 no implicit qwen3-instruct
system prompt, sgl-project#960 is_causal, sgl-project#961 fused DFlash head, sgl-project#962 selective checkpoint contexts, sgl-project#963 shared
flatten_vocab_projection / cache_vocab_projection), so the MoE arm carries exactly the same upstream code
as the dense-1/8 arm. Conflicts in specforge/training/backend.py and controller.py resolved in the stack's
favour.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…ense-1/8 branch

Taking the stack's side of the merge conflicts had dropped this branch's own changes to
specforge/training/backend.py and controller.py: the MoE checkpoint state-dict naming conversion
(to_checkpoint_state_dict / from_checkpoint_state_dict), the fsdp_replicate_when_frozen candidates, the
SPECFORGE_FSDP_SHARDED_GRAD_ACCUM path and the perf/mem_* allocator metrics. The files are now the
dense-1/8 versions (base + PR stack sgl-project#957-sgl-project#963), plus dense-1/8's launch_plan.py fix pinning each
capture server's --nccl-port, so specforge/ is identical across the two arms.

Recipe: flatten_vocab_projection / cache_vocab_projection (the sgl-project#963 names), save_interval 1196 with 12
checkpoints kept (9 per epoch, the 9th on the epoch boundary), in-flight window 264/132 and no
consumer_dispatch override, all as on dense-1/8.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…l-project#963 + sgl-project#966) into the MoE experiment branch

The same upstream content was already merged here independently; this records the fork branch's
current head as an ancestor. The two MoE config files that spark-Qwen3-8B also carries are kept in
this branch's version (the one the running experiment uses).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment on lines +356 to +357
if line.strip():
out.append(ref_from_dict(json.loads(line.decode("utf-8"))))

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.

If the JSON parses but ref_from_dict rejects it, this raises bare — no offset, and since the offset never commits, a restarted consumer crashes at the same record with nothing to go on.

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.

I think we can just throw a valueError here. e.g.

raw = json.loads(line.decode("utf-8"))

try:
    ref = ref_from_dict(raw)
except (KeyError, TypeError, AttributeError) as exc:
    raise ValueError(
        f"StreamingRefChannel {self.path}: "
        f"invalid SampleRef at byte offset {next_offset}: {exc}"
    ) from exc

out.append(ref)

@maocheng23

Copy link
Copy Markdown
Collaborator

Overall LGTM, nits to be addressed

@curnane-lab
curnane-lab merged commit 2ff40d1 into main Oct 22, 2026
7 of 8 checks passed
@curnane-lab
curnane-lab deleted the codex/pr942-01-streaming-reads branch October 22, 2026 01:24
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.

3 participants