LLM: vLLM on AMD MI300X (OpenAI-compat) with HF fallback
Browse files134 unmodified lines13513613713813914014114214347 unmodified lines191192193194195196197198199200201202203134 unmodified linesbw = _windows(bold)return torch.FloatTensor(bw).unsqueeze(0), torch.FloatTensor(adj).unsqueeze(0)# ── LLM (Qwen2.5-7B fine-tuned on AMD MI300X, served via HF Inference API) ─_LLM_MODEL = "Yatsuiii/asd-interpreter-merged"_HF_TOKEN = os.environ.get("HF_TOKEN", "")_SYSTEM_PROMPT = (47 unmodified linesf"and values listed above. Do not mention any network not in this report.")try:from huggingface_hub import InferenceClientclient = InferenceClient(model=_LLM_MODEL, token=_HF_TOKEN or None)messages = [{"role": "system", "content": _SYSTEM_PROMPT},{"role": "user", "content": user_msg},]response = client.chat_completion(messages=messages, max_tokens=512, temperature=0.1)return response.choices[0].message.content.strip()except Exception as e:return f"[LLM unavailable: {e}]"134 unmodified lines13513613713813914014114214314447 unmodified lines192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221134 unmodified linesbw = _windows(bold)return torch.FloatTensor(bw).unsqueeze(0), torch.FloatTensor(adj).unsqueeze(0)# ── LLM (Qwen2.5-7B fine-tuned on AMD MI300X, served via vLLM on MI300X) ───_VLLM_URL = os.environ.get("VLLM_BASE_URL", "")_LLM_MODEL = "Yatsuiii/asd-interpreter-merged"_HF_TOKEN = os.environ.get("HF_TOKEN", "")_SYSTEM_PROMPT = (47 unmodified linesf"and values listed above. Do not mention any network not in this report.")try:from openai import OpenAIif _VLLM_URL:# Live AMD MI300X inference via vLLMclient = OpenAI(base_url=_VLLM_URL, api_key="not-required")model_id = _LLM_MODELelse:# Fallback: HF Inference APIfrom huggingface_hub import InferenceClient as _HFClientclient = _HFClient(model=_LLM_MODEL, token=_HF_TOKEN or None)response = client.chat_completion(messages=[{"role": "system", "content": _SYSTEM_PROMPT},{"role": "user", "content": user_msg},],max_tokens=512, temperature=0.1,)return response.choices[0].message.content.strip()messages = [{"role": "system", "content": _SYSTEM_PROMPT},{"role": "user", "content": user_msg},]response = client.chat.completions.create(model=model_id, messages=messages, max_tokens=512, temperature=0.1)return response.choices[0].message.content.strip()except Exception as e:return f"[LLM unavailable: {e}]"
app.py+23-5