Skip to content

Commit

Permalink
Use multiprocessing in several modes
Browse files Browse the repository at this point in the history
  • Loading branch information
WeetHet committed Jan 16, 2025
1 parent 557a601 commit 27c3195
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 105 deletions.
19 changes: 19 additions & 0 deletions scripts/run_several_modes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

vcmd=${1:-"dafny verify --allow-warnings --verification-time-limit 10"}
prompts_dir=${2:-"prompts/humaneval-dafny"}
dir=${3:-"benches/HumanEval-Dafny"}
ext=${4:-"dfy"}

PYLOG_LEVEL=INFO NOFILE=1 poetry run several_modes \
--insert-conditions-mode=llm-single-step \
--llm-profile=anthropic-claude-3.5-sonnet \
--bench-type validating \
--tries 10 \
--runs 5 \
--verifier-command="dafny verify --verification-time-limit 20" \
--filter-by-ext dfy \
--output-logging \
--dir benches/HumanEval-Dafny \
--modes mode1 mode2 mode3 mode4 mode5 mode6 \
--prompts-directory prompts/dafny_eval prompts/dafny_eval prompts/dafny_eval_without_impls prompts/dafny_eval_without_impls_textd prompts/dafny_eval_without_impls_textd prompts/dafny_eval_without_impls_textd
2 changes: 1 addition & 1 deletion verified_cogen/args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
import os
from typing import Optional, no_type_check, List
from typing import List, Optional, no_type_check

from verified_cogen.tools.modes import VALID_MODES

Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/experiments/incremental_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from verified_cogen.args import ProgramArgs, get_default_parser
from verified_cogen.llm.llm import LLM
from verified_cogen.main import make_runner_cls, construct_rewriter
from verified_cogen.main import construct_rewriter, make_runner_cls
from verified_cogen.runners import RunnerConfig
from verified_cogen.runners.languages import AnnotationType, register_basic_languages
from verified_cogen.tools import (
Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/runners/languages/language.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import abstractmethod
from enum import Enum
from typing import Any, Pattern, List, Tuple
from typing import Any, List, Pattern, Tuple


class AnnotationType(Enum):
Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/runners/languages/nagini.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Pattern, List, Tuple
from typing import List, Pattern, Tuple

from verified_cogen.runners.languages.language import AnnotationType, GenericLanguage
from verified_cogen.tools.pureCallsDetectors import detect_and_replace_pure_calls_nagini
Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/runners/rewriters/nagini_rewriter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, List
from typing import List, Tuple

from verified_cogen.runners.rewriters import Rewriter

Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/runners/rewriters/nagini_rewriter_fixing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, Optional, Dict, List
from typing import Dict, List, Optional, Tuple

from verified_cogen.runners.rewriters.__init__ import Rewriter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Tuple, Optional
from typing import Optional, Tuple

from verified_cogen.runners.rewriters.__init__ import Rewriter
from verified_cogen.tools.inequality_replacer import (
replace_inequalities,
contains_double_inequality,
replace_inequalities,
)


Expand Down
2 changes: 1 addition & 1 deletion verified_cogen/runners/validating.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, List
from typing import List, Optional

from verified_cogen.llm import prompts
from verified_cogen.llm.llm import LLM
Expand Down
4 changes: 4 additions & 0 deletions verified_cogen/several_modes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from verified_cogen.several_modes.several_modes import main

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion verified_cogen/several_modes/args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
import os
from typing import Optional, no_type_check, List
from typing import List, Optional, no_type_check

from verified_cogen.tools.modes import VALID_MODES

Expand Down
54 changes: 54 additions & 0 deletions verified_cogen/several_modes/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from verified_cogen.runners.languages import AnnotationType

MODE_MAPPING = {
"mode1": [AnnotationType.INVARIANTS, AnnotationType.ASSERTS],
"mode2": [
AnnotationType.INVARIANTS,
AnnotationType.ASSERTS,
AnnotationType.PRE_CONDITIONS,
AnnotationType.POST_CONDITIONS,
],
"mode3": [
AnnotationType.INVARIANTS,
AnnotationType.ASSERTS,
AnnotationType.IMPLS,
],
"mode4": [
AnnotationType.INVARIANTS,
AnnotationType.ASSERTS,
AnnotationType.IMPLS,
],
"mode5": [
AnnotationType.INVARIANTS,
AnnotationType.ASSERTS,
AnnotationType.PRE_CONDITIONS,
AnnotationType.POST_CONDITIONS,
AnnotationType.IMPLS,
],
"mode6": [
AnnotationType.INVARIANTS,
AnnotationType.ASSERTS,
AnnotationType.PRE_CONDITIONS,
AnnotationType.POST_CONDITIONS,
AnnotationType.IMPLS,
AnnotationType.PURE,
],
}

REMOVE_IMPLS_MAPPING = {
"mode1": False,
"mode2": False,
"mode3": True,
"mode4": True,
"mode5": True,
"mode6": True,
}

TEXT_DESCRIPTIONS = {
"mode1": False,
"mode2": False,
"mode3": False,
"mode4": True,
"mode5": True,
"mode6": True,
}
Loading

0 comments on commit 27c3195

Please sign in to comment.