Skip to content

Dev4: ONNX export pipeline for Option A deployment - #32

Merged
sp25-bai-047-wq merged 1 commit into
QuantumLogicsLabs:mainfrom
sp25-bai-047-wq:dev4/onnx-export-deployment
Aug 12, 2026
Merged

Dev4: ONNX export pipeline for Option A deployment#32
sp25-bai-047-wq merged 1 commit into
QuantumLogicsLabs:mainfrom
sp25-bai-047-wq:dev4/onnx-export-deployment

Conversation

@sp25-bai-047-wq

Copy link
Copy Markdown
Collaborator

Summary

Implements the ONNX export path (Option A) for solving the Vercel serverless size limit (~250MB) that currently prevents the neural model from running in production.

What's included

  • inference/grammar.py — torch-free grammar/vocab helpers (is_valid_prefix, NodeValidityPool, vocab loading), split out of beam_search.py so the ONNX deployment path never needs to import torch.
  • inference/beam_search.py — updated to import grammar helpers from the new grammar.py (no logic changes).
  • deployment/export_onnx.py — exports the trained SimpleCalculusModel checkpoint (model/simple_transformer.py) to ONNX format.
  • deployment/onnx_beam_search.py — numpy/onnxruntime-only mirror of inference/beam_search.py's beam search.
  • deployment/onnx_solve.py — torch-free mirror of inference/solve.py's solve() interface, for use in production.
  • deployment/verify_export.py — runs eval/benchmarks/*.json through both the PyTorch and ONNX paths, checks exact-match output parity, measures real deployment bundle size against Vercel's 250MB limit, and writes docs/EXPORT_DECISION.md from the actual measured results.
  • requirements-onnx.txt — lightweight production dependencies (onnxruntime + numpy), deliberately excludes torch.
  • api/_shared.py — added a new priority step in get_solver(): local ONNX model is now tried before the heavier local torch load, falling back to Groq/FallbackSolver as before if unavailable.

Status

Export and verification scripts are ready and tested against the current architecture (model/simple_transformer.py's SimpleCalculusModel). Final numbers in docs/EXPORT_DECISION.md should be regenerated once run against the latest signed-off checkpoint from Developer 3, per the re-validation rule in the task assignment doc.

Testing

  • All new files pass py_compile with no syntax errors.
  • inference/grammar.py functionally tested against the real tokenizer/vocab.json (is_valid_prefix, load_vocab).
  • Existing beam_search.py logic unchanged — only the grammar helpers were relocated.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

@sp25-bai-047-wq is attempting to deploy a commit to the seno-quantum-coder's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sp25-bai-047-wq
sp25-bai-047-wq merged commit 319e357 into QuantumLogicsLabs:main Aug 12, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant