Skip to content

Commit 38d5388

Browse files
author
pytorchbot
committed
2026-05-20 nightly release (e4be2e0)
1 parent ff70fc7 commit 38d5388

19 files changed

Lines changed: 217 additions & 52 deletions

.github/workflows/cpp_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
ffmpeg-version-for-tests: ['7.0.1']
22+
ffmpeg-version-for-tests: ['7']
2323
steps:
2424
- name: Check out repo
2525
uses: actions/checkout@v6

.github/workflows/linux_aarch64_wheel.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
fail-fast: false
6565
matrix:
6666
python-version: ['3.10']
67-
ffmpeg-version-for-tests: ['7.0.1']
67+
ffmpeg-version-for-tests: ['7']
6868
needs: build
6969
steps:
7070
- name: Check out repo
@@ -105,6 +105,11 @@ jobs:
105105
- name: Install test dependencies
106106
run: bash packaging/install_test_dependencies.sh
107107

108+
- name: Run Python smoke tests
109+
run: |
110+
pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short
111+
108112
- name: Run Python tests
113+
if: ${{ matrix.ffmpeg-version-for-tests == '7' && !startsWith(github.ref, 'refs/heads/release/') }}
109114
run: |
110115
pytest --override-ini="addopts=-v" test

.github/workflows/linux_cuda_aarch64_wheel.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
matrix:
6565
python-version: ['3.10']
6666
cuda-version: ['12.6']
67-
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1', '8.0']
67+
ffmpeg-version-for-tests: ['4', '5', '6', '7', '8']
6868
container:
6969
image: "pytorch/manylinuxaarch64-builder:cuda${{ matrix.cuda-version }}"
7070
needs: build
@@ -111,6 +111,11 @@ jobs:
111111
112112
- name: Install test dependencies
113113
run: bash packaging/install_test_dependencies.sh
114+
- name: Run Python smoke tests
115+
run: |
116+
pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short
117+
114118
- name: Run Python tests
119+
if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }}
115120
run: |
116121
pytest --override-ini="addopts=-v" test

.github/workflows/linux_cuda_wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
# but for releases we should add 12.8.
7272
cuda-version: ['12.6', '13.0']
7373
# TODO: put back ffmpeg 5 https://github.com/pytorch/torchcodec/issues/325
74-
ffmpeg-version-for-tests: ['4.4.2', '6', '7', '8.0']
74+
ffmpeg-version-for-tests: ['4', '6', '7', '8']
7575

7676
container:
7777
image: "pytorch/manylinux2_28-builder:cuda${{ matrix.cuda-version }}"

.github/workflows/linux_wheel.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
fail-fast: false
6565
matrix:
6666
python-version: ['3.10']
67-
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1', '8.0']
67+
ffmpeg-version-for-tests: ['4', '5', '6', '7', '8']
6868
needs: build
6969
steps:
7070
- name: Check out repo
@@ -115,7 +115,7 @@ jobs:
115115
fail-fast: false
116116
matrix:
117117
python-version: ['3.10']
118-
ffmpeg-version-for-tests: ['8.0']
118+
ffmpeg-version-for-tests: ['8']
119119
needs: build
120120
steps:
121121
- name: Check out repo

.github/workflows/macos_wheel.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
with-rocm: disable
3737
with-cuda: disable
3838
build-python-only: "disable"
39+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
3940

4041
build:
4142
needs: generate-matrix
@@ -65,7 +66,7 @@ jobs:
6566
fail-fast: false
6667
matrix:
6768
python-version: ['3.10']
68-
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1', '8.0']
69+
ffmpeg-version-for-tests: ['4', '5', '6', '7', '8']
6970
needs: build
7071
steps:
7172
- name: Check out torchcodec repo
@@ -106,6 +107,11 @@ jobs:
106107
- name: Install test dependencies
107108
run: bash packaging/install_test_dependencies.sh
108109

110+
- name: Run Python smoke tests
111+
run: |
112+
pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short
113+
109114
- name: Run Python tests
115+
if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }}
110116
run: |
111117
pytest --override-ini="addopts=-v" test

.github/workflows/reference_resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
# Traditionally we generate the resources locally on FFmpeg 4 or 6.
5757
# The exact version shouln't matter as long as the unit tests pass
5858
# across all version for a given generated resource.
59-
ffmpeg-version-for-tests: ['6.1.1']
59+
ffmpeg-version-for-tests: ['6']
6060
steps:
6161
- name: Check out repo
6262
uses: actions/checkout@v3

.github/workflows/windows_cuda_wheel.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
with-rocm: disable
3838
with-cuda: enable
3939
build-python-only: "disable"
40+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
4041

4142
build:
4243
needs: generate-matrix
@@ -77,7 +78,7 @@ jobs:
7778
# TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing
7879
# bad parameters.
7980
# See https://github.com/pytorch/torchcodec/pull/806
80-
ffmpeg-version-for-tests: ['4.4.2', '6.1.1', '7.0.1', '8.0']
81+
ffmpeg-version-for-tests: ['4', '6', '7', '8']
8182
needs: build
8283
steps:
8384
- name: Setup env vars
@@ -91,12 +92,7 @@ jobs:
9192
uses: actions/checkout@v6
9293

9394
- name: Update NVIDIA driver
94-
shell: cmd
95-
run: |
96-
curl --retry 3 -kL https://ossci-windows.s3.amazonaws.com/580.88-data-center-tesla-desktop-win10-win11-64bit-dch-international.exe --output driver_installer.exe
97-
start /wait driver_installer.exe -s -noreboot
98-
del driver_installer.exe
99-
nvidia-smi
95+
uses: pytorch/test-infra/.github/actions/setup-nvidia-windows@main
10096

10197
- name: Remove src/ folder
10298
run: bash packaging/remove_src.sh

.github/workflows/windows_wheel.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
# TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing
7272
# bad parameters.
7373
# See https://github.com/pytorch/torchcodec/pull/806
74-
ffmpeg-version-for-tests: ['4.4.2', '6.1.1', '7.0.1', '8.0']
74+
ffmpeg-version-for-tests: ['4', '6', '7', '8']
7575
needs: build
7676
steps:
7777
- name: Check out repo
@@ -112,5 +112,11 @@ jobs:
112112
- name: Install test dependencies
113113
run: bash packaging/install_test_dependencies.sh
114114

115+
- name: Run Python smoke tests
116+
run: |
117+
pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short
118+
115119
- name: Run Python tests
116-
run: pytest --override-ini="addopts=-v" test
120+
if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }}
121+
run: |
122+
pytest --override-ini="addopts=-v" test
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
"""
2+
Basic benchmark aimed at validating that the new Encoder class isn't slower than
3+
the existing VideoEncoder and AudioEncoder.
4+
"""
5+
6+
import os
7+
import tempfile
8+
from time import perf_counter_ns
9+
10+
import torch
11+
12+
from torchcodec.encoders import AudioEncoder, Encoder, VideoEncoder
13+
14+
15+
def bench(f, *args, num_exp=100, warmup=0, **kwargs):
16+
for _ in range(warmup):
17+
f(*args, **kwargs)
18+
19+
times = []
20+
for _ in range(num_exp):
21+
start = perf_counter_ns()
22+
f(*args, **kwargs)
23+
end = perf_counter_ns()
24+
times.append(end - start)
25+
return torch.tensor(times).float()
26+
27+
28+
def report_stats(times, unit="ms"):
29+
mul = {
30+
"ns": 1,
31+
"µs": 1e-3,
32+
"ms": 1e-6,
33+
"s": 1e-9,
34+
}[unit]
35+
times = times * mul
36+
std = times.std().item()
37+
med = times.median().item()
38+
print(f"{med = :.2f}{unit} +- {std:.2f}")
39+
return med
40+
41+
42+
# --- Config ---
43+
height, width = 256, 256
44+
frame_rate = 30
45+
num_channels = 2
46+
sample_rate = 48000
47+
durations_s = [3, 10]
48+
49+
50+
def encode_video_with_video_encoder(frames, dest):
51+
encoder = VideoEncoder(frames, frame_rate=frame_rate)
52+
encoder.to_file(dest)
53+
54+
55+
def encode_video_with_streaming_encoder(frames, dest):
56+
encoder = Encoder()
57+
video_stream = encoder.add_video(
58+
height=frames.shape[2],
59+
width=frames.shape[3],
60+
frame_rate=frame_rate,
61+
device=str(frames.device),
62+
)
63+
with encoder.open_file(dest):
64+
video_stream.add_frames(frames)
65+
66+
67+
def encode_audio_with_audio_encoder(samples, dest):
68+
encoder = AudioEncoder(samples, sample_rate=sample_rate)
69+
encoder.to_file(dest)
70+
71+
72+
def encode_audio_with_streaming_encoder(samples, dest):
73+
encoder = Encoder()
74+
audio_stream = encoder.add_audio(sample_rate=sample_rate, num_channels=num_channels)
75+
with encoder.open_file(dest):
76+
audio_stream.add_samples(samples)
77+
78+
79+
if __name__ == "__main__":
80+
tmpdir = tempfile.mkdtemp()
81+
82+
devices = ["cpu"]
83+
if torch.cuda.is_available():
84+
devices.append("cuda")
85+
86+
for duration_s in durations_s:
87+
print(f"\n{'=' * 50}")
88+
print(f"Duration: {duration_s}s")
89+
print(f"{'=' * 50}")
90+
91+
num_frames = frame_rate * duration_s
92+
video_frames = torch.randint(
93+
0, 256, (num_frames, 3, height, width), dtype=torch.uint8
94+
)
95+
96+
num_samples = sample_rate * duration_s
97+
audio_samples = torch.randn(num_channels, num_samples)
98+
99+
# --- Video benchmarks ---
100+
for device in devices:
101+
frames = video_frames.to(device)
102+
dest = os.path.join(tmpdir, "video.mp4")
103+
104+
print(f"\n--- Video encoding ({device}) ---")
105+
106+
print("VideoEncoder: ", end="")
107+
times = bench(
108+
encode_video_with_video_encoder, frames, dest, num_exp=10, warmup=2
109+
)
110+
report_stats(times)
111+
112+
print("StreamingEncoder:", end="")
113+
times = bench(
114+
encode_video_with_streaming_encoder, frames, dest, num_exp=10, warmup=2
115+
)
116+
report_stats(times)
117+
118+
# --- Audio benchmarks ---
119+
print("\n--- Audio encoding (cpu) ---")
120+
dest = os.path.join(tmpdir, "audio.wav")
121+
122+
print("AudioEncoder: ", end="")
123+
times = bench(
124+
encode_audio_with_audio_encoder, audio_samples, dest, num_exp=10, warmup=2
125+
)
126+
report_stats(times)
127+
128+
print("StreamingEncoder:", end="")
129+
times = bench(
130+
encode_audio_with_streaming_encoder,
131+
audio_samples,
132+
dest,
133+
num_exp=10,
134+
warmup=2,
135+
)
136+
report_stats(times)

0 commit comments

Comments
 (0)