High-level Python wrapper for MTier memory management with PyTorch integration
Project description
xmem
High-level Python wrapper for MTier memory management with PyTorch integration.
Overview
xmem enables seamless offloading of PyTorch tensors to MTier remote memory tiers, allowing you to work with datasets and models that exceed GPU memory capacity.
Key Features:
- Simple API:
xmem.offload()and.prefetch() - Seamless PyTorch integration with CUDA support
- Async operations for overlapping computation and I/O
- Automatic memory management
Quick Installation
# Install prerequisites
pip install torch torchvision cuda-python>=12.0.0
# Install xmem (development mode)
cd /path/to/memory-tier-emu-framework/python
pip install -e .
Requirements:
- Python >= 3.8
- PyTorch >= 2.0.0 with CUDA support
- NVIDIA Hopper+ GPU (H100, H200, etc.) with fabric memory support
libmtier.soshared library (setMTIER_LIB_PATHif not in default location)
Quick Start
import torch
import xmem
# Create a tensor on GPU
tensor = torch.randn(1000, 1000, device='cuda')
# Offload to remote memory
remote_tensor = xmem.offload(tensor, bank_id=1)
# Prefetch back to GPU
reconstructed = remote_tensor.prefetch()
# Verify data integrity
assert torch.equal(tensor, reconstructed)
Async Operations
# Non-blocking offload
remote_tensor = xmem.offload(tensor, bank_id=1, non_blocking=True)
# Do other work while transfer happens...
# Non-blocking prefetch
remote_tensor.prefetch(non_blocking=True)
# Do other work...
# Get the result
reconstructed = remote_tensor.wait()
Documentation
📚 Full Python API Documentation
The comprehensive documentation includes:
- Detailed installation guide with troubleshooting
- Complete API reference for all functions and classes
- Advanced usage patterns and best practices
- Performance optimization tips
- Error handling and exception reference
Examples
See working examples in the examples/ directory:
pytorch_usage.py- Basic synchronous operationspytorch_async_usage.py- Async operations with pipelining
cd examples
python pytorch_usage.py
python pytorch_async_usage.py
API Summary
Core Functions
xmem.offload(tensor, bank_id, non_blocking=False, stream=None)→XMemTensorMTierxmem.is_available()→ Check if MTier is availablexmem.mbank_count()→ Get number of memory banksxmem.memory_available(bank_id)→ Get available memory in bytesxmem.memory_allocated(bank_id)→ Get allocated memory in bytes
XMemTensorMTier Methods
.prefetch(dst_tensor=None, device=None, reuse=False, non_blocking=False, stream=None)→ Retrieve tensor from remote memory.wait(timeout=None)→ Wait for async operation to complete.is_ready()→ Check if async operation is complete- Properties:
shape,dtype,size,remote_addr,device
Exceptions
All exceptions inherit from MTierError:
MTierNotInitializedError- SDK not initializedMTierOutOfMemoryError- Remote memory allocation failedMTierInvalidArgumentError- Invalid argumentMTierServiceUnavailableError- MTier service unavailable
See full documentation for complete exception hierarchy.
Development
# Install in development mode
pip install -e ".[dev]"
# Build wheel
pip install build
python -m build
# Run tests
pytest tests/
Support
For detailed documentation, examples, and best practices, see the Python API Documentation.
For issues or questions, please contact the development team.
License: Proprietary - All Rights Reserved
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xmem_mtier-0.1.0.tar.gz.
File metadata
- Download URL: xmem_mtier-0.1.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68f90f258e7202beb63268969678f01f8ec8c76fa2619502485a477fbc3885e2
|
|
| MD5 |
d43a082c44fe90469a7184778d1eec0e
|
|
| BLAKE2b-256 |
f008861079562b57e170e7630c2caa841971353a8691c25c4512dc7d540196cf
|
File details
Details for the file xmem_mtier-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xmem_mtier-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc916564596d986997b006a77135b7142baad31ac28aabbe8f79223038e04a3d
|
|
| MD5 |
ed645c1d6a44ed6bc3cc4a26ec4f9083
|
|
| BLAKE2b-256 |
68fa784bb047a1cf76c0b994e3de268b46eb30c7ff64f510eeba51c9b6a012bb
|