Divide, Harmonize, Then Conquer It: Shooting Multi-Commodity Flow Problems with Multimodal Language Models
Official PyTorch Implementation
๐ Pram is a multimodal language model (MLM)-powered framework for solving multi-commodity flow (MCF) problems, accepted by
ICLR '26. By leveraging the mathematical reasoning ability of MLMs, Pram achieves near-optimal flow allocations while outperforming production-grade LP solvers by several orders of magnitude in speed.
As shown in Figure 1, Pram consists of the following three main parts (from left to right). (i) ๐งฉ Divider: Complex problems are often intractable as a whole but can be decomposed into subproblems defined over subsets of commodities and links. (ii) ๐ง Solver: We propose to fine-ture MLMs (e.g., Qwen2.5-VL) for solving these subproblems in parallel, exploiting their mathematical reasoning capacity to yield high-quality allocations. (iii) โจ Harmonizer: We adopt multi-agent reinforcement learning (MARL) algorithms, i.e., counterfactual reasoning, to learn coordinated policies.
Figure 1: Overview of Our Proposal, Pram.
./Pram-master
โโโ ๐ baselines # Baseline methods for comparison
โโโ ๐ data # Dataset construction and loading
โ โโโ ๐ demand # Demand matrices
โ โโโ ๐ topology # Network topologies
โ โโโ ๐ build_dataloader.py # Build PyTorch dataloaders
โ โโโ ๐ dataset.py # Dataset and preprocessing logic
โโโ ๐ env # Experimental environment
โ โโโ ๐ logger.py # Logging utilities
โ โโโ ๐ marl_env.py # Reinforcement learning environment
โ โโโ ๐ objective.py # Objectives (e.g., MLU, total flow)
โโโ ๐ mlms # Pretrained MLM weights
โโโ ๐ pram # Core implementation of Pram
โ โโโ ๐ modules # Neural network modules
โ โโโ ๐ divider.py # Commodity partitioning and plotting logic
โ โโโ ๐ solver.py # Problem solver for training / evaluation
โ โโโ ๐ model_qwen.py # Qwen-VL-based backbone model
โ โโโ ๐ prompt.py # Prompt templates and construction logic
โ โโโ ...
โโโ ๐ scripts # Scripts (.sh)
โโโ ๐ utils # Useful functions
โโโ ๐ ds_config_zero2.json # DeepSpeed configuration file
โโโ ๐ main.py # Main entry point
- Run
pip install -r requirements.txtto install all Python dependencies. - ๐ Miniconda or Anaconda is required.
- ๐ Acquire a Gurobi license from Gurobi and activate it with
grbgetkey [gurobi-license]
For reproducibility, all topologies and demand matrices used in our experiments are included in the supplementary material of our OpenReview submission. For convenience, we also host the same data on Google Drive. After downloading the archive, please unzip it and place the files into the corresponding directories: topology for topology files and and demand for demand matrices.
๐ Note: Real-world network topologies are provided in JSON format and are accompanied by their corresponding traffic demand matrices. In contrast, large-scale topologies from Topology Zoo are represented in GraphML format and do not include predefined demand matrices; therefore, their traffic demands are synthetically generated following the procedures implemented in our codebase
We adopt several open-source instruction-tuned visionโlanguage models from ModelScope as the backbone reasoning engines in our framework. You can download them with the following commands:
# ๐ฆ Qwen2.5-VL-7B-Instruct
modelscope download --model qwen/Qwen2.5-VL-7B-Instruct --local_dir ./mlms/Qwen2.5-VL-7B-Instruct
# ๐ผ Qwen2.5-VL-3B-Instruct
modelscope download --model qwen/Qwen2.5-VL-3B-Instruct --local_dir ./mlms/Qwen2.5-VL-3B-Instruct
# ๐ฆ Llama-3.2-11B-Vision-Instruct
modelscope download --model llama/Llama-3.2-11B-Vision-Instruct --local_dir ./mlms/Llama-3.2-11B-Vision-InstructOr load directly in Python:
from modelscope import snapshot_download
# Example: Qwen2.5-VL-7B-Instruct
model_dir = snapshot_download("./mlms/Qwen2.5-VL-7B-Instruct")Run the provided script to evaluate Pram on the GรANT topology:
(base) $ conda activate myenv
(myenv) $ cd Pram-master
(myenv) $ bash scripts/test.shThe script will automatically load the corresponding topology and demand matrices, and then execute Pram with default settings. Logs and results will be saved in the ./log directory by default. To evaluate Pram on other topologies, please modify the config and rerun the script.
- ๐ง Linux OS (tested on Ubuntu)
- ๐งฎ CPU instance with multiple cores
- ๐ป GPU instances with sufficient memory and CUDA installed
We provide implementations of multiple baseline methods, i.e., LP, POP, LP-top, HARP, Ather, and PPO, used in our experimental evaluation.
โก See the baselines directory for more details on usage and setup. For example, to run the linear programming, you can run the following command:
(base) $ conda activate myenv
(myenv) $ python -m baselines.LP.runThis repository is released under the MIT License. See the LICENSE file for details.
Please consider citing our papers if you think the codebase is helpful to your research.
@inproceedings{yuan2026divide,
title={Divide, Harmonize, Then Conquer It: Shooting Multi-Commodity Flow Problems with Multimodal Language Models},
author={Xinyu Yuan and Yan Qiao and Zonghui Wang and Wenzhi Chen},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=kL9nYFvs6O}
}
@article{yuan2026putting,
title={LMTE: Putting the ``Reasoning'' into WAN Traffic Engineering with Language Models},
author={Yuan, Xinyu and Qiao, Yan and Wang, Zonghui and Li, Meng and Chen, Wenzhi},
journal={arXiv preprint arXiv:2602.00941},
year={2026}
}We acknowledge the open-source community for providing the foundational tools and libraries that this work relies on. Their contributions were instrumental in enabling the implementation and evaluation of Pram. Here we list them as follows:
- NCFlow - https://github.com/netcontract/ncflow - License
- POP - https://github.com/stanford-futuredata/POP - License
- Traffic-Matrix-Prediction - https://github.com/THU-INSC-NAD/Traffic-Matrix-Prediction - License
- DOTE - https://github.com/PredWanTE/DOTE - License
- Teal - https://github.com/harvard-cns/teal - License
- FIGRET - https://github.com/FIGRET/figret - License
If you have any questions or comments, please feel free to contact Xinyu Yuan (yxy5315@gmail.com) or open an issue on this repository.
-
Why are some sub-topologies displayed in a blurred or cluttered manner ?
We partition the original topology into multiple smaller subgraphs for visualization. However, the current plotting parameters are tuned for topologies with a relatively small number of nodes. When applied to larger-scale topologies, the visualization may appear blurred or cluttered. In such cases, the plotting parameters (e.g., layout scale, node size, and figure resolution) should be adjusted accordingly based on the topology size. -
Does this repository include implementations for Llama-based models and post-tuning ?
his repository primarily focuses on the core operations and workflow of Pram based on Qwen models. Implementations related to Llama-based models and post-tuning procedures are not the main focus of this codebase. That said, we highlight important considerations and implementation notes inmodel_llama.py. In addition, the post-tuning components can be found in the following external repositories, which we reference for completeness. 1๏ธโฃ Running gradient descent with ADMM - 2๏ธโฃ Recurrent adjustment with RNNs - 3๏ธโฃ LP-based partial solution refinement. -
To be continued ...
