Erinaldorodrigues commited on
Commit
d6f161f
·
verified ·
1 Parent(s): cac816b

Upgrade Space to Qwen3 Coder 30B FP8

Browse files
Files changed (3) hide show
  1. README.md +5 -3
  2. app.py +17 -8
  3. requirements.txt +3 -3
README.md CHANGED
@@ -10,9 +10,11 @@ app_file: app.py
10
  pinned: false
11
  ---
12
 
13
- This Space serves `Qwen/Qwen3-14B` through a compact OpenAI Chat Completions
14
- surface. It accepts standard function-tool schemas, disables reasoning traces
15
- for tool turns, and returns OpenAI-compatible structured tool calls for
 
 
16
  OpenClaude.
17
 
18
  Set `MODEL_ID` only when deliberately testing another compatible model; the
 
10
  pinned: false
11
  ---
12
 
13
+ This Space serves `Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8` through a compact
14
+ OpenAI Chat Completions surface. The official 29 GiB FP8 checkpoint fits the
15
+ default 48 GB ZeroGPU slice, activates 3.3B of its 30.5B parameters per token,
16
+ and is specialized for agentic coding. The endpoint accepts standard function-
17
+ tool schemas and returns OpenAI-compatible structured tool calls for
18
  OpenClaude.
19
 
20
  Set `MODEL_ID` only when deliberately testing another compatible model; the
app.py CHANGED
@@ -31,10 +31,14 @@ from transformers import (
31
  from tool_calls import extract_tool_call, has_complete_tool_call
32
 
33
 
34
- # Qwen3-14B fits comfortably in the Space's ZeroGPU allocation and, unlike the
35
- # previous coding model, has a dedicated chat template for OpenAI-style tool
36
- # calls. Keep MODEL_ID as an override so the Space remains easy to roll back.
37
- MODEL = os.getenv("MODEL_ID", "Qwen/Qwen3-14B")
 
 
 
 
38
  MAX_CONTEXT_TOKENS = int(os.getenv("MAX_CONTEXT_TOKENS", "24000"))
39
  MAX_NEW_TOKENS = int(os.getenv("MAX_NEW_TOKENS", "768"))
40
  TOOL_PROTOCOL_MARKER = "OPENAI TOOL CALL FORMAT — MANDATORY"
@@ -47,7 +51,9 @@ tokenizer.truncation_side = "left"
47
  print(f"Loading {MODEL} on ZeroGPU during startup...", flush=True)
48
  model = AutoModelForCausalLM.from_pretrained(
49
  MODEL,
50
- dtype=torch.bfloat16,
 
 
51
  low_cpu_mem_usage=True,
52
  )
53
  model = model.to("cuda")
@@ -303,10 +309,13 @@ def _completion_payload(request: ChatCompletionRequest) -> dict[str, Any]:
303
  if request.model not in {
304
  MODEL,
305
  "qwen-coder",
 
 
306
  "qwen3",
307
  "qwen3-14b",
308
- # Accept the previous backend identifier during the local proxy's
309
- # rolling restart so an in-flight OpenClaude session is not rejected.
 
310
  "Qwen/Qwen2.5-Coder-14B-Instruct",
311
  "qwen2.5-coder-14b",
312
  }:
@@ -391,7 +400,7 @@ demo = gr.Interface(
391
  gr.Number(value=512, label="Max Tokens"),
392
  ],
393
  outputs="text",
394
- title="Qwen Coder ZeroGPU Backend",
395
  )
396
 
397
  class OpenAIRouteMiddleware(BaseHTTPMiddleware):
 
31
  from tool_calls import extract_tool_call, has_complete_tool_call
32
 
33
 
34
+ # Qwen3-Coder-30B-A3B is the strongest coding-specialized Qwen checkpoint that
35
+ # fits the default 48 GB ZeroGPU slice and the Space's 50 GB disk. The official
36
+ # FP8 checkpoint is about 29 GiB, activates only 3.3B parameters per token, and
37
+ # has a dedicated chat template for OpenAI-style tool calls. Keep MODEL_ID as
38
+ # an override so the Space remains easy to roll back.
39
+ MODEL = os.getenv(
40
+ "MODEL_ID", "Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8"
41
+ )
42
  MAX_CONTEXT_TOKENS = int(os.getenv("MAX_CONTEXT_TOKENS", "24000"))
43
  MAX_NEW_TOKENS = int(os.getenv("MAX_NEW_TOKENS", "768"))
44
  TOOL_PROTOCOL_MARKER = "OPENAI TOOL CALL FORMAT — MANDATORY"
 
51
  print(f"Loading {MODEL} on ZeroGPU during startup...", flush=True)
52
  model = AutoModelForCausalLM.from_pretrained(
53
  MODEL,
54
+ # Preserve the checkpoint's fine-grained FP8 weights. Forcing BF16 here
55
+ # would roughly double memory use and no longer fit the default GPU slice.
56
+ torch_dtype="auto",
57
  low_cpu_mem_usage=True,
58
  )
59
  model = model.to("cuda")
 
309
  if request.model not in {
310
  MODEL,
311
  "qwen-coder",
312
+ "qwen3-coder",
313
+ "qwen3-coder-30b-a3b",
314
  "qwen3",
315
  "qwen3-14b",
316
+ # Accept previous backend identifiers during the local proxy's rolling
317
+ # restart so an in-flight OpenClaude session is not rejected.
318
+ "Qwen/Qwen3-14B",
319
  "Qwen/Qwen2.5-Coder-14B-Instruct",
320
  "qwen2.5-coder-14b",
321
  }:
 
400
  gr.Number(value=512, label="Max Tokens"),
401
  ],
402
  outputs="text",
403
+ title="Qwen3 Coder 30B ZeroGPU Backend",
404
  )
405
 
406
  class OpenAIRouteMiddleware(BaseHTTPMiddleware):
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  fastapi
2
  pydantic
3
- transformers
4
- torch
5
- accelerate
 
1
  fastapi
2
  pydantic
3
+ transformers>=4.52.3
4
+ torch>=2.8.0
5
+ accelerate>=1.2.0