优化engine
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
CDSL → STEP 重建管道
|
||||
====================
|
||||
优先: CDSL → sketch_solver → llm_compiler → llm_engine (engine=cdsl_only)
|
||||
优先: CDSL → capability planner → session runtime → STEP (engine=cdsl_only)
|
||||
回退: CDSL + compiler_context → translator
|
||||
"""
|
||||
|
||||
@@ -41,7 +41,7 @@ def run_rebuild(cdsl: dict[str, Any], out_step: Path, ctx_file: Path | None = No
|
||||
cdsl_only_error: Exception | None = None
|
||||
if all_drawable and not force_exact:
|
||||
try:
|
||||
return _run_cdsl_only(cdsl, out_step, gold_step=gold_step)
|
||||
return run_cdsl_only(cdsl, out_step, gold_step=gold_step)
|
||||
except Exception as e:
|
||||
cdsl_only_error = e
|
||||
|
||||
@@ -106,23 +106,24 @@ def _sketch_is_cdsl_drawable(sketch: dict[str, Any]) -> bool:
|
||||
return ptype in SHAPE_GENERATORS
|
||||
|
||||
|
||||
def _run_cdsl_only(cdsl: dict[str, Any], out_step: Path, gold_step: Path | None = None) -> dict[str, Any]:
|
||||
"""纯 Learning-IR 路径:CDSL → sketch_solver → llm_compiler → llm_engine。"""
|
||||
t0 = time.time()
|
||||
slim = {k: v for k, v in cdsl.items() if k != "compiler_context"}
|
||||
pack = compile_cdsl(slim)
|
||||
pack.pop("compiler_context", None)
|
||||
result = run_engine_plan(pack, out_step)
|
||||
result["engine"] = "cdsl_only"
|
||||
result["elapsed_s"] = round(time.time() - t0, 1)
|
||||
result.setdefault("log", [])
|
||||
result["log"].append("cdsl_only: sketch_solver + llm_compiler + llm_engine (no compiler_context)")
|
||||
def run_cdsl_only(cdsl: dict[str, Any], out_step: Path, gold_step: Path | None = None) -> dict[str, Any]:
|
||||
"""Pure semantic CDSL path with no compiler_context fallback."""
|
||||
t0 = time.time()
|
||||
try:
|
||||
from .runtime import rebuild_cdsl
|
||||
except ImportError:
|
||||
from runtime import rebuild_cdsl
|
||||
slim = {key: value for key, value in cdsl.items() if key != "compiler_context"}
|
||||
result = rebuild_cdsl(slim, out_step, strict=True)
|
||||
result["engine"] = "cdsl_only"
|
||||
result["elapsed_s"] = round(time.time() - t0, 1)
|
||||
result.setdefault("log", []).append("cdsl_only: capability planner + session runtime (no compiler_context)")
|
||||
if gold_step and gold_step.exists():
|
||||
result["gold_step"] = str(gold_step)
|
||||
return result
|
||||
|
||||
|
||||
def compile_cdsl_to_pack(cdsl: dict[str, Any]) -> dict[str, Any]:
|
||||
def compile_cdsl_to_pack(cdsl: dict[str, Any]) -> dict[str, Any]:
|
||||
pack = compile_cdsl({k: v for k, v in cdsl.items() if k != "compiler_context"})
|
||||
pack.pop("compiler_context", None)
|
||||
return pack
|
||||
|
||||
Reference in New Issue
Block a user