Repository navigation
Vela 3.0 (vela3-fast) on Core ML: decisions, PII and unsupported-claim spans - #40
Merged
Merged
Conversation
…m spans Vela3Manager runs vllm-sr/vela3-fast (UltraBERT-380M) from FluidInference/vela-3.0-coreml: decisions over named options (choice / yes-no about a state) on the decision backbone, and the span_sets adapter's two label sets (17 PII types, words of an answer its context does not support). One encoder pass per question, GPU. - Vela3Tokenizer: byte-level BPE with Hugging Face offsets (no trimming: the post-processor is TemplateProcessing; pieces of a multi-byte character share its offsets). - Rendering, readout and thresholds follow the release's vela3_encoder.py / vela3_schema.py; span assembly, word units and the decoder reuse the Vela 2.0 Swift code (the release copied that Python verbatim). - Vela2Heads gains init(weights:) (Vela 3 ships safetensors heads; the decision head set has no span temperature). - Vela3ModelStore pins revision deaf348c with per-file SHA-256. - Vela3Check parity vs the Python runtime on the same encoders: 0 token mismatches on 17 Unicode-heavy texts, 0 / 120 decisions and 0 / 12 span sets differ. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…alidation) - Long span inputs follow the release's assemble/_windows with a 1,024-token pass: the other part (an unsupported-claim context) is cut first (to 64 tokens, then 1), then the target is read in overlapping windows, each window re-fitted (a short last window gives the context its room back); per-word logits are averaged over windows (-30 where uncovered). - Tokenizer: added tokens honour lstrip / rstrip (<|mask|> absorbs the whitespace before it, as HF); BPE merges via a (rank, position) min-heap instead of a quadratic rescan; long pieces are not cached. - Core ML: hidden states go into an output backing with a synchronous prediction. With Core ML allocating the output, the first GPU prediction on a cold compile cache aborted in MPSGraphTensorData (shape.count = 0 != strides.count = 3) in ~1 of 3 cold runs; with the backing 0 of 20 (12 cold, 8 under a launcher that crashed 3 of 3). - Validation: heads tensor shapes (span heads must carry w_t / w_e / log_tau_span), safetensors bounds, hidden-state shape, pii_buckets, duplicate option names; heads errors surface as Vela3Error. - The label schema is tokenized once at load. - Vela3Check: compares every window's sequence and span probabilities, fails on probability drift (> 1e-3), adds a `warm` cold-start command; fixtures add <|mask|>, a 3,000-letter word, 2- and 9-window PII and long contexts. Parity vs the Python runtime: 0 / 23 token, 0 / 120 decision and 0 / 16 span-set mismatches (29 windows, 599 spans), max |dp| 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Vela3Managerruns vllm-sr/vela3-fast (Vela 3.0, UltraBERT-380M, Apache-2.0) from the newFluidInference/vela-3.0-coreml snapshot:
Vela3Decision.mlpackage, L128–L1024).span_setsadapter (LoRA merged,Vela3SpanSets.mlpackage, L512 / L1024): 17 PII types, and the words of an answer its context does not support.One encoder pass per question on the GPU. The Neural Engine is slower for this encoder at every length and drifts further from fp32 (15 / 1,200 decisions flipped), so it is not used.
How
Vela3Tokenizer: byte-level BPE reproducing Hugging Facetokenizersoffsets.TemplateProcessing.lstrip/rstripspecial tokens absorb the whitespace next to them.vela3_encoder.DecisionEncoder.assemble/_windowswithin a 1,024-token pass:vela3_config.json: set-adapter temperature, PII thresholds by input length, and the unsupported-claim threshold.Vela2Heads.init(weights:span:)was added so both models share the readout. It validates tensor shapes, and Vela 2 values are unchanged.Vela3ModelStoreis pinned to revisiondeaf348cwith a SHA-256 for every file.Checks
swift run -c release Vela3Check parity <model dir> <fixtures.json>against the Python runtime of the HF repo (vela3_coreml.py, same encoders, the release's own code). Fixtures come fromconversion/fixtures.pyin the HF repo. They cover emoji ZWJ sequences and flags, CJK, Arabic, Cyrillic, CRLF, URLs,<|mask|>and a 3,000-letter word; 2- and 9-window PII; and long contexts and answers.The check now fails on probability drift above 1e-3, not only on changed answers. The Python runtime itself matches fp32 PyTorch: 0 / 1,200 typed decisions differ, and PII span sets are identical on 25 passages (HF
reports/verify.txt).Built in release mode:
Vela3Check,Vela2Check,GuardrailDemo, andFrontDoorDemo(with the Xcode toolchain; the CommandLineTools toolchain lacks the SwiftUI macro plugin, and that predates this PR).Core ML cold-start abort (fixed here)
When Core ML allocated the output, the first GPU prediction on a cold compile cache aborted inside
MPSGraphTensorData(shape.count = 0 != strides.count = 3). This happened in about 1 of 3 cold runs, insideMLE5Engine, with either the sync or the async prediction API (macOS 27.0).With a preallocated output backing and synchronous prediction it happened 0 of 20 times: 12 cold runs, plus 8 under a launcher that had crashed 3 of 3.
Vela2Manageruses the same async, Core ML-allocated output pattern; it may be worth the same change in a follow-up.Review
A
/code-reviewpass found 15 issues. Fixed in 7792562:<|mask|>lstrip;pii_bucketsvalidation;Not changed: the model-store,
encodeand byte-table duplication, which follows the existing per-model pattern across FluidUse (a shared helper would be a repo-wide refactor), and the hard-coded function lengths (the snapshot is pinned).🤖 Generated with Claude Code