Pota019 commited on
Commit
17e842e
·
verified ·
1 Parent(s): 5d4f37a

Connect Qwen3 Transformers inference and quota-bounded scenario evaluation

Browse files
Files changed (5) hide show
  1. README.md +5 -1
  2. app.py +30 -1
  3. harnesslab_bundle.zip +2 -2
  4. manifest.json +13 -3
  5. requirements.txt +3 -0
README.md CHANGED
@@ -45,7 +45,11 @@ CPU에서 실행하고 GPU 모델은 로드하지 않습니다. 유료 하드웨
45
  - `HARNESS_TEMPERATURE=0`, `HARNESS_MAX_TOKENS=2048`, `HARNESS_SEED=42`
46
 
47
  Space의 localhost는 사용자의 PC가 아닙니다. 외부 추론 서비스 비용은 활성화할 때 별도로 확인하세요.
48
- 이번 프로토타입은 Hugging Face GPU 모델 추론 백엔드를 추가하지 않았습니다.
 
 
 
 
49
 
50
  ## 데이터
51
 
 
45
  - `HARNESS_TEMPERATURE=0`, `HARNESS_MAX_TOKENS=2048`, `HARNESS_SEED=42`
46
 
47
  Space의 localhost는 사용자의 PC가 아닙니다. 외부 추론 서비스 비용은 활성화할 때 별도로 확인하세요.
48
+ `실제 모델` 버튼 또는 `/gradio`에서 Qwen/Qwen3-4B-Instruct-2507을 직접 실행할 수 있습니다.
49
+ 1회 실행은 S01~S05 중 선택한 시나리오 1개이며 최대 120초 ZeroGPU 작업을 요청합니다.
50
+ temperature 0, seed 42, 최대 출력 512토큰, 최대 6단계입니다. 기록 데이터와 별도로
51
+ 실행 결과와 Trace JSON을 제공합니다. 모델 가중치는 시작 시 준비하고 GPU 시간은
52
+ 실행 버튼을 누를 때만 요청합니다. 실제 모델 실행에는 무료 GPU 쿼터가 사용됩니다.
53
 
54
  ## 데이터
55
 
app.py CHANGED
@@ -34,6 +34,30 @@ def main() -> None:
34
  import spaces
35
  import uvicorn
36
  from space_app import app as workspace
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  @spaces.GPU(duration=10)
39
  def gpu_environment_check() -> dict[str, str | float]:
@@ -52,7 +76,12 @@ def main() -> None:
52
  "purpose": "GPU environment diagnostic; not a model performance benchmark"}
53
 
54
  with gr.Blocks(title="HarnessLab") as info:
55
- gr.Markdown("# HarnessLab\n[평가 워크스페이스 열기](/)\n\n기존 평가 엔진을 실행하는 프로토타입입니다. GPU 추론은 포함하지 않습니다.")
 
 
 
 
 
56
  gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
57
  diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
58
  gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
 
34
  import spaces
35
  import uvicorn
36
  from space_app import app as workspace
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+ import torch
39
+ import tempfile
40
+ from uuid import uuid4
41
+ from adapters.transformers_local import TransformersLocalAdapter
42
+ from harness.hf_evaluation import evaluate_case
43
+
44
+ model_id = "Qwen/Qwen3-4B-Instruct-2507"
45
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)
46
+ model = AutoModelForCausalLM.from_pretrained(
47
+ model_id, torch_dtype=torch.float16, low_cpu_mem_usage=True, trust_remote_code=False,
48
+ ).eval().to("cuda")
49
+
50
+ @spaces.GPU(duration=120)
51
+ def run_model(case_id: str) -> tuple[dict, str]:
52
+ adapter = TransformersLocalAdapter(model_id=model_id, model=model, tokenizer=tokenizer)
53
+ path = Path(tempfile.gettempdir()) / f"harnesslab-hf-{uuid4()}.json"
54
+ batch = evaluate_case(adapter, case_id, model_id, getattr(model.config, "_commit_hash", None), root, path)
55
+ from space_app import store_report
56
+ report_id = store_report(batch, "real_live")
57
+ result = batch.summary()
58
+ result["workspace_report"] = f"/?report={report_id}"
59
+ result["failure_reason"] = batch.cases[0].report.evaluation.failure_reason
60
+ return result, str(path)
61
 
62
  @spaces.GPU(duration=10)
63
  def gpu_environment_check() -> dict[str, str | float]:
 
76
  "purpose": "GPU environment diagnostic; not a model performance benchmark"}
77
 
78
  with gr.Blocks(title="HarnessLab") as info:
79
+ gr.Markdown("# HarnessLab — 실제 모델 평가\n[평가 워크스페이스 열기](/)\n\nQwen3-4B-Instruct-2507을 이 Space에서 실행합니다. API 키나 로컬 PC가 필요 없습니다. 1회 실행은 시나리오 1개이며 최대 120초의 ZeroGPU 작업을 요청합니다. 무료 쿼터를 사용합니다.")
80
+ scenario = gr.Dropdown(["S01", "S02", "S03", "S04", "S05"], value="S01", label="평가 시나리오")
81
+ execute = gr.Button("실제 모델 평가 실행 — ZeroGPU 사용", variant="primary")
82
+ summary = gr.JSON(label="실제 실행 결과")
83
+ artifact = gr.File(label="평가 Trace JSON 다운로드")
84
+ execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)
85
  gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
86
  diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
87
  gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
harnesslab_bundle.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1669bfe33c30b83bb85b5ccf3eb71e6153d130f73fc12bf3da8480d017162142
3
- size 53363
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cdca6022e818220ad5c9ef7fe0691e3a2e64a10bb42136c86c873df602c452de
3
+ size 56927
manifest.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "release": "HarnessLab Gradio Space Prototype",
3
- "bundle_sha256": "1669bfe33c30b83bb85b5ccf3eb71e6153d130f73fc12bf3da8480d017162142",
4
  "files": [
5
  {
6
  "path": "harness/__init__.py",
@@ -27,6 +27,11 @@
27
  "bytes": 989,
28
  "sha256": "1b3fb1917c4d43aa40a6e3161f3fab6a7489859aa81c95c7c7bbb20444ebdab8"
29
  },
 
 
 
 
 
30
  {
31
  "path": "harness/local_tools.py",
32
  "bytes": 730,
@@ -77,6 +82,11 @@
77
  "bytes": 1825,
78
  "sha256": "93a827a73be032f6fd248c6efeee32bd610284ec86b32ec11b2b2e1c5b683b07"
79
  },
 
 
 
 
 
80
  {
81
  "path": "data/scenarios/01_save_note.json",
82
  "bytes": 468,
@@ -124,8 +134,8 @@
124
  },
125
  {
126
  "path": "web/index.html",
127
- "bytes": 18933,
128
- "sha256": "4f46e32ad49c2a98acdec63d4e94af59b3a7861ab95373cc634926f04990942d"
129
  },
130
  {
131
  "path": "data/reference_runs/ollama_local_02/smoke.json",
 
1
  {
2
  "release": "HarnessLab Gradio Space Prototype",
3
+ "bundle_sha256": "cdca6022e818220ad5c9ef7fe0691e3a2e64a10bb42136c86c873df602c452de",
4
  "files": [
5
  {
6
  "path": "harness/__init__.py",
 
27
  "bytes": 989,
28
  "sha256": "1b3fb1917c4d43aa40a6e3161f3fab6a7489859aa81c95c7c7bbb20444ebdab8"
29
  },
30
+ {
31
+ "path": "harness/hf_evaluation.py",
32
+ "bytes": 1655,
33
+ "sha256": "95ffffc5613a34c526ed1629fddb8b78d8fae27c3a3b00e84070142294cff886"
34
+ },
35
  {
36
  "path": "harness/local_tools.py",
37
  "bytes": 730,
 
82
  "bytes": 1825,
83
  "sha256": "93a827a73be032f6fd248c6efeee32bd610284ec86b32ec11b2b2e1c5b683b07"
84
  },
85
+ {
86
+ "path": "adapters/transformers_local.py",
87
+ "bytes": 7154,
88
+ "sha256": "4c1cd6e7193e08bd4b6b69025072726359328a957a49c56a00d12f88d64afac2"
89
+ },
90
  {
91
  "path": "data/scenarios/01_save_note.json",
92
  "bytes": 468,
 
134
  },
135
  {
136
  "path": "web/index.html",
137
+ "bytes": 19248,
138
+ "sha256": "34da8cca1df287377b39e473d4eb1d8ffd7a123b6207b45a23fbd5e67ada9837"
139
  },
140
  {
141
  "path": "data/reference_runs/ollama_local_02/smoke.json",
requirements.txt CHANGED
@@ -4,3 +4,6 @@ openai>=1.50,<4
4
  httpx>=0.27,<1
5
  fastapi>=0.115,<1
6
  uvicorn>=0.30,<1
 
 
 
 
4
  httpx>=0.27,<1
5
  fastapi>=0.115,<1
6
  uvicorn>=0.30,<1
7
+ transformers>=4.51,<5
8
+ accelerate>=1,<2
9
+ safetensors>=0.4