Skip to content

Commit a67b4b1

Browse files
committed
Updated LocalLab v0.3.2 and Updated Docs
1 parent c99feee commit a67b4b1

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

CHANGELOG.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to LocalLab will be documented in this file.
44

5-
## [0.3.1] - 2025-03-06
5+
## [0.3.1] - 2025-03-03
66

77
### Fixed
88

@@ -18,7 +18,7 @@ All notable changes to LocalLab will be documented in this file.
1818
- Improved error messages for configuration issues
1919
- Updated environment variable documentation with more details
2020

21-
## [0.3.0] - 2025-03-05
21+
## [0.3.0] - 2025-03-03
2222

2323
### Added
2424

@@ -45,7 +45,7 @@ All notable changes to LocalLab will be documented in this file.
4545
- Added detailed memory usage logging before and after model operations
4646
- Optimized memory usage by cleaning GPU cache more aggressively
4747

48-
## [0.2.9] - 2025-03-04
48+
## [0.2.9] - 2025-03-02
4949

5050
### Added
5151

@@ -58,7 +58,7 @@ All notable changes to LocalLab will be documented in this file.
5858
- Redesigned modern ASCII art banners for a more aesthetic interface
5959
- Improved UI with cleaner banner separations and better readability
6060

61-
## [0.2.8] - 2025-03-03
61+
## [0.2.8] - 2025-03-02
6262

6363
### Fixed
6464

@@ -125,3 +125,14 @@ All notable changes to LocalLab will be documented in this file.
125125
### Added
126126

127127
- Added new `
128+
129+
## [0.3.2] - 2025-03-07
130+
131+
### Added
132+
133+
- Integrated MIN_FREE_MEMORY environment variable for better memory management.
134+
- Updated documentation to include MIN_FREE_MEMORY in environment variable settings.
135+
136+
### Improved
137+
138+
- Updated memory checks in the server to utilize MIN_FREE_MEMORY for consistency.

docs/guides/environment_variables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,5 @@ For boolean environment variables, the following values are recognized:
166166
- [Performance Guide](../features/performance.md)
167167
- [Memory Monitoring](../features/memory.md)
168168
- [Google Colab Guide](../colab/README.md)
169+
170+
Make sure to set this variable to ensure optimal performance for LocalLab.

docs/guides/getting-started.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ This guide will help you start using LocalLab, whether you're running it locally
77
### Local Setup
88

99
1. **Install LocalLab**
10+
1011
```bash
1112
pip install locallab
1213
```
1314

1415
2. **Start the Server**
16+
1517
```python
1618
from locallab import start_server
1719
start_server()
@@ -26,17 +28,20 @@ This guide will help you start using LocalLab, whether you're running it locally
2628
### Google Colab Setup
2729

2830
1. **Install LocalLab**
31+
2932
```python
3033
!pip install locallab
3134
```
3235

3336
2. **Set Up Ngrok**
37+
3438
```python
3539
import os
3640
os.environ["NGROK_AUTH_TOKEN"] = "your_token_here"
3741
```
3842

3943
3. **Start Server**
44+
4045
```python
4146
from locallab import start_server
4247
start_server(ngrok=True) # Will show public URL in logs
@@ -51,6 +56,7 @@ This guide will help you start using LocalLab, whether you're running it locally
5156
## First Steps
5257

5358
### 1. Generate Text
59+
5460
```python
5561
# Simple text generation
5662
response = await client.generate(
@@ -61,6 +67,7 @@ print(response)
6167
```
6268

6369
### 2. Chat with AI
70+
6471
```python
6572
# Chat completion
6673
response = await client.chat([
@@ -71,6 +78,7 @@ print(response.choices[0].message.content)
7178
```
7279

7380
### 3. Process Multiple Prompts
81+
7482
```python
7583
# Batch processing
7684
responses = await client.batch_generate([

locallab/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from huggingface_hub import model_info, HfApi
88
from pathlib import Path
99
from dataclasses import dataclass
10+
from ..logger import get_logger
11+
12+
# Get the logger instance
13+
logger = get_logger("locallab.config")
1014

1115
def get_env_var(key: str, *, default: Any = None, var_type: Type = str) -> Any:
1216
"""Get environment variable with type conversion and validation.
@@ -45,6 +49,8 @@ def get_env_var(key: str, *, default: Any = None, var_type: Type = str) -> Any:
4549
DEFAULT_MAX_LENGTH = get_env_var("DEFAULT_MAX_LENGTH", default=2048, var_type=int)
4650
DEFAULT_TEMPERATURE = get_env_var("DEFAULT_TEMPERATURE", default=0.7, var_type=float)
4751
DEFAULT_TOP_P = get_env_var("DEFAULT_TOP_P", default=0.9, var_type=float)
52+
DEFAULT_TOP_K = 50 # Default value for top_k parameter
53+
DEFAULT_REPETITION_PENALTY = 1.0 # Default value for repetition penalty
4854

4955
# Optimization settings
5056
ENABLE_QUANTIZATION = get_env_var("LOCALLAB_ENABLE_QUANTIZATION", default=True, var_type=bool)
@@ -350,3 +356,5 @@ def get_model_info(model_id: str, fallback: Optional[str] = None) -> Optional[Di
350356
return MODEL_REGISTRY[fallback]
351357

352358
return None
359+
360+
MIN_FREE_MEMORY = 2000 # Minimum free memory in MB

locallab/core/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from fastapi.middleware.gzip import GZipMiddleware
1414
from contextlib import contextmanager
1515
from colorama import Fore, Style
16-
import threading
17-
import psutil
1816
from ..logger import get_logger
1917
from ..logger.logger import log_request, log_model_loaded, log_model_unloaded, get_request_count, SERVER_START_TIME
2018
from ..model_manager import ModelManager

locallab/routes/system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import torch
1111
import platform
1212
from datetime import datetime
13+
import gc
1314

1415
from ..logger import get_logger
1516
from ..logger.logger import get_request_count, get_uptime_seconds

locallab/server.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@
2929
from .logger.logger import set_server_status, log_request
3030
from .utils.system import get_gpu_memory
3131
from .config import (
32-
DEFAULT_MODEL,
33-
system_instructions,
34-
ENABLE_QUANTIZATION,
35-
QUANTIZATION_TYPE,
36-
ENABLE_ATTENTION_SLICING,
37-
ENABLE_BETTERTRANSFORMER,
38-
ENABLE_FLASH_ATTENTION,
39-
HOST,
40-
PORT
32+
MIN_FREE_MEMORY
4133
)
4234

4335
# Import torch - handle import error gracefully
@@ -135,7 +127,7 @@ def check_environment() -> List[Tuple[str, str, bool]]:
135127
total_gb = memory.total / (1024 * 1024 * 1024)
136128
available_gb = memory.available / (1024 * 1024 * 1024)
137129

138-
if available_gb < 2.0: # Less than 2GB available
130+
if available_gb < MIN_FREE_MEMORY / 1024: # Convert MB to GB
139131
issues.append((
140132
f"Low system memory: Only {available_gb:.1f}GB available",
141133
"Models may require 2-8GB of system memory. Consider closing other applications",

0 commit comments

Comments
 (0)