You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nvcomp: Unnecessary sync events and host memory transfers #300
Hi @dxqb,
Thank you for reaching out regarding this concern.
nvCOMP's python API is built upon the nvCOMP HLIF API. During decompression, we do several checks on the encoded stream header to make sure it can be decompressed correctly. For example, we check
Whether the codec being used to decompress is the same as the one which was used to encode
Whether the compressed stream was generated from an old version of nvCOMP
To calculate the output buffer size which is stored in the compressed stream header.
To be able to do this, we have to copy over the stream header to the pinned memory and do a stream synchronize.
Hope I answered your questions.
Hi @dxqb, Thank you for reaching out regarding this concern. nvCOMP's python API is built upon the nvCOMP HLIF API.
Are you saying that this issue can be avoided by using the C++ API instead (and using self-made python bindings)?
During decompression, we do several checks on the encoded stream header to make sure it can be decompressed correctly. For example, we check
To be able to do this, we have to copy over the stream header to the pinned memory and do a stream synchronize. Hope I answered your questions.
I see. Don't you think it should be possible to do these checks on GPU-only and CPU-only without any transfers?
* Whether the codec being used to decompress is the same as the one which was used to encode
* Whether the compressed stream was generated from an old version of nvCOMP
* To calculate the output buffer size which is stored in the compressed stream header.
all of these could be separated into
the data stream (that lives on GPU)
metadata (that could live on CPU)
Effectively syncing CPU with GPU after each decompression is a dealbreaker for any application that seeks to decompress on GPU for parallelization and then use the decompressed data on GPU. And why else would you even want to decompress on GPU?
I have tried an implementation that schedules the decompression in advance on a separate CUDA stream, so that when the main CUDA stream wants to use the decompressed data, the performance bottleneck has already been passed.
That works, but it's quite involved and shouldn't be necessary.
We've triaged this and confirmed the issue. To support this use-case through the Python API, we plan to split the decode API into two steps:
Configure decompression - handles the copies and synchronization required for metadata
Decode - performs the actual decompression
Using your snippet, we were able to reproduce the problem and achieve a significant speedup with this split, along with some memory copy optimizations.
The full fix is currently in works. Keep an eye on our CHANGELOG.md for upcoming releases.
Thank you for addressing this! I have revisited the experiment back then and it turned out better than expected:
Compression of int8-quantized transformer weights up to ~ 45%, effectively turning it into a 4-5 bit quant without quality loss and low performance impact: Nerogar/OneTrainer#1630
A sync-free API was required for this. However, it's not completely sync-free yet:
There are still stalls in the compute stream after the decompressions (in blue). This seems to be some type of status synchronisation, that - if you know that the data is fine because you have compressed it yourself - shouldn't be necessary. Does the python API expose that currently?
I haven't found it.
Claude has come up with a way to circumvent it by using the C API directly, but it's not nice code: Nerogar/OneTrainer@5ecdb24#diff-2410c3c3e9c7964747d03f5d3041ac898f88b82775287c10e92e07c393a67c92
do you want to reopen this issue? should I report it separately? or notplanned?
Activity
naveenaero commentedon Jan 6, 2026
Hi @dxqb,
Thank you for reaching out regarding this concern.
nvCOMP's python API is built upon the nvCOMP HLIF API. During decompression, we do several checks on the encoded stream header to make sure it can be decompressed correctly. For example, we check
To be able to do this, we have to copy over the stream header to the pinned memory and do a stream synchronize.
Hope I answered your questions.
dxqb commentedon Jan 7, 2026
Thanks!
Are you saying that this issue can be avoided by using the C++ API instead (and using self-made python bindings)?
I see. Don't you think it should be possible to do these checks on GPU-only and CPU-only without any transfers?
all of these could be separated into
Effectively syncing CPU with GPU after each decompression is a dealbreaker for any application that seeks to decompress on GPU for parallelization and then use the decompressed data on GPU. And why else would you even want to decompress on GPU?
I have tried an implementation that schedules the decompression in advance on a separate CUDA stream, so that when the main CUDA stream wants to use the decompressed data, the performance bottleneck has already been passed.
That works, but it's quite involved and shouldn't be necessary.
gmrrk commentedon Feb 20, 2026
@dxqb Thanks for the report!
We've triaged this and confirmed the issue. To support this use-case through the Python API, we plan to split the decode API into two steps:
Using your snippet, we were able to reproduce the problem and achieve a significant speedup with this split, along with some memory copy optimizations.
The full fix is currently in works. Keep an eye on our CHANGELOG.md for upcoming releases.
gmrrk commentedon Feb 20, 2026
We will mark this issue as closed when the fix gets released.
gmrrk commentedon Jul 17, 2026
@dxqb Hello, with 5.3 we released a way to skip the sync when you know the decompressed size of the requested buffer.
For the API additions that allow this look at Pre-configure API section in jupyter notebook published with nvCOMP 5.3: https://github.com/NVIDIA/CUDALibrarySamples/blob/main/nvCOMP/examples/python/nvcomp_basic.ipynb
dxqb commentedon Jul 18, 2026
Thank you for addressing this! I have revisited the experiment back then and it turned out better than expected:
Compression of int8-quantized transformer weights up to ~ 45%, effectively turning it into a 4-5 bit quant without quality loss and low performance impact: Nerogar/OneTrainer#1630
A sync-free API was required for this. However, it's not completely sync-free yet:

There are still stalls in the compute stream after the decompressions (in blue). This seems to be some type of status synchronisation, that - if you know that the data is fine because you have compressed it yourself - shouldn't be necessary. Does the python API expose that currently?
I haven't found it.
Claude has come up with a way to circumvent it by using the C API directly, but it's not nice code: Nerogar/OneTrainer@5ecdb24#diff-2410c3c3e9c7964747d03f5d3041ac898f88b82775287c10e92e07c393a67c92
do you want to reopen this issue? should I report it separately? or notplanned?