GSOC2023ns3-ai: Difference between revisions
No edit summary |
No edit summary |
||
Line 88: | Line 88: | ||
# (Update on June 3) {{strike|Make "pip install . --user" a target in Cmake, so that users can install Python modules more easily, like "./ns3 build ns3ai_interfaces".}} | # (Update on June 3) {{strike|Make "pip install . --user" a target in Cmake, so that users can install Python modules more easily, like "./ns3 build ns3ai_interfaces".}} | ||
# If I have time, I will test my code on Linux. | # If I have time, I will test my code on Linux. | ||
== Week 2 (June 5 - June 11) == | |||
=== Achievements === | |||
# Updated the [https://github.com/ShenMuyuan/ns3-ai/tree/improvements/examples/rate-control Thompson Sampling example] to use the new interface. Previously, it uses simple packed structure for information sharing. Now it uses the first element of shared std::vector (which is basically the same structure as before). | |||
# Measured running time of the Thompson Sampling example, old interface vs new interface. Results: old about 5 seconds, new about 12 minutes. | |||
=== Problems === | |||
# The benchmarking result above shows that, in terms of passing small amount of data in each interaction, the new interface is 150 times slower than the old interface. | |||
=== Todo next week === | |||
# Measure running time of another example (the new multi-bss example) which passes large amount of data in each interaction, to check whether the new interface improves performance in that case. If the new outperforms the old, then the old and new interface can coexist for different cases. Else, I will consider modifying the implementation. | |||
# Or, try to optimize the code to make small data interaction faster. |
Revision as of 13:42, 12 June 2023
Main Page - Roadmap - Summer Projects - Project Ideas - Developer FAQ - Tools - Related Projects
HOWTOs - Installation - Troubleshooting - User FAQ - Samples - Models - Education - Contributed Code - Papers
Back to GSoC 2023 projects
Project Overview
- Project Name: ns3-ai enhancements
- Student: Muyuan Shen
- Mentors: Collin Brady and Hao Yin
- Google page: https://summerofcode.withgoogle.com/programs/2023/projects/A4KZ7dxo
Project Goals
The proposed project aims to enhance the ns3-ai module, which provides interfaces between ns-3 and Python-based ML frameworks using shared memory, with a focus on performance optimization and expanding the range of supported data structures. To achieve this, the project will introduce APIs for additional data structures like vector and string in shared memory IPC to reduce the interaction between C++ and Python. Additionally, the project will provide examples demonstrating how to implement ML algorithms within ns-3 using C++ and open-source frameworks such as TensorFlow and PyTorch. The project will also improve the current examples and documentation and integrate new examples, such as LTE handover. Overall, the project aims to expand and accelerate the capabilities of the ns3-ai module, enabling users to simulate and analyze large-scale networks with greater efficiency and flexibility.
Repository
https://github.com/ShenMuyuan/ns3-ai/tree/improvements
About Me
Education
As a junior at Huazhong University of Science and Technology, I am majoring in electronic engineering. I am proud to be a member of the Undergraduate Program for Advanced Project-based Information Science Education, also known as the Seed Class, and currently serve as the class monitor. Additionally, I am a project leader in the Dian group, where I engage in extracurricular technical projects. In terms of relevant coursework, I have excelled in network programming through courses such as C programming language and computer network, both of which I achieved a perfect grade point of 4.0. These courses have equipped me with a strong foundation in network programming, which I believe will enable me to contribute effectively to relevant projects. I am a motivated and skilled undergraduate student with a passion for network programming and a track record of academic excellence.
Experience with ns-3
During my academic journey, I have had the opportunity to explore computer networking through labs and projects. In particular, in the labs for the computer networking course, I gained valuable insights into how different parameters, such as the number of STAs, CW range, and packet arrival rate, can impact network throughput in the WiFi DCF protocol. In addition, I have worked on a project that leverages ns-3 as a simulation platform with Prof. Yayu Gao. Through this project, I have gained practical experience in simulating WiFi MAC rate control algorithms, which has further solidified my understanding of the ns-3's usage and its object-oriented programming approach. Overall, my hands-on experience in both labs and projects has allowed me to apply theoretical concepts to practical scenarios and enhanced my network simulation and analysis skills.
Milestones
Based on my proposal, I divide my project into two phases, listed below.
Phase one (before midterm evaluation)
Enhancements for the interface
std::vector support
Introduce APIs for storing data structures like std::vector in shared memory, to reduce the interaction between C++ and Python.
gym-like interface
Introduce a gym-like interface to enable users to train RL models directly in ns-3 with OpenAI Gym.
Enhancements for existing examples
Make all previous examples up to date with the Cmake building system introduced in ns3.36, also provide a new example to benchmark the running time of vectors.
Phase two (after midterm evaluation)
Integration of ns-3 and C++-based ML frameworks
TODO
Finishing new examples and benchmarking test
TODO
Weekly Report
Week 1 (May 29 - June 4)
Achievements
- Got familiar with the usage of Boost library, and the syntax of Cython pyx files. I am using Boost to support dynamic allocation and synchronization in shared memory and Cython to wrap C++ code for Python.
- Created the interface to support std::vector in shared memory. Also wrote a new a-plus-b example to demonstrate the usage. It is still in development and currently supports macOS.
- (Update on June 3) Now I am using pybind11 instead of Cython for Python binding, because pybind11 has similar performance but cleaner code. And also it is easier to use cmake to install the python module.
Problems
- The code is quite naive and possibly includes some extra interactions that lowers performance.
- I have not tested the new interface on Linux.
- (Update on June 3)
The new interface has hardcoded parts in the setup.py. Users need to explicitly specify their Boost library include and library paths. - (Update on June 3)
Although I have only one example currently, if there is more, users need to repeatedly call the setup.py to install modules which lacks efficiency.
Todo next week
- Use the new interface in an existing example such as rl-tcp, compare running time with old interface, to know its performance better.
- Switch to a new branch called "improvements" instead of "cmake", which better shows the project goal.
- (Update on June 3)
Modify CMakeLists.txt to pass the result of find_package(Boost...) to setup.py, and remove the hardcoded part. - (Update on June 3)
Make "pip install . --user" a target in Cmake, so that users can install Python modules more easily, like "./ns3 build ns3ai_interfaces". - If I have time, I will test my code on Linux.
Week 2 (June 5 - June 11)
Achievements
- Updated the Thompson Sampling example to use the new interface. Previously, it uses simple packed structure for information sharing. Now it uses the first element of shared std::vector (which is basically the same structure as before).
- Measured running time of the Thompson Sampling example, old interface vs new interface. Results: old about 5 seconds, new about 12 minutes.
Problems
- The benchmarking result above shows that, in terms of passing small amount of data in each interaction, the new interface is 150 times slower than the old interface.
Todo next week
- Measure running time of another example (the new multi-bss example) which passes large amount of data in each interaction, to check whether the new interface improves performance in that case. If the new outperforms the old, then the old and new interface can coexist for different cases. Else, I will consider modifying the implementation.
- Or, try to optimize the code to make small data interaction faster.