feat(qec): add trt_decoder_config for real-time decoding #384
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.
Add comprehensive configuration support for TensorRT decoder in the real-time decoding system.
Add TensorRT Decoder Configuration Support for Real-Time Decoding
Summary
This PR adds comprehensive configuration support for the TensorRT decoder in the real-time decoding system, enabling users to configure TRT decoders through the standard
decoder_configinterface with full YAML serialization support.Motivation
The TensorRT decoder previously lacked integration with the real-time decoding configuration system. This made it impossible to configure TRT decoders using YAML files or the standard
decoder_configAPI that other decoders (nv-qldpc, sliding_window, etc.) support.Changes
1. Core Configuration Struct
Added
trt_decoder_configstruct indecoding_config.hwith five parameters:onnx_load_path(string): Path to ONNX model file (builds TRT engine)engine_load_path(string): Path to pre-built TensorRT engine (faster startup)engine_save_path(string): Path to save built engine for reuseprecision(string): Inference precision mode (fp16, bf16, int8, fp8, tf32, best)memory_workspace(size_t): Workspace memory size in bytes (default: 1GB)2. Integration with Decoder Config System
trt_decoder_configto thedecoder_configvariantto_heterogeneous_map()andfrom_heterogeneous_map()methodsMappingTraits<trt_decoder_config>set_decoder_custom_args_from_heterogeneous_map()for type dispatch3. Python Bindings
trt_decoder_configto Python via pybind11cudaq_qec.trt_decoder_config()4. Comprehensive Tests
Added 3 test functions covering:
None)Usage Example
Python:
import cudaq_qec as qec
Create TRT decoder config
trt = qec.trt_decoder_config()
trt.engine_load_path = "/path/to/model.engine"
trt.precision = "fp16"
Use with decoder_config
dc = qec.decoder_config()
dc.type = "trt_decoder"
dc.set_decoder_custom_args(trt)
YAML roundtrip
yaml_str = dc.to_yaml_str()
dc2 = qec.decoder_config.from_yaml_str(yaml_str)C++:
using namespace cudaq::qec::decoding::config;
// Create TRT decoder config
trt_decoder_config trt;
trt.engine_load_path = "/path/to/model.engine";
trt.precision = "fp16";
// Use with decoder_config
decoder_config dc;
dc.type = "trt_decoder";
dc.decoder_custom_args = trt;
// YAML roundtrip
auto yaml_str = dc.to_yaml_str();
auto dc2 = decoder_config::from_yaml_str(yaml_str);### Testing
All tests pass: ✅ 34/34 in
test_decoding_config.pyTest breakdown:
Run tests with:
pytest libs/qec/python/tests/test_decoding_config.py -k "trt_decoder" -v### Files Changed