Skip to content

Add a production PyTorch MRT2 backend for Linux and Windows #110

Description

@brxs

Summary

Add a production PyTorch backend for Magenta RealTime 2 on Linux and Windows, consuming Apolinario's implementation as a pinned upstream dependency behind a thin LSDJ adapter. Keep MLX as the macOS backend.

Dependencies

Architecture

  • Define a runtime-neutral MRT2 service contract used by the Rust host and frontend.
  • Select MLX on supported macOS systems and PyTorch on supported Linux/Windows NVIDIA systems.
  • Keep platform/backend selection explicit and diagnosable; do not silently choose an unsupported CPU path.
  • Consume a versioned upstream package/tag when available, otherwise an immutable VCS revision. Do not copy or fork the runtime into LSDJ.
  • Keep the LSDJ-owned layer limited to API adaptation, lifecycle integration, input/output normalization, and diagnostics.
  • Use the worker topology selected by Spike: validate Apolinario's PyTorch MRT2 port for LSDJ #109 and supervise it through Refactor LSDJ's cross-platform application foundation #107, including readiness, heartbeat/watchdog, bounded logs, graceful shutdown, crash detection, and full process-tree cleanup.

Scope

Backend parity

  • Implement prompt, negative prompt, guidance, temperature, top-k, seed, steering/conditioning, reset, warm-up, and model selection with the semantics validated in Spike: validate Apolinario's PyTorch MRT2 port for LSDJ #109.
  • Preserve the existing chunk/context/overlap contract, sample rate, channel layout, and continuous audio behavior.
  • Surface any intentional cross-backend semantic difference in UI/help and diagnostics.

Runtime and model management

Performance and scheduling

  • Support both LSDJ scheduling modes validated by the spike:
    • 25 frames / approximately 1 second;
    • 5 frames / approximately 200 ms when both decks are armed.
  • Preserve the approximately 1.5-second playback-ring safety model.
  • Prevent background install, logging, or model-management work from blocking the real-time audio callback.
  • Expose generation latency, queue depth, worker health, and engine-reported underruns for diagnostics and smoke tests.

Failure behavior

  • Fail clearly for unsupported hardware, insufficient VRAM, incompatible drivers, corrupt assets, and worker startup/crash conditions.
  • A failure on one model worker must follow the isolation behavior chosen in the spike and must never orphan GPU processes after app exit.
  • Preserve the previous verified runtime/model when an update fails.

Tests and documentation

  • Adapter contract tests using deterministic/fake backends.
  • Cross-backend parity fixtures for controls and audio shape/timing.
  • Runtime install/update/rollback tests on Ubuntu and Windows CI.
  • Process readiness, crash, timeout, and cleanup tests.
  • Hardware smoke checklist reused by the Linux and Windows release issues.
  • Contributor documentation for updating the pinned upstream dependency without creating an LSDJ fork.

Acceptance criteria

  • Linux and Windows select the PyTorch backend; supported macOS continues to select MLX.
  • The production dependency is pinned to an immutable upstream release/revision and no runtime source is vendored or forked into LSDJ.
  • Users do not need system Python, Git, shell tooling, or a CUDA toolkit.
  • All required LSDJ controls pass the parity fixtures agreed in Spike: validate Apolinario's PyTorch MRT2 port for LSDJ #109.
  • On the proposed minimum NVIDIA hardware, both decks run for 10 minutes in both scheduling modes with zero engine-reported underruns.
  • Diagnostics report backend, dependency/model revision, driver/runtime version, latency, queue depth, and worker state.
  • Failed installs/updates retain the previous working version, and app exit leaves no worker descendants.
  • CI covers shared adapter/install/lifecycle behavior on Ubuntu and Windows; real-hardware results are recorded in the platform release checklists.

Out of scope

  • Replacing the macOS MLX backend.
  • Maintaining an LSDJ fork of the PyTorch port.
  • CPU-only MRT2 support.
  • AMD or Intel GPU support.
  • Platform installers and hardware certification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions