Skip to content

platforms: native dispatcher reuses buffers that workers may still read after an exception #170

Closed

Description

@gspark-etri

Problem

After moe_disp_start posts jobs, any exception before moe_disp_wait (e.g. a GPU OOM in a device tier) leaves workers running with d->n set. The next call's reserve() frees j->x/out/idx while a worker may still read them (use-after-free); a half-finished pipe exchange also desyncs the RNGD server.

Evidence and reproduction

opt_prime/opt_prime/accel/moe/layer.py:154-185, accel/platforms/cpu/csrc/dispatch.c:272-290,294. Verified by reading: no try/finally around start/wait.

Environment

optimus-rm @253be20; Python 3.10, torch 2.10.0+cu128, transformers 5.1.0; RNGD+A100 host (CPU / one A100 for the checks).

Scope

dispatch.c, layer.py.

Done when

Start drains jobs left from a failed call and Python always waits in finally; a test raises between start and wait and the next call is correct.

Owner

@gspark-etri

Activity

  1. gspark-etri commented on Oct 23, 2026

    @gspark-etri
    CollaboratorAuthor

    Fixed by #179, squash-merged into optimus-rm.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions