← Back to Pull requests

feat comfyui connector and fix framesync null guard #207

Closed
unknown closed this pull request without merging on Oct 28, 2025 02:12 UTC
View on GitHub
unknown unknown commented on Sep 16, 2025 14:37 UTC
Author

Summary


Introduces a ComfyUI-to-BMF connector that runs ComfyUI graphs on the BMF engine without bundling GPL3.0 code.
Fixes a crash in FrameSync input manager when inputs arrive at different timestamps (mixed-rate/mixed-type flows).

Part 1 — Feature: ComfyUI Connector

What


Runtime integration that converts a ComfyUI prompt graph into a BMF GraphConfig and executes it in-process.

How


  • demo/comfyui_intergration/bmf_runner.py: Installs a lightweight runtime hook into execution.PromptExecutor.execute (no on-disk modification) and routes execution into BMF when enabled.

  • demo/comfyui_intergration/bridge.py:

  • - BmfWorkflowConverter builds a BMF graph from the ComfyUI prompt.
    - ComfyNodeRunner wraps each Comfy node as a BMF module with:
    - zero-copy tensor paths (hmp <-> torch via DLPack),
    - simple model-output caching for loader nodes,
    - progress/preview alignment with comfy_execution.progress,
    - guarded input decoding to avoid null/invalid packets.
  • demo/comfyui_intergration/run_bmf_comfy.py: Launches ComfyUI with the runtime hook installed.

  • demo/comfyui_intergration/setup.sh: One-step environment setup and pinned ComfyUI checkout.
  • Why


  • Avoid copying GPL-licensed code; only use public modules at runtime.

  • Keep ComfyUI UX: progress bars, previews, and history outputs remain aligned.

  • Zero-copy data flow reduces CPU/GPU overhead.
  • Part 2 — Bugfix: FrameSync crash under mixed timestamps

  • FrameSync scans inputs, records the next packet per stream (if any), computes the global minimum timestamp min_ts, and only “advances” streams whose next packet timestamp equals min_ts.

  • For streams whose next packet is greater than min_ts, curr_pkt_ remains unset. Previously, the code unconditionally called set_timestamp() on curr_pkt_[stream_id]. Because operator[] default-constructs an empty Packet, this dereferenced an invalid packet and crashed.
  • Fix in this MR:


  • Add a defensive null-guard before set_timestamp() and only enqueue defined packets for each stream. This prevents creating invalid packets and eliminates the segfault.

  • On the Comfy side, the node runner checks that all input queues are non-empty before executing. If any input is missing, it simply waits, so mixed-rate/mixed-type graphs (e.g., KSampler receiving model/vae at ts=1 and latent at ts=2) no longer crash.
  • Limitations & follow-ups:


  • Some Comfy nodes truly require a strict “all inputs present” barrier at the min_ts step.

  • If this fix would change FrameSync semantics in an unacceptable way, consider adding a new input manager (e.g., “AlignedFrameSync”).

  • DefaultInputManager/ImmediateInputStreamManager intentionally do not provide this barrier behavior.
  • Reproducer (why it used to crash)


  • Graph with KSampler(e.g. image2image template in ComfyUI):

  • - model/vae from a loader arrive once at ts=1.
    - latent_image arrives later at ts=2 (after VAEEncode finishes).
  • FrameSync selected min_ts=1, advanced model/vae streams, left latent_image unset.

  • Code then attempted set_timestamp() on a default-constructed Packet for latent_image, causing a null dereference.

  • The guard added in this MR prevents that; the runner waits until latent_image arrives before executing the node.
  • Diff: 410 lines (+307 / -103) across 5 files Reviewer: ischencheng Review duration: 59735m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 410 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #207"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%
    Repository