b10-transfer 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- b10_transfer-0.1.2/PKG-INFO +127 -0
- b10_transfer-0.1.2/README.md +97 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/pyproject.toml +3 -3
- b10_transfer-0.1.2/src/b10_transfer/__init__.py +23 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/cleanup.py +1 -1
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/constants.py +2 -23
- b10_transfer-0.1.2/src/b10_transfer/core.py +394 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/space_monitor.py +1 -14
- b10_transfer-0.1.0/PKG-INFO +0 -219
- b10_transfer-0.1.0/README.md +0 -189
- b10_transfer-0.1.0/src/b10_transfer/__init__.py +0 -51
- b10_transfer-0.1.0/src/b10_transfer/async_torch_cache.py +0 -62
- b10_transfer-0.1.0/src/b10_transfer/async_transfers.py +0 -283
- b10_transfer-0.1.0/src/b10_transfer/core.py +0 -169
- b10_transfer-0.1.0/src/b10_transfer/torch_cache.py +0 -388
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/archive.py +0 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/environment.py +0 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/info.py +0 -0
- {b10_transfer-0.1.0 → b10_transfer-0.1.2}/src/b10_transfer/utils.py +0 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: b10-transfer
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: Distributed PyTorch file transfer for Baseten - Environment-aware, lock-free file transfer management
|
5
|
+
License: MIT
|
6
|
+
Keywords: pytorch,file-transfer,cache,machine-learning,inference
|
7
|
+
Author: Shounak Ray
|
8
|
+
Author-email: shounak.noreply@baseten.co
|
9
|
+
Maintainer: Fred Liu
|
10
|
+
Maintainer-email: fred.liu.noreply@baseten.co
|
11
|
+
Requires-Python: >=3.9,<4.0
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Requires-Dist: torch (>=2.0.0)
|
24
|
+
Requires-Dist: triton (>=2.0.0)
|
25
|
+
Project-URL: Documentation, https://docs.baseten.co/development/model/b10-transfer
|
26
|
+
Project-URL: Homepage, https://docs.baseten.co/development/model/b10-transfer
|
27
|
+
Project-URL: Repository, https://pypi.org/project/b10-transfer/
|
28
|
+
Description-Content-Type: text/markdown
|
29
|
+
|
30
|
+
https://www.notion.so/ml-infra/mega-base-cache-24291d247273805b8e20fe26677b7b0f
|
31
|
+
|
32
|
+
# B10 Transfer
|
33
|
+
|
34
|
+
PyTorch file transfer for Baseten deployments.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
```python
|
39
|
+
import b10_transfer
|
40
|
+
|
41
|
+
# Inside model.load() function
|
42
|
+
def load()
|
43
|
+
# Load cache before torch.compile()
|
44
|
+
cache_loaded = b10_transfer.load_compile_cache()
|
45
|
+
|
46
|
+
# ...
|
47
|
+
|
48
|
+
# Your model compilation
|
49
|
+
model = torch.compile(model)
|
50
|
+
# Warm up the model with dummy prompts, and arguments that would be typically used in your requests (e.g resolutions)
|
51
|
+
dummy_input = "What is the capital of France?"
|
52
|
+
model(dummy_input)
|
53
|
+
|
54
|
+
# ...
|
55
|
+
|
56
|
+
# Save cache after compilation
|
57
|
+
if not cache_loaded:
|
58
|
+
b10_transfer.save_compile_cache()
|
59
|
+
```
|
60
|
+
|
61
|
+
## Configuration
|
62
|
+
|
63
|
+
Configure via environment variables:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
# Cache directories
|
67
|
+
export TORCH_CACHE_DIR="/tmp/torchinductor_root" # Default
|
68
|
+
export B10FS_CACHE_DIR="/cache/model/compile_cache" # Default
|
69
|
+
export LOCAL_WORK_DIR="/app" # Default
|
70
|
+
|
71
|
+
# Cache limits
|
72
|
+
export MAX_CACHE_SIZE_MB="1024" # 1GB default
|
73
|
+
```
|
74
|
+
|
75
|
+
## How It Works
|
76
|
+
|
77
|
+
### Environment-Specific Caching
|
78
|
+
|
79
|
+
The library automatically creates unique cache keys based on your environment:
|
80
|
+
|
81
|
+
```
|
82
|
+
torch-2.1.0_cuda-12.1_cc-8.6_triton-2.1.0 → cache_a1b2c3d4e5f6.latest.tar.gz
|
83
|
+
torch-2.0.1_cuda-11.8_cc-7.5_triton-2.0.1 → cache_x9y8z7w6v5u4.latest.tar.gz
|
84
|
+
torch-2.1.0_cpu_triton-none → cache_m1n2o3p4q5r6.latest.tar.gz
|
85
|
+
```
|
86
|
+
|
87
|
+
**Components used:**
|
88
|
+
- **PyTorch version** (e.g., `torch-2.1.0`)
|
89
|
+
- **CUDA version** (e.g., `cuda-12.1` or `cpu`)
|
90
|
+
- **GPU compute capability** (e.g., `cc-8.6` for A100)
|
91
|
+
- **Triton version** (e.g., `triton-2.1.0` or `triton-none`)
|
92
|
+
|
93
|
+
### Cache Workflow
|
94
|
+
|
95
|
+
1. **Load Phase** (startup): Generate environment key, check for matching cache in B10FS, extract to local directory
|
96
|
+
2. **Save Phase** (after compilation): Create archive, atomic copy to B10FS with environment-specific filename
|
97
|
+
|
98
|
+
### Lock-Free Race Prevention
|
99
|
+
|
100
|
+
Uses journal pattern with atomic filesystem operations for parallel-safe cache saves.
|
101
|
+
|
102
|
+
## API Reference
|
103
|
+
|
104
|
+
### Functions
|
105
|
+
|
106
|
+
- `load_compile_cache() -> bool`: Load cache from B10FS for current environment
|
107
|
+
- `save_compile_cache() -> bool`: Save cache to B10FS with environment-specific filename
|
108
|
+
- `clear_local_cache() -> bool`: Clear local cache directory
|
109
|
+
- `get_cache_info() -> Dict[str, Any]`: Get cache status information for current environment
|
110
|
+
- `list_available_caches() -> Dict[str, Any]`: List all cache files with environment details
|
111
|
+
|
112
|
+
### Exceptions
|
113
|
+
|
114
|
+
- `CacheError`: Base exception for cache operations
|
115
|
+
- `CacheValidationError`: Path validation or compatibility check failed
|
116
|
+
|
117
|
+
## Performance Impact
|
118
|
+
|
119
|
+
### Debugging
|
120
|
+
|
121
|
+
Enable debug logging:
|
122
|
+
|
123
|
+
```python
|
124
|
+
import logging
|
125
|
+
logging.getLogger('b10_transfer').setLevel(logging.DEBUG)
|
126
|
+
```
|
127
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
https://www.notion.so/ml-infra/mega-base-cache-24291d247273805b8e20fe26677b7b0f
|
2
|
+
|
3
|
+
# B10 Transfer
|
4
|
+
|
5
|
+
PyTorch file transfer for Baseten deployments.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```python
|
10
|
+
import b10_transfer
|
11
|
+
|
12
|
+
# Inside model.load() function
|
13
|
+
def load()
|
14
|
+
# Load cache before torch.compile()
|
15
|
+
cache_loaded = b10_transfer.load_compile_cache()
|
16
|
+
|
17
|
+
# ...
|
18
|
+
|
19
|
+
# Your model compilation
|
20
|
+
model = torch.compile(model)
|
21
|
+
# Warm up the model with dummy prompts, and arguments that would be typically used in your requests (e.g resolutions)
|
22
|
+
dummy_input = "What is the capital of France?"
|
23
|
+
model(dummy_input)
|
24
|
+
|
25
|
+
# ...
|
26
|
+
|
27
|
+
# Save cache after compilation
|
28
|
+
if not cache_loaded:
|
29
|
+
b10_transfer.save_compile_cache()
|
30
|
+
```
|
31
|
+
|
32
|
+
## Configuration
|
33
|
+
|
34
|
+
Configure via environment variables:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
# Cache directories
|
38
|
+
export TORCH_CACHE_DIR="/tmp/torchinductor_root" # Default
|
39
|
+
export B10FS_CACHE_DIR="/cache/model/compile_cache" # Default
|
40
|
+
export LOCAL_WORK_DIR="/app" # Default
|
41
|
+
|
42
|
+
# Cache limits
|
43
|
+
export MAX_CACHE_SIZE_MB="1024" # 1GB default
|
44
|
+
```
|
45
|
+
|
46
|
+
## How It Works
|
47
|
+
|
48
|
+
### Environment-Specific Caching
|
49
|
+
|
50
|
+
The library automatically creates unique cache keys based on your environment:
|
51
|
+
|
52
|
+
```
|
53
|
+
torch-2.1.0_cuda-12.1_cc-8.6_triton-2.1.0 → cache_a1b2c3d4e5f6.latest.tar.gz
|
54
|
+
torch-2.0.1_cuda-11.8_cc-7.5_triton-2.0.1 → cache_x9y8z7w6v5u4.latest.tar.gz
|
55
|
+
torch-2.1.0_cpu_triton-none → cache_m1n2o3p4q5r6.latest.tar.gz
|
56
|
+
```
|
57
|
+
|
58
|
+
**Components used:**
|
59
|
+
- **PyTorch version** (e.g., `torch-2.1.0`)
|
60
|
+
- **CUDA version** (e.g., `cuda-12.1` or `cpu`)
|
61
|
+
- **GPU compute capability** (e.g., `cc-8.6` for A100)
|
62
|
+
- **Triton version** (e.g., `triton-2.1.0` or `triton-none`)
|
63
|
+
|
64
|
+
### Cache Workflow
|
65
|
+
|
66
|
+
1. **Load Phase** (startup): Generate environment key, check for matching cache in B10FS, extract to local directory
|
67
|
+
2. **Save Phase** (after compilation): Create archive, atomic copy to B10FS with environment-specific filename
|
68
|
+
|
69
|
+
### Lock-Free Race Prevention
|
70
|
+
|
71
|
+
Uses journal pattern with atomic filesystem operations for parallel-safe cache saves.
|
72
|
+
|
73
|
+
## API Reference
|
74
|
+
|
75
|
+
### Functions
|
76
|
+
|
77
|
+
- `load_compile_cache() -> bool`: Load cache from B10FS for current environment
|
78
|
+
- `save_compile_cache() -> bool`: Save cache to B10FS with environment-specific filename
|
79
|
+
- `clear_local_cache() -> bool`: Clear local cache directory
|
80
|
+
- `get_cache_info() -> Dict[str, Any]`: Get cache status information for current environment
|
81
|
+
- `list_available_caches() -> Dict[str, Any]`: List all cache files with environment details
|
82
|
+
|
83
|
+
### Exceptions
|
84
|
+
|
85
|
+
- `CacheError`: Base exception for cache operations
|
86
|
+
- `CacheValidationError`: Path validation or compatibility check failed
|
87
|
+
|
88
|
+
## Performance Impact
|
89
|
+
|
90
|
+
### Debugging
|
91
|
+
|
92
|
+
Enable debug logging:
|
93
|
+
|
94
|
+
```python
|
95
|
+
import logging
|
96
|
+
logging.getLogger('b10_transfer').setLevel(logging.DEBUG)
|
97
|
+
```
|
@@ -4,8 +4,8 @@ build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
5
5
|
[tool.poetry]
|
6
6
|
name = "b10-transfer"
|
7
|
-
version = "0.1.
|
8
|
-
description = "Distributed PyTorch
|
7
|
+
version = "0.1.2"
|
8
|
+
description = "Distributed PyTorch file transfer for Baseten - Environment-aware, lock-free file transfer management"
|
9
9
|
authors = ["Shounak Ray <shounak.noreply@baseten.co>", "Fred Liu <fred.liu.noreply@baseten.co>"]
|
10
10
|
maintainers = ["Fred Liu <fred.liu.noreply@baseten.co>", "Shounak Ray <shounak.noreply@baseten.co>"]
|
11
11
|
readme = "README.md"
|
@@ -13,7 +13,7 @@ homepage = "https://docs.baseten.co/development/model/b10-transfer"
|
|
13
13
|
documentation = "https://docs.baseten.co/development/model/b10-transfer"
|
14
14
|
repository = "https://pypi.org/project/b10-transfer/"
|
15
15
|
license = "MIT"
|
16
|
-
keywords = ["pytorch", "
|
16
|
+
keywords = ["pytorch", "file-transfer", "cache", "machine-learning", "inference"]
|
17
17
|
classifiers = [
|
18
18
|
"Development Status :: 4 - Beta",
|
19
19
|
"Intended Audience :: Developers",
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"""B10 Transfer - Lock-free PyTorch file transfer for Baseten."""
|
2
|
+
|
3
|
+
from .core import load_compile_cache, save_compile_cache, clear_local_cache
|
4
|
+
from .utils import CacheError, CacheValidationError
|
5
|
+
from .space_monitor import CacheOperationInterrupted
|
6
|
+
from .info import get_cache_info, list_available_caches
|
7
|
+
from .constants import SaveStatus, LoadStatus
|
8
|
+
|
9
|
+
# Version
|
10
|
+
__version__ = "0.1.2"
|
11
|
+
|
12
|
+
__all__ = [
|
13
|
+
"CacheError",
|
14
|
+
"CacheValidationError",
|
15
|
+
"CacheOperationInterrupted",
|
16
|
+
"SaveStatus",
|
17
|
+
"LoadStatus",
|
18
|
+
"load_compile_cache",
|
19
|
+
"save_compile_cache",
|
20
|
+
"clear_local_cache",
|
21
|
+
"get_cache_info",
|
22
|
+
"list_available_caches",
|
23
|
+
]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""Configuration constants for b10-
|
1
|
+
"""Configuration constants for b10-transfer.
|
2
2
|
|
3
3
|
This module defines configuration constants for the PyTorch compilation cache system.
|
4
4
|
Some values can be overridden by environment variables, but security caps are enforced
|
@@ -36,8 +36,7 @@ B10FS_CACHE_DIR = validate_path_security(
|
|
36
36
|
_b10fs_cache_dir, [_REQUIRED_TORCH_CACHE_DIR_PREFIX], "B10FS_CACHE_DIR"
|
37
37
|
)
|
38
38
|
|
39
|
-
# Validate LOCAL_WORK_DIR - allow /app, /tmp, and /cache paths
|
40
|
-
# This is like a "scratch" directory where you can do work (like compression/archival for example)
|
39
|
+
# Validate LOCAL_WORK_DIR - allow /app, /tmp, and /cache paths
|
41
40
|
_local_work_dir = os.getenv("LOCAL_WORK_DIR", "/app")
|
42
41
|
LOCAL_WORK_DIR = validate_path_security(
|
43
42
|
_local_work_dir, ["/app/", "/tmp/", "/cache/"], "LOCAL_WORK_DIR"
|
@@ -113,7 +112,6 @@ class WorkerStatus(Enum):
|
|
113
112
|
SUCCESS = auto()
|
114
113
|
ERROR = auto()
|
115
114
|
CANCELLED = auto()
|
116
|
-
FILE_NOT_FOUND = auto()
|
117
115
|
|
118
116
|
|
119
117
|
class LoadStatus(Enum):
|
@@ -131,22 +129,3 @@ class SaveStatus(Enum):
|
|
131
129
|
SUCCESS = auto()
|
132
130
|
ERROR = auto()
|
133
131
|
SKIPPED = auto()
|
134
|
-
|
135
|
-
|
136
|
-
class TransferStatus(Enum):
|
137
|
-
"""Status values for generic transfer operations."""
|
138
|
-
|
139
|
-
SUCCESS = auto()
|
140
|
-
ERROR = auto()
|
141
|
-
INTERRUPTED = auto()
|
142
|
-
DOES_NOT_EXIST = auto()
|
143
|
-
|
144
|
-
|
145
|
-
class AsyncTransferStatus(Enum):
|
146
|
-
NOT_STARTED = auto()
|
147
|
-
IN_PROGRESS = auto()
|
148
|
-
SUCCESS = auto()
|
149
|
-
ERROR = auto()
|
150
|
-
INTERRUPTED = auto()
|
151
|
-
CANCELLED = auto()
|
152
|
-
DOES_NOT_EXIST = auto()
|