This repository provides a C/Python-based simulation framework to evaluate both lossless (features) and lossy (filters) data compression techniques at the CXL flit granularity (256B), as part of a national project on next-generation memory subsystems for AI accelerators.
This work was supported by the Technology Innovation Program
(Industrial Strategic Technology Development Program - Public-Private Joint Investment Advanced Semiconductor Talent Development Project)
Project ID: RS-2023-00237136
Title: Development of CXL/DDR5-based memory subsystem for AI accelerators
Funding: Ministry of Trade, Industry & Energy (MOTIE, Korea) (1415187686)
This repository implements simulation code and evaluation logic for the following key deliverables defined in the national project’s performance goals:
- Goal: Apply lossless compression to 16-bit DNN feature maps in 256B CXL flit blocks, and compute compression ratios.
- Key Metric:
Compression Ratio = (Original Size) / (Compressed Size)
- Target:
Unlike stream-based compression (e.g., Zhuo Chen 2018), block-based compression faces limited redundancy, but is crucial for random access. This simulation targets a 2:1 lossless compression ratio on flit-sized blocks. - Evaluation:
- Simulated via C/Python code (not FPGA)
- Based on ResNet-50 feature maps
- Per-layer results are aggregated and logged
- Goal: Compress FP32 filters using quantization + lossy compression without reducing Top-1 accuracy by more than 1%.
- Key Metric:
Compression Ratio = (Original FP32 size) / (Compressed size)
- Target:
Filters contain fewer zeros, making lossless compression inefficient. This simulation seeks 4:1 lossy compression while preserving accuracy. - Evaluation:
- Simulated via C/Python
- Restored filters are used in ResNet-50 inference
- Accuracy loss ≤ 1% is enforced
- Docker (≥ 20.10)
- Git (optional)
- Clone this repository
git clone https://github.com/scalable-arch/CXL-Compression.git
cd CXL-Compression- Build Docker image
docker build -t cxl-comp .- Run the container
docker run --rm -it -v $(pwd):/workspace cxl-comp- Execute the full pipeline
./run_all.shYou can start from a specific step by providing a step number as an argument:
./run_all.sh <step_number>For example:
./run_all.sh 5This will skip steps 1 to 4 and begin from step 5.
| Step | Title | Description |
|---|---|---|
| 1 | Extract Feature Maps | Extract 16-bit feature maps from sample ImageNet images using ResNet-50. |
| 2 | Merge Feature Maps Operation-wise | Group feature maps by operation (e.g., conv1, relu) for flit-level compression. |
| 3 | Compile Feature Compression Code | Build the C++ lossless compressor used for 128B feature block compression. |
| 4 | Run Feature Compression | Compress feature maps and generate compression ratio logs and plots. |
| 5 | Compile Weight Compression Libraries | Build C++ shared libraries for lossy compression & masking compression. |
| 6 | Run Weight Compression (Simple Truncation) | Apply compression, fixed masks on all weight in blocks and evaluate accuracy drop. |
| 7 | Run Weight Compression (Adaptive Truncation) | Apply compression, select masks adaptively per block and evaluate accuracy drop. |
| 8 | Print Total Results | Show compression summary and Top-1 / Top-5 accuracy changes after weight truncation. |
📂 All result logs and plots are saved under the total-result/ directory.
.
├── extract-data # DNN feature map extraction
├── feature-compression # Feature lossless compression
├── imagenet-sample-images # ImageNet sample images
├── weight-sensitivity-analysis # Weight sensitivity analysis
├── weight-compression # Weight lossy compression
├── total-result # Result reports (created by script)
├── Dockerfile # Docker build file
├── run_all.sh # Full pipeline script
├── images # Graph Result Images
├── README.md
└── LICENSE
Sample log line:
Block Mask Ratio | Original Restored | Orig(bin) Rest(bin)
==================================================================================================================================
[Block 1] Ratio: 1.1763, Compressed bits: 1741, Mask usage: {'mask20': 13, 'mask19': 51}
1 mask20 1.1763354394026422 | -0.01909715 -0.01757812 | 10111100100111000111000110100011 10111100100100000000000000000000
1 mask20 1.1763354394026422 | -0.44219688 -0.43750000 | 10111110111000100110011110100001 10111110111000000000000000000000
1 mask20 1.1763354394026422 | -0.01033773 -0.00976562 | 10111100001010010101111110010011 10111100001000000000000000000000
1 mask20 1.1763354394026422 | -0.36786637 -0.34375000 | 10111110101111000101100011111011 10111110101100000000000000000000
1 mask20 1.1763354394026422 | 0.00367908 0.00366211 | 00111011011100010001110010110001 00111011011100000000000000000000
1 mask20 1.1763354394026422 | -0.09179689 -0.08593750 | 10111101101111000000000000000010 10111101101100000000000000000000
...
1 mask19 1.1763354394026422 | 0.00530118 0.00512695 | 00111011101011011011010110000011 00111011101010000000000000000000
1 mask19 1.1763354394026422 | -0.03543944 -0.03515625 | 10111101000100010010100011110011 10111101000100000000000000000000
1 mask19 1.1763354394026422 | 0.00795496 0.00781250 | 00111100000000100101010110001000 00111100000000000000000000000000
1 mask19 1.1763354394026422 | -0.14247002 -0.14062500 | 10111110000100011110001110101001 10111110000100000000000000000000
1 mask19 1.1763354394026422 | -0.01383873 -0.01367188 | 10111100011000101011101111010100 10111100011000000000000000000000
1 mask19 1.1763354394026422 | -0.01616473 -0.01562500 | 10111100100001000110101111100100 10111100100000000000000000000000
1 mask19 1.1763354394026422 | 0.00619890 0.00610352 | 00111011110010110010000000101100 00111011110010000000000000000000
[Block 2] Ratio: 1.1763, Compressed bits: 1741, Mask usage: {'mask20': 13, 'mask19': 51}
2 mask20 1.1763354394026422 | -0.01067094 -0.00976562 | 10111100001011101101010100101100 10111100001000000000000000000000
2 mask20 1.1763354394026422 | 0.10300009 0.10156250 | 00111101110100101111000110110110 00111101110100000000000000000000
2 mask20 1.1763354394026422 | -0.00293915 -0.00292969 | 10111011010000001001111011010000 10111011010000000000000000000000
2 mask20 1.1763354394026422 | 0.28020972 0.25000000 | 00111110100011110111011110100110 00111110100000000000000000000000
2 mask20 1.1763354394026422 | -0.08703937 -0.08593750 | 10111101101100100100000110110010 10111101101100000000000000000000
2 mask20 1.1763354394026422 | -0.01414643 -0.01367188 | 10111100011001111100011001101111 10111100011000000000000000000000
...
Summary report:
═════════════════════════════════════════════════════
🔹 8) Print Total Results
═════════════════════════════════════════════════════
📄 result_bf16.log:
Filename Blocks Average
avgpool_all.bin.log 320 1.2584
bn1_all.bin.log 423360 3.5146
bn2_all.bin.log 215600 2.9779
bn3_all.bin.log 862400 3.0428
conv1_all.bin.log 423360 1.4366
conv2_all.bin.log 215600 1.3945
conv3_all.bin.log 862400 1.4864
downsample_all.bin.log 470400 1.8797
fc_all.bin.log 156 1.2263
maxpool_all.bin.log 31360 4.5169
relu_all.bin.log 987840 3.2385
TOTAL 4492796 2.4863
📄 Origin Accuracy
[Original FP32] Top-1 Accuracy: 92.97%, Top-5 Accuracy: 98.83%
📄 Simple Truncation with Exponent-BPC Accuracy
[Restored Adaptive] Top-1 Accuracy: 84.57%, Top-5 Accuracy: 96.48%
📊 Top-1 Drop: 8.40%
📉 Top-5 Drop: 2.34%
📄 Adaptive Truncation with Exponent-BPC Accuracy
[Restored Adaptive] Top-1 Accuracy: 90.23%, Top-5 Accuracy: 98.63%
📊 Top-1 Drop: 2.73%
📉 Top-5 Drop: 0.20%
- Name: [Boyeol Choi & Jungrae Kim]
- Affiliation: [Scalable Architecture Lab. / Sungkyunkwan University]
- Contact: [Boyeol Choi(gju06051@gmail.com)]
- Research inspiration: Bit-Plane Compression Transforming Data for Better Compression in Many-Core Architectures (ISCA)
- This project is supported by Korea's Ministry of Trade, Industry & Energy (MOTIE)