audio: Tracking Issue for Flaky File-like obj CI failure
Some tests for file-like object support for load
function are failing sporadicly. Retrying the job makes the failure go away, but we need to understand what is causing the flaky failure.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16
Commits related to this issue
- Add NNAPI tutorial (#1229) — committed to mthrok/audio by dreiss 4 years ago
Resolved by #1297
Okay, I think I figured. The
is_seekable
function is checking thestat.st_mode
of an opened file, which is invalid in case of memory object.https://github.com/dmkrepo/libsox/blob/b9dd1a86e71bbd62221904e3e59dfaa9e5e72046/src/formats.c#L336
Checking the data from failure mode 2; the source audio file and audio files processed with
sox
have the same checksum. This indicates that there is some un-deterministic behavior in torchaudio’s implementation.Success - torchaudio_unittest.backend.sox_io.save_test.SaveTest.test_save_flac_bytesio_16_0.tar.gz
Failure - torchaudio_unittest.backend.sox_io.save_test.SaveTest.test_save_flac_bytesio_16_0.tar.gz
Checksum of generated files.
Success
Failure
Where are they different?
Truncating the first 10K (12K total) gives the same check sum. This suggests that the un-deterministic behavior occurs at the end where the file is closed.
Success
Failure
How are they written?
Tapping into the number of bytes written each time
write()
is called, there is a slight difference in success case and failure case.debug wrapper
Success
Failure
Potentially problematic code?
The final
write
is called athttps://github.com/pytorch/audio/blob/3488f3142c734326b54badfba4b166173647d1b2/torchaudio/csrc/sox/io.cpp#L299-L303
The problem here is that, to get the final byte chunk, we need to close the
sox_format_t
structure. But doing so for the case of in-memory file object, we will lose the way to see how many bytes are written to the buffer. In the above code we usebuffer.size
, hoping that under the hood, the new buffer size is same as the number of data written, which could be wrong…But where is the un-deterministic behavior coming from?
The above investigation still does not explain where is the origin. Is it
open_memstream
used by libsox? libsox implementation or flac encoder?Checking at the data from the failure mode 2;
torchaudio_unittest.backend.sox_io.save_test.SaveTest.test_save_flac_bytesio_16_0.tar.gz
looks like ~the conversion from flac to wav is altering the data.~ flac data has something wrong.
Audacity also reports that the final part of data is missing.