Sadjad Alikhani
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,41 +1,37 @@
|
|
1 |
# π‘ **LWM: Large Wireless Model**
|
2 |
|
3 |
-
**[π
|
4 |
|
5 |
-
Welcome to the **LWM** (Large Wireless Model) repository!
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
## π **How to Use for Beginners**
|
10 |
-
|
11 |
-
### 1. **Install Conda or Mamba (via Miniforge)**
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
#### **Option A: Install Conda**
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
- **Miniconda** is a lightweight version that only includes Conda and Python. Download it [here](https://docs.conda.io/en/latest/miniconda.html).
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
|
|
29 |
|
30 |
---
|
31 |
|
32 |
-
### 2. **
|
33 |
-
|
34 |
-
Once you have Conda or Mamba installed, follow these steps to create a new environment and install the necessary packages.
|
35 |
|
36 |
#### **Step 1: Create a new environment**
|
37 |
|
38 |
-
|
39 |
|
40 |
```bash
|
41 |
# If you're using Conda:
|
@@ -47,73 +43,48 @@ mamba create -n lwm_env python=3.12
|
|
47 |
|
48 |
#### **Step 2: Activate the environment**
|
49 |
|
50 |
-
Activate the environment
|
51 |
|
52 |
```bash
|
53 |
-
# For both Conda and Mamba:
|
54 |
conda activate lwm_env
|
55 |
```
|
56 |
|
57 |
---
|
58 |
|
59 |
-
|
60 |
|
61 |
-
Install the necessary packages
|
62 |
|
63 |
```bash
|
64 |
-
#
|
65 |
conda install pytorch torchvision torchaudio -c pytorch
|
66 |
-
pip install -r requirements.txt
|
67 |
|
68 |
-
#
|
69 |
-
mamba install pytorch torchvision torchaudio -c pytorch
|
70 |
pip install -r requirements.txt
|
71 |
```
|
72 |
-
---
|
73 |
|
74 |
-
|
75 |
|
|
|
76 |
```python
|
77 |
-
import
|
|
|
|
|
|
|
78 |
import os
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
os.makedirs(scenarios_path)
|
86 |
-
|
87 |
-
scenario_path = os.path.join(scenarios_path, scenario_name)
|
88 |
-
|
89 |
-
# Initialize sparse checkout for the dataset repository
|
90 |
-
if not os.path.exists(os.path.join(scenarios_path, ".git")):
|
91 |
-
print(f"Initializing sparse checkout in {scenarios_path}...")
|
92 |
-
subprocess.run(["git", "clone", "--sparse", repo_url, "."], cwd=scenarios_path, check=True)
|
93 |
-
subprocess.run(["git", "sparse-checkout", "init", "--cone"], cwd=scenarios_path, check=True)
|
94 |
-
subprocess.run(["git", "lfs", "install"], cwd=scenarios_path, check=True) # Install Git LFS if needed
|
95 |
-
|
96 |
-
# Add the requested scenario folder to sparse checkout
|
97 |
-
print(f"Adding {scenario_name} to sparse checkout...")
|
98 |
-
subprocess.run(["git", "sparse-checkout", "add", scenario_name], cwd=scenarios_path, check=True)
|
99 |
-
|
100 |
-
# Pull large files if needed (using Git LFS)
|
101 |
-
subprocess.run(["git", "lfs", "pull"], cwd=scenarios_path, check=True)
|
102 |
-
|
103 |
-
print(f"Successfully cloned {scenario_name} into {scenarios_path}.")
|
104 |
-
|
105 |
-
# Function to clone multiple dataset scenarios
|
106 |
-
def clone_dataset_scenarios(selected_scenario_names, dataset_repo_url, model_repo_dir):
|
107 |
-
for scenario_name in selected_scenario_names:
|
108 |
-
clone_dataset_scenario(scenario_name, dataset_repo_url, model_repo_dir)
|
109 |
```
|
110 |
|
111 |
---
|
112 |
|
113 |
-
###
|
114 |
|
115 |
```python
|
116 |
-
|
117 |
# Step 1: Clone the model repository (if not already cloned)
|
118 |
model_repo_url = "https://huggingface.co/sadjadalikhani/lwm"
|
119 |
model_repo_dir = "./LWM"
|
@@ -125,9 +96,9 @@ if not os.path.exists(model_repo_dir):
|
|
125 |
|
126 |
---
|
127 |
|
128 |
-
###
|
129 |
|
130 |
-
|
131 |
|
132 |
π **Dataset Overview**
|
133 |
|
@@ -135,61 +106,28 @@ Before proceeding with tokenization and data processing, the **DeepMIMO** datase
|
|
135 |
|----------------|----------------------|------------------------|------------------------------------------------------------------------------------------------------------|
|
136 |
| Dataset 0 | π Denver | 1354 | [DeepMIMO City Scenario 18](https://www.deepmimo.net/scenarios/deepmimo-city-scenario18/) |
|
137 |
| Dataset 1 | ποΈ Indianapolis | 3248 | [DeepMIMO City Scenario 15](https://www.deepmimo.net/scenarios/deepmimo-city-scenario15/) |
|
138 |
-
| Dataset 2 | π Oklahoma | 3455 | [DeepMIMO City Scenario 19](https://www.deepmimo.net/scenarios/deepmimo-city-scenario19/) |
|
139 |
-
| Dataset 3 | π Fort Worth | 1902 | [DeepMIMO City Scenario 12](https://www.deepmimo.net/scenarios/deepmimo-city-scenario12/) |
|
140 |
-
| Dataset 4 | π Santa Clara | 2689 | [DeepMIMO City Scenario 11](https://www.deepmimo.net/scenarios/deepmimo-city-scenario11/) |
|
141 |
-
| Dataset 5 | π
San Diego | 2192 | [DeepMIMO City Scenario 7](https://www.deepmimo.net/scenarios/deepmimo-city-scenario7/) |
|
142 |
-
|
143 |
-
It is important to note that these six datasets were **not** used during the pre-training of the LWM model, and the high-quality embeddings produced are a testament to LWMβs robust generalization capabilities rather than overfitting.
|
144 |
|
145 |
-
The operational settings below were used in generating the datasets for both the pre-training of LWM and the downstream tasks. If you intend to use custom datasets, please ensure they adhere to these configurations:
|
146 |
-
|
147 |
-
#### **Operational Settings**:
|
148 |
-
- **Antennas at BS**: 32
|
149 |
-
- **Antennas at UEs**: 1
|
150 |
-
- **Subcarriers**: 32
|
151 |
-
- **Paths**: 20
|
152 |
-
|
153 |
```python
|
154 |
-
#
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
"city_19_oklahoma",
|
159 |
-
"city_12_fortworth",
|
160 |
-
"city_11_santaclara",
|
161 |
-
"city_7_sandiego"]
|
162 |
-
)
|
163 |
-
scenario_idxs = np.array([3])
|
164 |
-
selected_scenario_names = scenario_names[scenario_idxs]
|
165 |
-
|
166 |
-
# Clone the requested scenario folders (this will clone every time)
|
167 |
-
clone_dataset_scenarios(selected_scenario_names, dataset_repo_url, model_repo_dir)
|
168 |
```
|
169 |
|
170 |
---
|
171 |
|
172 |
-
###
|
173 |
-
```python
|
174 |
-
if os.path.exists(model_repo_dir):
|
175 |
-
os.chdir(model_repo_dir)
|
176 |
-
print(f"Changed working directory to {os.getcwd()}")
|
177 |
-
else:
|
178 |
-
print(f"Directory {model_repo_dir} does not exist. Please check if the repository is cloned properly.")
|
179 |
-
```
|
180 |
|
181 |
-
|
182 |
|
183 |
-
### 6. **Tokenize and Load the Model**
|
184 |
```python
|
185 |
from input_preprocess import tokenizer
|
186 |
from lwm_model import lwm
|
187 |
-
import torch
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
gen_raw=True)
|
192 |
|
|
|
193 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
194 |
print(f"Loading the LWM model on {device}...")
|
195 |
model = lwm.from_pretrained(device=device)
|
@@ -198,13 +136,28 @@ model = lwm.from_pretrained(device=device)
|
|
198 |
---
|
199 |
|
200 |
### 7. **Perform Inference**
|
|
|
|
|
|
|
201 |
```python
|
202 |
from inference import lwm_inference, create_raw_dataset
|
|
|
203 |
input_types = ['cls_emb', 'channel_emb', 'raw']
|
204 |
-
selected_input_type =
|
|
|
205 |
if selected_input_type in ['cls_emb', 'channel_emb']:
|
206 |
dataset = lwm_inference(preprocessed_chs, selected_input_type, model, device)
|
207 |
else:
|
208 |
dataset = create_raw_dataset(preprocessed_chs, device)
|
|
|
209 |
|
210 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# π‘ **LWM: Large Wireless Model**
|
2 |
|
3 |
+
**[π Try the Interactive Demo on Hugging Face!](https://huggingface.co/spaces/sadjadalikhani/LWM-Interactive-Demo)**
|
4 |
|
5 |
+
Welcome to the **LWM** (Large Wireless Model) repository! LWM is a powerful pre-trained model designed to extract rich and high-quality features from wireless communication datasets, such as the **DeepMIMO** dataset. This model leverages advanced neural architectures to efficiently handle wireless channel data, making it applicable in a wide range of tasks like channel prediction, classification, and beamforming.
|
6 |
|
7 |
+
LWM was built with robust generalization capabilities, ensuring it performs well even on datasets it hasnβt seen before, making it an ideal tool for both research and real-world applications in wireless communications. Read on to learn how to set up, run, and explore the features of LWM.
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
---
|
|
|
|
|
10 |
|
11 |
+
## β¨ **Key Features**
|
12 |
+
- **Wireless Channel Embeddings:** LWM is trained to extract meaningful embeddings from wireless channel data, capturing complex features that can be used in various downstream tasks.
|
13 |
+
- **Flexible Input:** Whether you're working with raw channel data or compressed embeddings, LWM supports different data formats, offering versatility in wireless data processing.
|
14 |
+
- **Efficient Inference:** LWM's architecture is optimized for quick and scalable inference, providing fast results even on large datasets.
|
15 |
+
- **Generalization Power:** Tested on several unseen datasets, LWM maintains high-quality performance without overfitting, proving its effectiveness in diverse environments.
|
16 |
|
17 |
+
---
|
|
|
18 |
|
19 |
+
## π **How to Use**
|
20 |
|
21 |
+
### 1. **Install Conda or Mamba**
|
22 |
|
23 |
+
To begin, install **Conda** or **Mamba** for managing Python environments and packages.
|
24 |
|
25 |
+
- **Conda:** Download and install [Miniconda](https://docs.conda.io/en/latest/miniconda.html) for a lightweight environment.
|
26 |
+
- **Mamba (via Miniforge):** [Miniforge](https://github.com/conda-forge/miniforge/releases/latest) is a faster alternative to Conda, with **Mamba** pre-installed for quicker package installations.
|
27 |
|
28 |
---
|
29 |
|
30 |
+
### 2. **Set Up Your Environment**
|
|
|
|
|
31 |
|
32 |
#### **Step 1: Create a new environment**
|
33 |
|
34 |
+
Create a new Python environment named `lwm_env` (or any name you prefer).
|
35 |
|
36 |
```bash
|
37 |
# If you're using Conda:
|
|
|
43 |
|
44 |
#### **Step 2: Activate the environment**
|
45 |
|
46 |
+
Activate the new environment:
|
47 |
|
48 |
```bash
|
|
|
49 |
conda activate lwm_env
|
50 |
```
|
51 |
|
52 |
---
|
53 |
|
54 |
+
### 3. **Install Required Packages**
|
55 |
|
56 |
+
Install the necessary Python packages for LWM.
|
57 |
|
58 |
```bash
|
59 |
+
# Using Conda or Mamba to install PyTorch
|
60 |
conda install pytorch torchvision torchaudio -c pytorch
|
|
|
61 |
|
62 |
+
# Install additional dependencies with pip
|
|
|
63 |
pip install -r requirements.txt
|
64 |
```
|
|
|
65 |
|
66 |
+
> **Note**: If `requirements.txt` includes all necessary dependencies, you can install everything in one go by running `pip install -r requirements.txt`.
|
67 |
|
68 |
+
**Main package requirements include:**
|
69 |
```python
|
70 |
+
import torch
|
71 |
+
import numpy as np
|
72 |
+
import pandas as pd
|
73 |
+
import DeepMIMOv3
|
74 |
import os
|
75 |
+
import pickle
|
76 |
+
import shutil
|
77 |
+
import warnings
|
78 |
+
from tqdm import tqdm
|
79 |
+
from datetime import datetime
|
80 |
+
from torch.utils.data import Dataset, DataLoader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
```
|
82 |
|
83 |
---
|
84 |
|
85 |
+
### 4. **Clone the Model Repository**
|
86 |
|
87 |
```python
|
|
|
88 |
# Step 1: Clone the model repository (if not already cloned)
|
89 |
model_repo_url = "https://huggingface.co/sadjadalikhani/lwm"
|
90 |
model_repo_dir = "./LWM"
|
|
|
96 |
|
97 |
---
|
98 |
|
99 |
+
### 5. **Clone the Desired Datasets**
|
100 |
|
101 |
+
LWM is designed to process datasets from various environments, such as the **DeepMIMO** dataset. Before running inference, ensure the datasets are cloned into your local environment. Below is an overview of some of the available datasets and their respective links:
|
102 |
|
103 |
π **Dataset Overview**
|
104 |
|
|
|
106 |
|----------------|----------------------|------------------------|------------------------------------------------------------------------------------------------------------|
|
107 |
| Dataset 0 | π Denver | 1354 | [DeepMIMO City Scenario 18](https://www.deepmimo.net/scenarios/deepmimo-city-scenario18/) |
|
108 |
| Dataset 1 | ποΈ Indianapolis | 3248 | [DeepMIMO City Scenario 15](https://www.deepmimo.net/scenarios/deepmimo-city-scenario15/) |
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
```python
|
111 |
+
# Function to clone specific dataset scenario
|
112 |
+
def clone_dataset_scenario(scenario_name, repo_url, model_repo_dir="./LWM", scenarios_dir="scenarios"):
|
113 |
+
# Logic for cloning datasets
|
114 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
```
|
116 |
|
117 |
---
|
118 |
|
119 |
+
### 6. **Tokenize and Load the Model**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
Once you have cloned the model and the datasets, you can preprocess the data and load the model.
|
122 |
|
|
|
123 |
```python
|
124 |
from input_preprocess import tokenizer
|
125 |
from lwm_model import lwm
|
|
|
126 |
|
127 |
+
# Tokenizing the dataset
|
128 |
+
preprocessed_chs = tokenizer(selected_scenario_names=["city_18_denver"], manual_data=None, gen_raw=True)
|
|
|
129 |
|
130 |
+
# Load LWM model
|
131 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
132 |
print(f"Loading the LWM model on {device}...")
|
133 |
model = lwm.from_pretrained(device=device)
|
|
|
136 |
---
|
137 |
|
138 |
### 7. **Perform Inference**
|
139 |
+
|
140 |
+
After tokenizing the data and loading the model, you're ready to perform inference with LWM.
|
141 |
+
|
142 |
```python
|
143 |
from inference import lwm_inference, create_raw_dataset
|
144 |
+
|
145 |
input_types = ['cls_emb', 'channel_emb', 'raw']
|
146 |
+
selected_input_type = 'cls_emb' # Choose the type of input
|
147 |
+
|
148 |
if selected_input_type in ['cls_emb', 'channel_emb']:
|
149 |
dataset = lwm_inference(preprocessed_chs, selected_input_type, model, device)
|
150 |
else:
|
151 |
dataset = create_raw_dataset(preprocessed_chs, device)
|
152 |
+
```
|
153 |
|
154 |
---
|
155 |
+
|
156 |
+
### LWM Architecture and Usage in Wireless Tasks
|
157 |
+
|
158 |
+
**LWM** employs a robust neural network architecture to extract valuable features from wireless channel data. Its deep layers, combined with advanced tokenization, make it suitable for challenging wireless communication tasks, such as beamforming, interference management, and channel state prediction.
|
159 |
+
|
160 |
+
LWM is particularly effective in generalizing across diverse environments without overfitting, and its results are consistent across raw channel data and embeddings.
|
161 |
+
|
162 |
+
By using **LWM**, you can enhance your wireless communication systems by utilizing data-driven models that outperform traditional approaches, offering faster and more accurate results.
|
163 |
+
|