update to use latest vast api and qwen3-next on 24GB gpu

This commit is contained in:
2026-05-13 09:47:02 -04:00
parent 8bba9ef2a6
commit f641ab955f
3 changed files with 37 additions and 25 deletions

1
20 Normal file
View File

@@ -0,0 +1 @@
Error: Unknown operator. Did you forget to quote your query? ''

View File

@@ -7,7 +7,7 @@
"cpu_ram": {"gt":23},
"gpu_ram": {"gt": 50000},
"reliability": {"gt": ".99"},
"direct": {"eq": true},
"inet_down": {"gt": 500},
"order": [
[
"price",

View File

@@ -17,9 +17,9 @@ import requests
# -----------------------------------------------------------------------------
# Configuration
# -----------------------------------------------------------------------------
OLLAMA_MODEL = "qwen3-coder-next:q8_0"
MIN_VRAM_MB = 80000
MAX_BID_HOURLY = 2.5
OLLAMA_MODEL = "qwen3-next:80b-a3b-instruct-q4_K_M "
MIN_VRAM_MB = 20000
MAX_BID_HOURLY = 1.5
DISK_SPACE_GB = int(MIN_VRAM_MB / 700 + 20)
VAST_API_BASE = "https://console.vast.ai/api/v0"
@@ -75,7 +75,7 @@ def get_cheapest_gpus() -> List[Dict[str, Any]]:
params["gpu_ram"] = {}
params["gpu_ram"]["gt"] = MIN_VRAM_MB
response = vast_request("GET", "bundles/", params=params)
response = vast_request("POST", "bundles/", json_data=params)
offers = response.get("offers", [])
if not offers:
@@ -112,6 +112,7 @@ def create_instance(offer_id: int) -> int:
return response["new_contract"]
def destroy_instance(instance_id: int) -> None:
return None
"""Destroys a running instance."""
print(f"Destroying instance {instance_id}...")
vast_request("DELETE", f"instances/{instance_id}/")
@@ -125,8 +126,11 @@ def get_instance_details(instance_id: int) -> Dict[str, Any]:
if not instances:
raise Exception(f"Instance {instance_id} not found.")
return instances[0]
return instances
def get_instances() -> List[Dict[str, Any]]:
"""Fetches a list of all instances for the user."""
response = vast_request("GET", "instances/")
return response.get("instances", [])
def wait_until_ready(instance_id: int, poll_interval: int = 15) -> Dict[str, Any]:
"""Polls the instance status until it is running and ready."""
print(f"Waiting for instance {instance_id} to become ready...")
@@ -182,29 +186,36 @@ def ssh_and_setup(ip: str, port: int, user: str = "root") -> None:
# Main Execution
# -----------------------------------------------------------------------------
def main():
instances = get_instances()
instance_id = 0
if instances:
print("Existing instances found:")
for inst in instances:
print(f" - ID: {inst['id']}, Status: {inst['actual_status']}, GPU: {inst.get('gpu_name', 'N/A')}")
instance_id = inst["id"]
print("Searching for the cheapest suitable GPU...")
try:
offers = get_cheapest_gpus()
except Exception as e:
print(f"Error finding GPUs: {e}")
return
instance_id = 0
for offer in offers:
offer_id = offer["id"]
gpu_name = offer.get("gpu_name", "Unknown GPU")
price = offer.get("dph_total", 0.0)
print(f"\nAttempting to claim Offer {offer_id} (GPU: {gpu_name}, Price: ${price:.3f}/hr)")
try:
instance_id = create_instance(offer_id)
print(f"Successfully claimed offer. Instance ID: {instance_id}")
break
except Exception as e:
print(f"Failed to claim offer {offer_id}: {e}")
if instance_id == 0:
for offer in offers:
offer_id = offer["id"]
gpu_name = offer.get("gpu_name", "Unknown GPU")
price = offer.get("dph_total", 0.0)
if not instance_id:
print(f"\nAttempting to claim Offer {offer_id} (GPU: {gpu_name}, Price: ${price:.3f}/hr)")
try:
instance_id = create_instance(offer_id)
print(f"Successfully claimed offer. Instance ID: {instance_id}")
break
except Exception as e:
print(f"Failed to claim offer {offer_id}: {e}")
if not instance_id or instance_id == 0:
print("Failed to claim any of the available offers.")
return
@@ -216,7 +227,7 @@ def main():
ssh_host = data.get("ssh_host")
ssh_port = data.get("ssh_port")
public_ip = data.get("public_ipaddr")
ssh_host=public_ip if public_ip else ssh_host
ports_config = data.get("ports", {})
pub_ssh_port = ports_config.get("22/tcp", [{}])[0].get("HostPort", ssh_port)
pub_ollama_port = ports_config.get("11434/tcp", [{}])[0].get("HostPort", "Unknown")
@@ -224,7 +235,7 @@ def main():
print(f"\nInstance is fully ready at {ssh_host}:{ssh_port}")
# Setup SSH and Ollama
ssh_and_setup(ssh_host, ssh_port, "root")
ssh_and_setup(public_ip, pub_ssh_port, "root")
print("\n--- Setup Complete ---")
print(f"SSH Command: ssh root@{public_ip} -p {pub_ssh_port}")