Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TorchAudio Dispatcher Migration #2950

Open
6 tasks done
hwangjeff opened this issue Jan 3, 2023 · 2 comments
Open
6 tasks done

TorchAudio Dispatcher Migration #2950

hwangjeff opened this issue Jan 3, 2023 · 2 comments

Comments

@hwangjeff
Copy link
Contributor

hwangjeff commented Jan 3, 2023

Overview

We propose the following end state for TorchAudio’s I/O functions info, load, save:

  • FFmpeg is the primary backend for TorchAudio’s I/O functions info, load, save.
  • FFmpeg-, SoX-, and soundfile-based backends are user-selectable from said I/O functions and are no longer determined by global state.
  • All of FFmpeg, SoX, and soundfile are optional dependencies.
  • I/O functions no longer support TorchScript.

Context

TorchAudio’s functions info, load, and save currently rely on two third-party libraries: SoX and soundfile. Whereas SoX is used in the Linux and Mac distributions, soundfile is used in the Windows distribution.

Through the years, we’ve encountered several issues with SoX:

Separately, our work around streaming I/O introduced FFmpeg as a dependency. FFmpeg's advantages over SoX include the following:

  • It’s battle tested. It’s been developed for over 20 years now and is widely used in industry.
  • The library code is portable across Linux, Mac, and Windows.
  • It supports a wide variety of codecs, from basic to advanced, for both audio and video.
  • It supports GPU acceleration in decoding and encoding.
  • The C API offers a high degree of customizability.
    • It abstracts away many things like codecs, file formats, and devices.
    • It allows for implementing custom I/O such as in-memory decoding/encoding with file-like object protocol.
  • It’s being actively developed, with the latest version (5.1) having been released in July 2022.

End state

To address the issues above, we propose the following end state:

  • FFmpeg is the primary backend for TorchAudio’s I/O functions info, load, save.
  • FFmpeg-, SoX-, and soundfile-based backends are user-selectable from said I/O functions and are no longer determined by global state.
  • All of FFmpeg, SoX, and soundfile are optional dependencies.
  • I/O functions no longer support TorchScript.

We anticipate this end state bringing greater cross-platform consistency, simplifying our codebase, and delivering an improved user experience.

Plan

Release 2.0

  • Introduce option to {info, load, save} that allows users to choose any of FFmpeg, SoX, and soundfile as the I/O backend for both file paths and file objects, while preserving the existing behavior, i.e. Linux and Mac distributions default to relying on SoX, Windows distributions default to relying on soundfile.
    • Doing so naturally removes TorchScript support in {info, load, save}.
  • Add deprecation warnings that convey that release 2.0 will make FFmpeg the default backend for files and file objects for {info, load, save} and encourage users to switch over to FFmpeg.

Release 2.1

Release 2.2

@hwangjeff hwangjeff added the RFC label Jan 3, 2023
@vadimkantorov
Copy link

vadimkantorov commented Jan 23, 2023

Related discussion in core: pytorch/pytorch#81102. Ffmpeg integration is currently overlapped/duplicated between torchvision and torchaudio. It would be cool if it moved to a single implementation (in a new / separate package?)

Also supporting eliminating global backend state, and forcing user to maintain this selection themselves if they want to use a non-default backend.

@hwangjeff
Copy link
Contributor Author

hwangjeff commented Jan 24, 2023

Hi @vadimkantorov — thanks for flagging. Somewhat independently of this particular issue, we are indeed considering consolidating media I/O in a separate package. We'll post updates on the outcomes of our discussions to pytorch/pytorch#81102.

mthrok added a commit that referenced this issue Apr 5, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 5, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 5, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit to mthrok/audio that referenced this issue Apr 6, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also pytorch#2950
mthrok added a commit that referenced this issue Apr 6, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 7, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 11, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 12, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue Apr 28, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue May 10, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
mthrok added a commit that referenced this issue May 10, 2023
This commit makes the code defaults to the backend dispatcher by default.
Enabling backend dispatcher puts the FFmpeg-based I/O implementation on
higher priority (if the corresponding FFmpeg is available), and allows
individual function call to specify the backend.

See also #2950
facebook-github-bot pushed a commit that referenced this issue May 10, 2023
Summary:
This commit makes the code defaults to the backend dispatcher by default. Enabling backend dispatcher puts the FFmpeg-based I/O implementation on higher priority (if the corresponding FFmpeg is available), and allows individual function call to specify the backend.

See also #2950

Pull Request resolved: #3241

Reviewed By: hwangjeff

Differential Revision: D44709068

Pulled By: mthrok

fbshipit-source-id: 43aac3433f78a681df6669e9ac46e8ecf3beb1be
@mthrok mthrok pinned this issue May 10, 2023
mthrok added a commit that referenced this issue May 10, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.
mthrok added a commit to mthrok/audio that referenced this issue May 18, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit that referenced this issue May 19, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.
mthrok added a commit that referenced this issue May 19, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.
mthrok added a commit to mthrok/audio that referenced this issue May 23, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit to mthrok/audio that referenced this issue May 27, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit to mthrok/audio that referenced this issue May 30, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit that referenced this issue May 30, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.
mthrok added a commit to mthrok/audio that referenced this issue May 31, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit that referenced this issue May 31, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.
mthrok added a commit to mthrok/audio that referenced this issue Jun 1, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit to mthrok/audio that referenced this issue Jun 1, 2023
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in pytorch#2950.
mthrok added a commit that referenced this issue Jun 1, 2023
)

Summary:
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.

Pull Request resolved: #3035

Differential Revision: D44695647

Pulled By: mthrok

fbshipit-source-id: af1efd5c2f6f861ee34fc3d08a6703618206a100
facebook-github-bot pushed a commit that referenced this issue Jun 1, 2023
)

Summary:
This commit removes file-like obejct support so that we can remove custom patch

The motivation and plan is outlined in #2950.

Pull Request resolved: #3035

Reviewed By: hwangjeff

Differential Revision: D44695647

Pulled By: mthrok

fbshipit-source-id: 13af0234e288c041bc7b490e1f967f85ce7eb8ec
@mthrok mthrok changed the title TorchAudio FFmpeg migration TorchAudio Dispatcher Migration Sep 5, 2023
@mot0 mot0 unpinned this issue Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants