Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

perf(agent): reuse sequence stats option count instead of re-rendering options

Hamidreza0e07dc462005
diff --git a/laya/agent.py b/laya/agent.py
index 67ea7760..a89fded3 100644
--- a/laya/agent.py
+++ b/laya/agent.py
@@ -40,7 +40,6 @@ from .common import (
_disable_question_token_reuse,
encode_text,
render_criterion,
- render_options,
resolve_lang_temperatures,
serialize_state,
temp_bucket,
@@ -1154,7 +1153,7 @@ class Agent(HookRegistry):
self.tok, state, q, max_len, head_max_len, option_order=q.get("option_order"),
truncate_left=truncate_left, state_ids=state_ids, return_stats=True,
return_truncation_stats=True, return_layout=self.parallel_options)
- n_opts = len(render_options(q))
+ n_opts = stats["options"]
if len(markers) != n_opts:
# The markers are placed at absolute positions and `build_sequence` then drops the
# ones past `max_len`, so this is about the question fitting in the sequence --
diff --git a/laya/onnx_agent.py b/laya/onnx_agent.py
index 010190a3..a38f8edf 100644
--- a/laya/onnx_agent.py
+++ b/laya/onnx_agent.py
@@ -22,7 +22,6 @@ from laya.common import (
confidence_from_probs,
encode_text,
render_criterion,
- render_options,
resolve_lang_temperatures,
serialize_state,
window_batch_cap,
@@ -642,7 +641,7 @@ class ONNXAgent(HookRegistry):
truncate_left=truncate_left, state_ids=state_ids, return_stats=True,
return_truncation_stats=True,
)
- n_opts = len(render_options(q))
+ n_opts = stats["options"]
if len(markers) != n_opts:
# Same diagnosis as `Agent._encode_state`, so both backends report the same thing.
# The markers are placed at absolute positions and `build_sequence` drops the ones