Skip to content

Commit

Permalink
Merge pull request #35 from gizatechxyz/gonzalo/giz-312-handle-provin…
Browse files Browse the repository at this point in the history
…g-in-the-runner

Improve Proving by using trace and memory
  • Loading branch information
Gonmeso authored Jan 22, 2024
2 parents 14f5543 + b8c6b28 commit f81af2c
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 403 deletions.
2 changes: 1 addition & 1 deletion giza/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
Depending on the framework, this command will do different things:
* For Cairo, it will generate a proof using a `CASM.JSON` as the representation to create the proof for.
* For Cairo, it will generate a proof using a trace and a memory file in that order.
* For EZKL, it will generate a proof using the provided input, all the trusted setup will be retrieve during the job.
This command will create a job with the specified size, but the amount of jobs will be rate limited by the backend.
Expand Down
13 changes: 11 additions & 2 deletions giza/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,12 @@ def get(self, job_id: int, params: Optional[dict[str, str]] = None) -> Job:
return Job(**response.json())

@auth
def create(self, job_create: JobCreate, f: BufferedReader) -> Job:
def create(
self,
job_create: JobCreate,
trace: BufferedReader,
memory: Optional[BufferedReader] = None,
) -> Job:
"""
Create a new job.
Expand All @@ -752,11 +757,15 @@ def create(self, job_create: JobCreate, f: BufferedReader) -> Job:
"""
headers = copy.deepcopy(self.default_headers)
headers.update(self._get_auth_header())

files = {"trace_or_proof": trace} if trace is not None else None
if trace is not None and memory is not None:
files["memory"] = memory
response = self.session.post(
f"{self.url}/{self.JOBS_ENDPOINT}",
headers=headers,
params=job_create.dict(),
files={"file": f} if f is not None else None,
files=files,
)
self._echo_debug(str(response))

Expand Down
6 changes: 3 additions & 3 deletions giza/commands/prove.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional

import typer

Expand All @@ -10,7 +10,7 @@


def prove(
data: str = typer.Argument(None),
data: List[str] = typer.Argument(None),
model_id: Optional[int] = typer.Option(None, "--model-id", "-m"),
version_id: Optional[int] = typer.Option(None, "--version-id", "-v"),
size: JobSize = typer.Option(JobSize.S, "--size", "-s"),
Expand All @@ -22,7 +22,7 @@ def prove(
cairo.prove(data=data, size=size, output_path=output_path, debug=debug)
elif framework == Framework.EZKL:
ezkl.prove(
input_data=data,
input_data=data[0],
model_id=model_id,
version_id=version_id,
size=size,
Expand Down
9 changes: 6 additions & 3 deletions giza/frameworks/cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


def prove(
data: str,
data: list[str],
debug: Optional[bool],
size: JobSize = JobSize.S,
framework: Framework = Framework.CAIRO,
Expand All @@ -58,8 +58,11 @@ def prove(
"""
try:
client = JobsClient(API_HOST)
with open(data) as casm:
job: Job = client.create(JobCreate(size=size, framework=framework), casm)
trace_path, memory_path = data
with open(trace_path, "rb") as trace, open(memory_path, "rb") as memory:
job: Job = client.create(
JobCreate(size=size, framework=framework), trace, memory
)
echo(f"Proving job created with name '{job.job_name}' and id -> {job.id} ✅")
with Live() as live:
while True:
Expand Down
Loading

0 comments on commit f81af2c

Please sign in to comment.