Skip to content

Repository files navigation

BioGraph-Edge-Quantizer

Lead Architect: Swapin Vidya
ORCID: 0009-0009-5758-3845
Email: [email protected]

Version Dataset Architecture Optimization

Overview

BioGraph-Edge-Quantizer is a resource-aware Graph Neural Network pipeline designed for:

  • edge-constrained inference
  • biological graph prototyping
  • reproducible performance checks

The system focuses on:

  • reduced model footprint via INT8 weight packing
  • bounded-variance inference profiling
  • deployable execution using TorchScript

Problem Definition

This repository models protein-protein interaction graphs derived from the STRING database.

Task: Prototype node-level inference for biological graph data.

Inputs represented in the retained implementation:

  • core_quantizer/src/quantizer.py builds the retained large GraphSAGE model with 4096 input channels and 2048 hidden channels.
  • core_quantizer/src/benchmark.py currently generates a synthetic 10,000-node graph with 2048-dimensional node features and 10,000 random edges for latency profiling.
  • core_quantizer/src/data_loader.py can generate a small three-edge STRING-format sample file for pipeline checks.

Objective: Enable reliable inference under CPU-only, edge-constrained environments while preserving predictive behavior after compression.

System Architecture

  • core_quantizer/ Python-based GNN pipeline using GraphSAGE and PyTorch Geometric

  • api_gateway/ Laravel-based interface exposing inference through a structured API

Setup & Initialization

1. ML Core (Python)

cd core_quantizer
python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate

pip install pandas torch torch-geometric scikit-learn numpy

python -m src.data_loader --generate-sample
python -m src.quantizer
python -m src.benchmark

2. API Gateway (Laravel)

cd api_gateway
composer install
echo "PYTHON_PATH=$(pwd)/../core_quantizer/venv/Scripts/python.exe" >> .env
php artisan migrate
php artisan serve

Validation Status

Results in this README are limited to evidence retained in this repository. Earlier revisions documented numerical accuracy and edge-device benchmark results whose raw artifacts are not retained here. Those figures are therefore not presented as verified current results. See docs/validation/README.md.

Completed Validation

Area Model / Runtime Metric Result Evidence
Footprint FP32 GraphSAGE state dict File size 64.03 MB core_quantizer/models/heavy_bio_model.pt, validation metadata
Footprint Manually packed INT8 GraphSAGE weights File size 16.02 MB core_quantizer/models/heavy_bio_model_int8packed.pt, validation metadata
Footprint Manual INT8 weight packing Reduction 74.98% vs retained FP32 state dict core_quantizer/src/quantizer.py, validation metadata

The retained INT8 artifact stores model weights as torch.int8 tensors with separate scale tensors while preserving FP32 bias tensors.

Reproducible Local Checks

The repository includes scripts for regenerating sample data, producing model artifacts, and profiling synthetic inference:

cd core_quantizer
python -m src.data_loader --generate-sample
python -m src.quantizer
python -m src.benchmark

core_quantizer/src/benchmark.py currently performs 5 warm-up passes and 10 timed CPU runs with torch.set_num_threads(4) on a synthetic graph. It prints latency statistics to the console; the repository does not retain an exported benchmark report for those latency runs.

Accuracy / Model Validation

No retained accuracy-evaluation artifact was found for the former README claims of 91.8% FP32 accuracy, 90.9% INT8 accuracy, precision, or recall. Those figures have therefore been removed from the verified-results section until an evaluation script and corresponding retained output are added.

Edge Hardware Validation

No retained repository evidence currently substantiates Raspberry Pi, TPU, or Jetson benchmark claims for this BioGraph workload.

Hardware validation should be documented separately by exact device, accelerator, runtime, precision, model artifact, input, metric, and command. Results measured on one device should not be generalized to other ARM or NVIDIA edge platforms.

Key Insight

Quantization does not necessarily improve latency in this pipeline because:

  • graph aggregation can dominate compute
  • high-dimensional feature movement can be memory-bound
  • dequantization or runtime overhead can offset packed-weight savings

Conclusion: The retained evidence primarily supports storage-footprint reduction, not a general latency-speedup claim.

Quantization Strategy

This implementation uses manual INT8 weight packing:

  • Weights converted to int8
  • Scale factors stored separately
  • Dequantization occurs during inference/runtime use

Trade-offs:

  • ~70-75% model size reduction for retained packed weights
  • Dequantization overhead
  • Limited or device-specific latency gain under the current architecture

System Integration

Current pipeline:

Laravel -> subprocess -> Python -> GNN -> Response

Measured Overhead:

  • Earlier README revisions described approximately 10-15 ms per request, but no retained exported measurement artifact was found.

Limitation:

  • Not scalable for high-throughput systems

Future Direction:

  • Replace subprocess with persistent inference service (FastAPI / gRPC)

Clinical Alignment (Experimental)

The system includes structured output compatible with FHIR-style schemas to simulate integration into clinical workflows.

Note: This is a research prototype and not validated for medical use.

Limitations

  • Retained local evidence supports model-footprint reduction, but not the former README accuracy table.
  • No retained exported benchmark report was found for latency measurements; current latency checks print console output from core_quantizer/src/benchmark.py.
  • Historical hardware benchmark provenance is incomplete in this repository.
  • Hardware-specific results should not be generalized across Raspberry Pi, Jetson, or other edge devices.
  • Quantization does not necessarily reduce latency for this pipeline because graph aggregation and feature movement can dominate runtime.
  • TorchScript deployment package size does not necessarily reflect packed-weight compression gains.
  • Subprocess-based execution adds overhead and is not suitable for high-throughput serving without replacing it with a persistent inference service.
  • This is a research prototype and is not clinically, regulatorily, or independently validated.

Intellectual Property

Indian Patent Application: 202541127477

Reproducibility

  • Random seed fixed: 42
  • Execution mode: CPU-only
  • Current benchmark script: 4 Torch threads, 5 warm-up passes, 10 timed runs
  • Retained sample data: three STRING-format edges generated by core_quantizer/src/data_loader.py

Results are device-, runtime-, model-, and configuration-specific. Reproduce benchmark conditions before comparing figures.

Roadmap

  • Add retained accuracy-evaluation script/output for FP32 vs INT8 behavior
  • Add retained edge-hardware benchmark reports with exact device metadata
  • Persistent inference service
  • Sparse GNN optimization
  • ONNX INT8 deployment pipeline

Research Artifact History

This repository preserves a research-stage implementation of the quantization workflow. Subsequent development is outside the scope of this documentation update. Results reported here are limited to validation evidence retained in this repository.

Technical Glossary

Term Description
GraphSAGE Inductive GNN architecture for graph-structured data
STRING Protein interaction dataset format used by the loader
Quantization Converting FP32 weights to lower-precision representations such as INT8
P95 Latency The latency threshold under which 95% of measured runs complete

About

BioGraph-Edge-Quantizer: A framework for INT8 GNN quantization and FHIR-compliant GraphQL APIs. Optimized for on-device clinical intelligence and biological network analysis.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages