This project implements and compares several 5G NR polar coding and decoding paths for DCI and UCI control-channel messages. It includes a pure Python reference path, an optimized C CA-SCL decoder, a CUDA fixed-point decoder path, and several experimental deep-learning polar decoder models.
The classical CRC-aided SCL decoder is the main performance baseline. The deep-learning models are research prototypes for exploring whether neural networks can learn useful pieces of the polar decoding process. In the current experiments, the deep-learning models perform much worse than the SCL/CA-SCL baseline, so they should be treated as experimental scaffolds rather than production decoders.
The repository covers the main pieces of a single-code-block 5G polar simulation:
payload bits
-> DCI or UCI CRC attachment
-> 5G polar construction
-> polar encoding
-> rate matching
-> BPSK over AWGN
-> LLR generation
-> rate recovery
-> SC, SCL, C CA-SCL, CUDA CA-SCL, or neural decoding
-> BER / BLER measurement
Supported control-channel wrappers:
DCI: CRC24C with RNTI masking, nMax = 9
UCI: CRC6 or CRC11 depending on payload size, nMax = 10
py5gphy/
Python 5G polar encoder/decoder reference implementation.
c_lib/
C implementation of NR polar encode, rate match/recover, CRC, and CA-SCL
decoding. Exposes a shared library used by simulations and ctypes wrappers.
CUDA/
CUDA-oriented polar implementation and fixed-point decoder wrappers.
deep_learning/
Experimental PyTorch polar decoder models and evaluation scripts.
scripts/
Monte Carlo BLER/BER simulation scripts for Python, C, CUDA, and analysis.
out/
Saved checkpoints and simulation outputs.
how_to_run_deeplearning.md
Detailed guide for training and evaluating the neural polar decoders.
Create or activate a Python environment, then install the saved dependencies:
python -m venv .venv
source .venv/bin/activate
.venv/bin/python -m pip install -r requirements.txtFor C builds, use a normal C toolchain with make and gcc or a compatible
compiler. For CUDA builds, use a CUDA-capable system with nvcc.
Build the shared C polar library:
make -C c_lib sharedRun the C smoke test:
make -C c_lib
./c_lib/test_nr_polar_cThe smoke test performs noiseless DCI and UCI encode/decode round trips through the public C API.
Pure Python reference simulation:
.venv/bin/python scripts/sim_py_polar_decoder.pyC CA-SCL simulation:
.venv/bin/python scripts/sim_c_polar_decoder.pyCUDA simulation:
.venv/bin/python scripts/sim_cuda_polar_decoder.pyThese scripts run Monte Carlo trials over an SNR grid and report BLER/BER. The default grids are intentionally small enough to edit directly in each script for experiments.
The figure below is copied from
scripts/plot_analysis_c_lib_polar_performance.ipynb. It shows the saved
c_lib BLER result for the UCI A=120, E=360, rate 1/3 configuration using
the int16 CA-SCL decoder with list size L=1,8,16,32.
LDPC decoder is around 0.6dB worse than polar decoder
The deep_learning/ folder contains four experimental model families:
min-sum-bp
Unrolled trainable min-sum / BP-style polar message passing.
permutation-bp
Multiple min-sum BP branches over deterministic phase permutations.
partitioned
Shared neural nodes over fixed-size LLR blocks plus a global fusion head.
sparse-graph
Learned message passing over the polar butterfly graph.
All neural models consume rate-recovered polar LLRs in phase order and output payload-bit logits. Training data is generated synthetically:
random payload -> 5G polar encode -> BPSK AWGN -> LLR -> rate recovery
For detailed training and evaluation commands, see:
how_to_run_deeplearning.md
The main metrics are:
BER = payload bit error rate
BLER = block/frame error rate
For control-channel decoding, BLER is usually the more important metric because one wrong payload bit makes the whole decoded control message unusable.
When comparing decoders, keep these settings identical:
channel type
payload length A
rate-matched length E
SNR range
number of frames per SNR point
list size L for SCL/CA-SCL
LLR type, such as float or int16
This repository focuses on single-code-block polar experiments. The UCI wrappers
exclude unsupported high-payload/high-E segmentation cases. The CUDA path is
oriented around fixed-point int16 decoding. The deep-learning models are not yet
competitive with CA-SCL and are best used for research exploration and ablation
studies.

