Instructions to use MemTensor/MemT-1.0-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MemTensor/MemT-1.0-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MemTensor/MemT-1.0-Pro", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MemTensor/MemT-1.0-Pro", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MemTensor/MemT-1.0-Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MemTensor/MemT-1.0-Pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MemTensor/MemT-1.0-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MemTensor/MemT-1.0-Pro
- SGLang
How to use MemTensor/MemT-1.0-Pro with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MemTensor/MemT-1.0-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MemTensor/MemT-1.0-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MemTensor/MemT-1.0-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MemTensor/MemT-1.0-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MemTensor/MemT-1.0-Pro with Docker Model Runner:
docker model run hf.co/MemTensor/MemT-1.0-Pro
Download configuration_memt.py from MemTensor/MemT-1.0-Pro: direct link, hf CLI and curl.
- Browser
- Download file 4.72 kB
-
https://huggingface.co/MemTensor/MemT-1.0-Pro/resolve/main/configuration_memt.py
- Command line
-
hf download hf://MemTensor/MemT-1.0-Pro/configuration_memt.py
-
curl -L -o configuration_memt.py https://huggingface.co/MemTensor/MemT-1.0-Pro/resolve/main/configuration_memt.py
4.72 kB
| """MemT-1.0-Pro configuration for the Nemotron-H backbone. | |
| For dense_v1, Q/K/V and erase/write projections are full-width. gate_rank | |
| controls the factorized decay/output gates, preserving their trained shapes. | |
| """ | |
| from copy import deepcopy | |
| from transformers import PretrainedConfig | |
| from transformers.models.nemotron_h.configuration_nemotron_h import NemotronHConfig | |
| _SEMANTICS = { | |
| "memory_update_mode": "token", | |
| "gdn_version": "stable_gdn2", | |
| "memory_use_short_conv": False, | |
| "memory_head_mode": "mha", | |
| "memory_read_scale": "k_inv_sqrt", | |
| "projection": "dense_v1", | |
| "gate_rank": 512, | |
| "output_gate_type": "silu", | |
| "output_gate_bias": False, | |
| "output_gate_softcap_enabled": True, | |
| "output_gate_softcap_limit": 2.0, | |
| "stable_gdn2_sqrt_erase_gate": True, | |
| "linear_attention_state_policy": "reset_per_chunk", | |
| "chunk_tokens": 2048, | |
| "tail_policy": "commit", | |
| "gate_latent_norm": False, | |
| } | |
| _GEOMETRY = {"layers", "num_memory_heads", "num_kv_heads", "head_dim", "norm_eps"} | |
| class MemTNemotronHConfig(PretrainedConfig): | |
| model_type = "memt_nemotron_h" | |
| has_no_defaults_at_init = True | |
| def __init__(self, backbone_configs=None, memt=None, **kwargs): | |
| if not isinstance(backbone_configs, dict) or not isinstance(memt, dict): | |
| raise TypeError("backbone_configs and memt are required objects") | |
| required = set(_SEMANTICS) | _GEOMETRY | |
| if set(memt) != required: | |
| raise ValueError(f"Unknown MemT fields: {sorted(set(memt) - required)}; " | |
| f"missing: {sorted(required - set(memt))}") | |
| for name, expected in _SEMANTICS.items(): | |
| if type(memt[name]) is not type(expected) or memt[name] != expected: | |
| raise ValueError(f"Unsupported memt.{name}: {memt[name]!r}") | |
| b = deepcopy(backbone_configs) | |
| if b.get("model_type") != "nemotron_h": | |
| raise ValueError("MemT-1.0-Pro requires the native nemotron_h backbone") | |
| kinds = b.get("layers_block_type") | |
| if not isinstance(kinds, list) or not kinds or any(x not in {"mamba", "moe", "attention", "mlp"} for x in kinds): | |
| raise ValueError("layers_block_type must use native Nemotron layer names") | |
| expected_layers = [i for i, kind in enumerate(kinds) if kind == "attention"] | |
| if (not isinstance(memt["layers"], list) | |
| or any(type(x) is not int for x in memt["layers"]) | |
| or memt["layers"] != expected_layers or not expected_layers): | |
| raise ValueError("MemT must be attached to every native attention layer in order") | |
| for name, expected in (("num_memory_heads", b["num_attention_heads"]), | |
| ("num_kv_heads", b["num_attention_heads"]), | |
| ("head_dim", b["head_dim"])): | |
| if type(memt[name]) is not int or memt[name] <= 0 or memt[name] != expected: | |
| raise ValueError(f"memt.{name} must match native query-head geometry") | |
| if b["num_attention_heads"] % b["num_key_value_heads"]: | |
| raise ValueError("Native query heads must be divisible by native KV heads") | |
| if (isinstance(memt["norm_eps"], bool) or memt["norm_eps"] != b["layer_norm_epsilon"] | |
| or not 0 < memt["norm_eps"] < 1): | |
| raise ValueError("memt.norm_eps must match the native normalization epsilon") | |
| for key in ("metis_settings", "memory_configs", "backend", "backend_config"): | |
| if key in kwargs: | |
| raise ValueError(f"Training-only field {key!r} is not part of this HF configuration") | |
| for name in ("bos_token_id", "eos_token_id", "pad_token_id", "tie_word_embeddings"): | |
| kwargs.setdefault(name, b.get(name)) | |
| self.backbone_configs = b | |
| self.memt = deepcopy(memt) | |
| super().__init__(**kwargs) | |
| self.vocab_size = b["vocab_size"] | |
| self.hidden_size = b["hidden_size"] | |
| self.num_hidden_layers = len(kinds) | |
| self.initializer_range = b["initializer_range"] | |
| self.use_cache = kwargs.get("use_cache", True) | |
| def get_text_config(self, decoder=False, encoder=False): | |
| text = NemotronHConfig(**deepcopy(self.backbone_configs)) | |
| text._attn_implementation = getattr(self, "_attn_implementation", None) or "sdpa" | |
| text._experts_implementation = getattr(self, "_experts_implementation", None) | |
| return text | |
| def from_dict(cls, config_dict, **kwargs): | |
| result = super().from_dict(deepcopy(config_dict), **kwargs) | |
| config = result[0] if isinstance(result, tuple) else result | |
| cls(**config.to_dict()) | |
| return result | |
| MemTNemotronHConfig.register_for_auto_class() | |