mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[GH-ISSUE #535] [v2.0.0.dev0] Crash in non-interactive mode after optimization completes (EOFError from prompt_toolkit) #230
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#230
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @instax-dutta on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/535
[v2.0.0.dev0] Crash in non-interactive mode after optimization completes (EOFError from prompt_toolkit)
Summary
Heretic v2.0.0.dev0 crashes with an
EOFError/PermissionErrorfromprompt_toolkitwhen running in non-interactive environments (e.g.,nohup,script, CI, piped stdin) after the Optuna optimization finishes. This prevents saving the abliterated model, uploading to HuggingFace, or continuing the post-optimization workflow without a TTY.Environment
heretic-llm-2.0.0.dev0(installed fromgit+https://github.com/p-e-w/heretic.git)LiquidAI/LFM2.5-230MReproduction
Observed Behavior
After "Optimization finished!" and displaying Pareto optimal trials, Heretic tries to prompt interactively and fails:
Full traceback (from logs):
See attached logs:
run3_20261030_032306.log,additional_cont_*.logetc. in test artifacts.Expected Behavior
--trial-index,--model-action,--save-directorywithout prompting, or--non-interactive/--yesflags or detect non-TTY (sys.stdin.isatty())Additional Context
Dependency installation issues (for v2.0 testing)
The v2.0 pre-release has strict dependency requirements that caused conflicts during installation:
transformers[torch]~=5.18,peft~=0.21,huggingface-hub~=1.33,datasets~=5.0kernelspackage and some transitive depsTesting results (for context)
We ran 450+ trials across 3 runs testing
LiquidAI/LFM2.5-230M. Best configuration found: Trial 82 with KL=0.038817, Refusals=8/100 which outperforms the user's v1.4.0 baseline (KL 0.0548, 10/100 refusals). The optimization/search functionality works well; the issue is purely the post-optimization interactive flow in non-TTY environments.Suggested Fix
In
heretic/main.pyaround the trial selection/saving logic, check if running interactively (sys.stdin.isatty()and/orsys.stdout.isatty()). If not interactive and required parameters aren't provided, either:--trial-index,--model-action,--save-directoryflags fullyThis would make the v2.0 pre-release testable as instructed in the announcement.
@p-e-w commented on GitHub (Oct 30, 2026):
Please elaborate. How are they currently not respected "fully"?
@instax-dutta commented on GitHub (Oct 30, 2026):
We hit this in scripted/headless runs with stdin closed (e.g.
timeout ... heretic ... |& tee logor when stdin is/dev/null). In that environment,stdin.isatty()is False - questionary/prompt_toolkit can still try to prompt in the post-optimization flow and raiseEOFError. Even if flags like--trial-index,--model-action,--save-directory/--upload-repo-idare passed, in our case it crashed after optimization when trying to select a trial/action.The fix is to detect non-TTY/EOF early and fall back to CLI-provided values (or sensible defaults like first Pareto trial + auto-select save/upload based on flags) instead of letting the prompt raise EOFError. PR #537 does this defensively. Happy to adjust if there's a specific pattern the tests expect.