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.1.tar.gz (18.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.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xmem_mtier-0.1.1.tar.gz
  • Upload date:
  • Size: 18.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.1.tar.gz
Algorithm Hash digest
SHA256 bf3eda744f8a26082fd467c2720d037cfe159439e974ab0533b274ed1a0c42d1
MD5 09f845133929600dd6fd082a742d19cd
BLAKE2b-256 d030becd9a6614426a7694e22b6761a5e53227f1bac4969031e4e292bf965bf5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xmem_mtier-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed27f4f18e3e80b19222033ba144ee1d79b14e064c59ac8f3598a97d741776da
MD5 413802180970a9566b8daa77d4bd2c53
BLAKE2b-256 8b534e46330737cb8f6fe075d521778fd2e2f0602811cddabb03bb9e6f5fa498

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