API Reference¶
Technical reference for FlexTensor's public API. All pages below are auto-generated from source docstrings.
Simplified API¶
Module-level convenience functions — the recommended starting point for most users.
DEFAULT_MANAGER_NAME— Name used byget_offload_manager()when no explicit name is provided (value:"default")init()— Pre-initialize the tensor manager (optional, called automatically byoffload())offload()— Patch a model for automatic tensor offloadingget_offload_manager()— Get or create an offload manager singletonset_config()— Set configuration for an offload manageroffload_block()— Context manager for manual offloading controlget_gpu_memory_usage()— Get GPU memory usage (inference mode only)save_profile()/load_profile()— Profile persistenceoffload_from_profile()— Load a saved profile and offload in one stepoffload_from_state()— Adopt an in-memory saved staterelease()— Release resources and restore modelcollect_offload_timing()/reset_offload_timing()/update_offload_timing()— Inference offload-timing measure windowrequest_strategy_replan()/update_state()— Remeasure and rebuild strategy (compile / CUDA graphs)StrategyReplanStatus— Passive replan availability and outcome, read fromOffloadManager.strategy_replan_statusOffloadTimingReport/OffloadTimingSnapshot— Timing aggregates and per-pass dataload_model_from_profile()— Load a model from a saved profile with optimized weight loading
OffloadManager¶
The OffloadManager class provides full control over the offloading lifecycle. Obtain an instance via get_offload_manager().
Configuration¶
OffloadConfig— All offloading parameters with sensible defaultsload_config()— Load config from files, env vars, and kwargsGPUMemoryUsage— GPU memory usage breakdown
Strategies¶
Offloading strategies for OffloadConfig.load_strategy:
Strategy— Protocol all strategies implementKnapsackStrategy— Dynamic programming optimization (default)GreedyStrategy— Largest tensors firstGlobalOffloadStrategy— Global optimization across layers- And more...
Advanced¶
Lower-level components for custom workflows:
TensorManager— Direct control over discovery, profiling, and inference phasesTensorBenchmarkMode— Benchmark mode base classBenchmarkReplace/PreloadToDevice— Benchmark implementations- Host pinning — Lower-level pinned-memory helpers and modes