Add repro & preload-workaround scripts for torchcodec / transformers import-order issue #42107
+89
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds small reproducible scripts and documentation demonstrating an import-order issue between torchcodec and transformers' audio modules and a minimal runtime workaround that preloads the system libavcodec before loading torchcodec's extension.\n\nFiles added:\n- scripts/torchcodec_preload/repro_fail_order.py — repro that imports torchcodec first and may fail\n- scripts/torchcodec_preload/repro_fix_ctypes_preload.py — preloads libavcodec via ctypes then loads torchcodec and transformers\n- scripts/torchcodec_preload/README.md — instructions to inspect libavcodec and run examples\n\nTesting notes:\n- In some environments (including the container used to create this PR), ffmpeg/libavcodec may not be installed; may return nothing. Run locally to find a candidate path.\n- Recommended local test sequence:\n 1) \n 2) Could not find libavcodec via ctypes.util.find_library('avcodec').
Run
ldconfig -p | grep avcodecto locate a system lib, or set LD_PRELOAD. — should preload and succeed\n 3) — demonstrates the original failing order\n\nRationale and suggested next steps:\n- This PR intentionally adds only examples and docs to help reproduce and triage loader/symbol-version mismatches without modifying library code.\n- If maintainers prefer, we can follow up with either a small runtime helper in to optionally preload ffmpeg libs, or open a reproducible issue on the torchcodec repo and collaborate on a longer-term fix.\n\nIf you want me to also add a small helper function and unit tests in this PR, say so and I will prepare the changes.