Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/vllm/llama3_8b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ policy:

services:
policy:
procs: 2
num_replicas: 1
procs: ${policy.engine_config.tensor_parallel_size}
num_replicas: 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! No tweaks!

with_gpus: true


Expand Down
45 changes: 26 additions & 19 deletions apps/vllm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,32 @@ async def run(cfg: DictConfig):
print("Spawning service...")
policy = await Policy.options(**cfg.services.policy).as_service(**cfg.policy)

try:
async with policy.session():
print("Requesting generation...")
response_output: list[Completion] = await policy.generate.choose(
prompt=prompt
)

print("\nGeneration Results:")
print("=" * 80)
for batch, response in enumerate(response_output):
print(f"Sample {batch + 1}:")
print(f"User: {prompt}")
print(f"Assistant: {response.text}")
print("-" * 80)

finally:
print("\nShutting down...")
await policy.shutdown()
await shutdown()
import time

print("Requesting generation...")
n = 100
start = time.time()
response_outputs: list[Completion] = await asyncio.gather(
*[policy.generate.choose(prompt=prompt) for _ in range(n)]
)
end = time.time()

print(f"Generation of {n} requests completed in {end - start:.2f} seconds.")
print(
f"Generation with procs {cfg.services.policy.procs}, replicas {cfg.services.policy.num_replicas}"
)

print(f"\nGeneration Results (last one of {n} requests):")
print("=" * 80)
for batch, response in enumerate(response_outputs[-1]):
print(f"Sample {batch + 1}:")
print(f"User: {prompt}")
print(f"Assistant: {response.text}")
print("-" * 80)

print("\nShutting down...")
await policy.shutdown()
await shutdown()


@parse
Expand Down
Loading