Skip to main content

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.so shared library (set MTIER_LIB_PATH if 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:

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)XMemTensorMTier
  • xmem.is_available() → Check if MTier is available
  • xmem.mbank_count() → Get number of memory banks
  • xmem.memory_available(bank_id) → Get available memory in bytes
  • xmem.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 initialized
  • MTierOutOfMemoryError - Remote memory allocation failed
  • MTierInvalidArgumentError - Invalid argument
  • MTierServiceUnavailableError - 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmem_mtier-0.1.2.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xmem_mtier-0.1.2-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file xmem_mtier-0.1.2.tar.gz.

File metadata

  • Download URL: xmem_mtier-0.1.2.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for xmem_mtier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d80d759716afc374bc361a2da11764834cba38ad9882596081758d564c37069f
MD5 c28b6a9b606c74dd6cac4f2c4f9631be
BLAKE2b-256 1a56227358da73451c64fb375c6ae98330630584e7530c50db23aa439aacf9d7

See more details on using hashes here.

File details

Details for the file xmem_mtier-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: xmem_mtier-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for xmem_mtier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 584735b7162bcc8c9dfb90d6d8cf561eef7e073774b15102a6e9ef9ff7259454
MD5 aa2310c59fbc3ae3c701c773738d11fa
BLAKE2b-256 5ef09118c5b1a84fdbebfe21d640e3ebca56a6fa592596597c71b28a0b594b45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page