Update README with vLLM usage instructions
Browse files
README.md
CHANGED
|
@@ -65,6 +65,8 @@ pip install flash-linear-attention # required for linear attention operators (K
|
|
| 65 |
|
| 66 |
## Usage
|
| 67 |
|
|
|
|
|
|
|
| 68 |
This model uses a custom architecture and requires `trust_remote_code=True`.
|
| 69 |
|
| 70 |
```python
|
|
@@ -101,6 +103,54 @@ response = processor.decode(output_ids[0][inputs.input_ids.shape[1]:], skip_spec
|
|
| 101 |
print(response)
|
| 102 |
```
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
---
|
| 105 |
|
| 106 |
## Dependencies
|
|
@@ -110,6 +160,8 @@ print(response)
|
|
| 110 |
| transformers | ≥ 4.57.0 |
|
| 111 |
| torch | ≥ 2.0 |
|
| 112 |
| flash-linear-attention (fla) | latest |
|
|
|
|
|
|
|
| 113 |
|
| 114 |
---
|
| 115 |
|
|
|
|
| 65 |
|
| 66 |
## Usage
|
| 67 |
|
| 68 |
+
### HuggingFace Transformers
|
| 69 |
+
|
| 70 |
This model uses a custom architecture and requires `trust_remote_code=True`.
|
| 71 |
|
| 72 |
```python
|
|
|
|
| 103 |
print(response)
|
| 104 |
```
|
| 105 |
|
| 106 |
+
### vLLM Acceleration
|
| 107 |
+
|
| 108 |
+
For significantly faster inference, MOSAIC-4B supports vLLM via an out-of-tree monkey patch plugin.
|
| 109 |
+
|
| 110 |
+
**Install the plugin:**
|
| 111 |
+
|
| 112 |
+
```bash
|
| 113 |
+
pip install -e .
|
| 114 |
+
# or from the model directory:
|
| 115 |
+
pip install -e /path/to/MOSAIC-4B
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
**Prerequisites:**
|
| 119 |
+
|
| 120 |
+
| Package | Version |
|
| 121 |
+
|---------|---------|
|
| 122 |
+
| vllm | ≥ 0.17.0, < 0.18.0 |
|
| 123 |
+
| flash-linear-attention (fla) | ≥ 0.4.2 |
|
| 124 |
+
| einops | latest |
|
| 125 |
+
|
| 126 |
+
**Usage:**
|
| 127 |
+
|
| 128 |
+
```python
|
| 129 |
+
import nas_child_vl_vllm # Register MOSAIC-4B with vLLM (must be imported before vLLM)
|
| 130 |
+
|
| 131 |
+
from vllm import LLM, SamplingParams
|
| 132 |
+
|
| 133 |
+
llm = LLM(
|
| 134 |
+
model="LiAuto-DSR/MOSAIC-4B",
|
| 135 |
+
trust_remote_code=True,
|
| 136 |
+
enforce_eager=True, # Required: FLA layers don't support CUDAGraph
|
| 137 |
+
dtype="bfloat16",
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
output = llm.generate("Hello, how are you?", SamplingParams(max_tokens=128))
|
| 141 |
+
print(output)
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
> **Note:** `enforce_eager=True` is required because the FLA (Flash Linear Attention) GDN/KDA layers do not support CUDA graphs. `trust_remote_code=True` is needed to load the custom config and model classes.
|
| 145 |
+
|
| 146 |
+
**What the plugin does when you `import nas_child_vl_vllm`:**
|
| 147 |
+
|
| 148 |
+
1. Registers `NasChildVLConfig` with vLLM's config discovery system
|
| 149 |
+
2. Maps `model_type="nas-child-vl"` to the config class
|
| 150 |
+
3. Maps `NasChildVLModelForCausalLM` architecture to the vLLM model class (lazy-loaded)
|
| 151 |
+
4. Registers `MambaModelConfig` for proper hybrid state management (GDN/KDA layers)
|
| 152 |
+
5. Patches `rmsnorm_fn` to support sigmoid activation (needed by KDA layers)
|
| 153 |
+
|
| 154 |
---
|
| 155 |
|
| 156 |
## Dependencies
|
|
|
|
| 160 |
| transformers | ≥ 4.57.0 |
|
| 161 |
| torch | ≥ 2.0 |
|
| 162 |
| flash-linear-attention (fla) | latest |
|
| 163 |
+
| vllm (optional, for acceleration) | ≥ 0.17.0, < 0.18.0 |
|
| 164 |
+
| einops (optional, for vLLM) | latest |
|
| 165 |
|
| 166 |
---
|
| 167 |
|