Skip to content

Commit 22235c0

Browse files
committed
Remove the initialize method.
Less is more.
1 parent 29b8160 commit 22235c0

File tree

2 files changed

+8
-28
lines changed

2 files changed

+8
-28
lines changed

launch/dynamo-run/README.md

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,14 @@ Command line arguments are passed to the python engine like this:
216216
dynamo-run out=pystr:my_python_engine.py -- -n 42 --custom-arg Orange --yes
217217
```
218218

219-
The python engine has two options for receiving those command line arguments (both of which are optional).
220-
221-
In both cases the argument list will include some standard ones as well as anything after the `--`.
219+
The python engine receives the arguments in `sys.argv`. The argument list will include some standard ones as well as anything after the `--`.
222220

223221
This input:
224222
```
225223
dynamo-run out=pystr:my_engine.py /opt/models/Llama-3.2-3B-Instruct/ --model-name llama_3.2 --tensor-parallel-size 4 -- -n 1
226224
```
227225

228-
1. In `sys.argv`:
229-
226+
is read like this:
230227
```
231228
async def generate(request):
232229
.. as before ..
@@ -235,31 +232,12 @@ if __name__ == "__main__":
235232
print(f"MAIN: {sys.argv}")
236233
```
237234

238-
Produces this output:
235+
and produces this output:
239236
```
240237
MAIN: ['my_engine.py', '--model-path', '/opt/models/Llama-3.2-3B-Instruct/', '--model-name', 'llama3.2', '--http-port', '8080', '--tensor-parallel-size', '4', '--base-gpu-id', '0', '--num-nodes', '1', '--node-rank', '0', '-n', '1']
241238
```
242239

243-
This form allows quick iteration on the engine setup.
244-
245-
2. In an `initialize` function:
246-
247-
```
248-
async def generate(request):
249-
.. as before ..
250-
251-
def initialize(args: list[str]) -> None:
252-
print(f"initialize: {args}")
253-
```
254-
255-
Produces this output:
256-
```
257-
initialize: ['--model-path', '/opt/models/Llama-3.2-3B-Instruct/', '--model-name', 'llama3.2', '--http-port', '8080', '--tensor-parallel-size', '4', '--base-gpu-id', '0', '--num-nodes', '1', '--node-rank', '0', '-n', '1']
258-
```
259-
260-
Note how in both cases the `-n` `1` is included.
261-
262-
Flags `--leader-addr` and `--model-config` will also be added if provided to `dynamo-run`.
240+
This allows quick iteration on the engine setup. Note how the `-n` `1` is included. Flags `--leader-addr` and `--model-config` will also be added if provided to `dynamo-run`.
263241

264242
### Dynamo does the pre-processing
265243

lib/llm/src/engines/python.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ async fn new_engine(
9494
tokio::task::spawn_blocking(move || run_asyncio(tx));
9595
let event_loop = rx.await?;
9696

97-
let user_module = python_file_to_module(py_file, py_args.clone())
98-
.with_context(|| py_file.display().to_string())?;
97+
let user_module =
98+
python_file_to_module(py_file, py_args).with_context(|| py_file.display().to_string())?;
9999
let generator = Python::with_gil(|py| {
100+
/* Leave commented, `initialize` may be needed to match Triton
100101
if let Ok(initialize) = user_module.getattr(py, "initialize") {
101102
initialize
102103
.call1(py, (py_args,))
@@ -106,6 +107,7 @@ async fn new_engine(
106107
})
107108
.with_context(|| "Failed calling python engine's initialize(args)")?;
108109
};
110+
*/
109111
user_module
110112
.getattr(py, "generate")
111113
.with_context(|| "generate")

0 commit comments

Comments
 (0)