Skip to content

docs(tutorials): ternary networks getting started (Pi-native, 16x smaller weights) - #1163

Merged
michalharakal merged 1 commit into
developfrom
feature/1141-ternary-getting-started
Aug 26, 2026
Merged

michalharakal merged 1 commit into
developfrom
feature/1141-ternary-getting-started

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Part of #1141 / #1136. Best merged after #1161 (the tutorial's bridge table names JniTernaryF32Gemv / NativeKnTernaryF32Gemv from that PR; everything else stands on already-merged code).

What

New tutorial tutorials/ternary-getting-started.adoc (registered in nav): the user-facing story for the ternary f32 path —

  1. define the classifier with the stock sequential { } DSL (unchanged),
  2. train FP32, ternarize with TernaryCodec.encodeBitNet — layout diagram + memory table (~397 KB → ~25 KB for the MNIST-shaped MLP, ≈16×),
  3. dispatch through the exact kernel via the weight format (no model/DSL/dispatcher changes — the architecture-proof-point story from Ternary f32 LUT gemv — vendored NeoGPU kernel: exact FP32×b1.58 matmul for baseline-NEON ARM (Pi-4/A72) #1136),
  4. deploy natively on a Raspberry Pi 4 (linuxArm64 + NativeKnTernaryF32Gemv.install()), with the Android/JVM one-liners alongside,
  5. honest expectations (upstream Pi-4 GOPS numbers, internal threading ≥512 rows, post-training-ternarization accuracy note) and status/roadmap ([ternary-f32] Phase 4: GGUF I2_S (type 36) import with group→sequential repack, keep-packed BITNET_B1_58 #1140, [ternary-f32] Phase 5: benchmark scenario + docs #1141, transformers#335).

API change

NativeTernaryF32GemvKernel (FFM) goes internal → public so the JVM row of the bridge table is true — the same public install() surface its JNI and Kotlin/Native siblings already have. Verified: ternary jvmTest suite green after the change.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-1163 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

…a Pi

The user-facing walkthrough for the vendored NeoGPU ternary path (#1136):
train a sequential-DSL classifier in FP32, ternarize with
TernaryCodec.encodeBitNet (~16x smaller weights, exact math), and run it
natively on a Raspberry Pi 4 through the linuxArm64 cinterop bridge — one
install() call per deployment shape, no changes to model code or the
dispatcher. Includes the BITNET_B1_58 layout, the memory arithmetic, honest
accuracy/threading expectations, and the status/roadmap (#1140, #1141,
transformers#335).

NativeTernaryF32GemvKernel goes internal → public so the JVM row of the
bridge table is true — the same install() surface JniTernaryF32Gemv and
NativeKnTernaryF32Gemv already expose publicly.

Refs #1141, #1136

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michalharakal
michalharakal force-pushed the feature/1141-ternary-getting-started branch from f707c65 to db16a91 Compare August 26, 2026 11:07
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-1163 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal
michalharakal merged commit dababc0 into develop Aug 26, 2026
20 checks passed
@michalharakal
michalharakal deleted the feature/1141-ternary-getting-started branch August 26, 2026 11:25
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