Skip to content

[3/4] Andes batch prediction bridge and student distillation - #12

Open
singjc wants to merge 16 commits into
developfrom
stack/03-andes-batch-distill
Open

singjc wants to merge 16 commits into
developfrom
stack/03-andes-batch-distill

Conversation

@singjc

@singjc singjc commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Stack 3/4 (base: stack 2)

Andes batch prediction bridge and student distillation.

  • Versioned YAML batch prediction bridge for Andes, with v0.52 and v0.35 research checkpoints
  • v0.52 inference speedups: constant weights, a single trunk pass, dedup, parallel and length-sorted batches, dynamic padding, no per-call weight repacking, and opt-in --fast-math fused LayerNorm
  • foundation_distill example: trains a small or medium student on cached teacher labels, with opt-in task_weights
  • Andes peptide Form adapter and a typed UINT32 Foundation tensor boundary

Consolidates the non-featurizer part of feature/foundation-distill (rebased from an old develop). Left out: docs-only result-log commits, and a duplicate ONNX encoder lowering in src/onnx_export.rs that stack 2 supersedes and that depended on a missing local path.

Integration fix on top (fix(foundation): adapt batch bridge and distillation to the stack 2 APIs):

  • prediction_record moved to runtime, and the example now uses the research pair loader because stack 2 removed the legacy FoundationPredictor
  • Specialist config gained size fields, which now take their defaults
  • The tensor batch validator was missing the instrument_present length. This was a latent bug on the original branch.

Verified: cargo check --workspace --all-targets with onnx-export is clean, and cargo test -p redeem-properties --features onnx-export --lib gives 239 passed, 0 failed, 2 ignored.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

CodeRabbit ASCII loading animation

Currently processing new changes in this PR. This may take a few minutes, please wait...

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 82faabe4-696c-44d6-b35a-dd7febcf4a95
Commits

Reviewing files that changed from the base of the PR and between 65b5a27 and ef29855.

Files selected for processing: 19

  • redeem-properties/examples/foundation_batch_predict.rs
  • redeem-properties/examples/foundation_batch_request.yaml
  • redeem-properties/examples/foundation_distill.rs
  • redeem-properties/src/foundation/andes.rs
  • redeem-properties/src/foundation/batch_prediction.rs
  • redeem-properties/src/foundation/distill.rs
  • redeem-properties/src/foundation/featurize.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0270.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0310.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0350.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0360.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0500.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0510.rs
  • redeem-properties/src/foundation/historical_checkpoints/multimodal_v0520.rs
  • redeem-properties/src/foundation/layers.rs
  • redeem-properties/src/foundation/mod.rs
  • redeem-properties/src/foundation/model.rs
  • redeem-properties/src/foundation/research_v0520.rs
  • redeem-properties/src/foundation/runtime.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@singjc
singjc added this pull request to stack #14 December 3, 2026 14:06
@singjc
singjc force-pushed the stack/03-andes-batch-distill branch from 058324c to dffa646 Compare December 3, 2026 15:07
@singjc

singjc commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@singjc
singjc force-pushed the stack/03-andes-batch-distill branch from e01ba68 to 113053f Compare December 3, 2026 16:41
@singjc

singjc commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 21 minutes.

@singjc
singjc force-pushed the stack/03-andes-batch-distill branch from 113053f to 7fe1ed1 Compare December 3, 2026 17:40
@singjc

singjc commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 55 minutes.

Base automatically changed from stack/02-foundation-onnx-export to develop December 3, 2026 17:54
singjc added 16 commits December 3, 2026 12:54
…l batches

Outputs byte-identical to the previous bridge on test requests.
- Load research weights via mmaped safetensors (no Var autograd tracking): RSS 3.6 GB -> 0.4 GB at batch 4.
- property_and_mobility_t runs the v0.50 trunk once for RT/MS2/CCS (was twice, plus two collates).
- Bridge predicts identical model inputs once and runs batches on the rayon pool.
The v0.50 trunk, v0.52 refinement and v0.35 teacher run at the batch width
instead of 64; features keep max_sequence_len as normalizer, MS2 is padded back
to 63 cleavages. Predictions identical (max abs diff 0) on 256 real PXD003881
peptidoforms; 56 s -> 7.5 s at batch 1, 16 threads.
…ches

layers::Linear flattens 3D/4D inputs to 2D and multiplies by a weight transposed
once at load (only for non-Var weights; single-row and 2D inputs keep candle's
path). Bit-identical to candle_nn::Linear (unit test) and on 256 real PXD003881
peptidoforms; ~1.3x less CPU. The bridge also sorts unique inputs by length
before batching so batch>1 pads only to near-equal peptides.
Off by default (outputs stay bit-identical). With --fast-math the bridge uses
candle's fused layer_norm row kernel for non-Var weights: ~1.2x less CPU on
256 real PXD003881 peptidoforms, max drift RT 3e-5, CCS 4e-4, MS2 2e-6.
MKL backend was tried and dropped: candle 0.8.4 + intel-mkl-src fails to link
(undefined hgemm_).
…bels

foundation::distill: teacher_labelled_records (any PredictionModel teacher, e.g.
v0.52 research stack), distill_foundation_student (small ResidueTransformer
FoundationModel, supervised RT/CCS/MS2 on teacher predictions, deterministic
holdout fidelity report), small_student_config. Training and inference crop
each batch to its longest peptide (width-invariance unit test).
examples/foundation_distill: CLI over a batch-request peptide list.
distill_from_records / labelled_record split labelling from training.
Batch responses deserialize, so a foundation_batch_predict response serves as a
cached label file (foundation_distill --labels). --train-threads caps training:
the small student does not scale past ~2 threads (rayon steal overhead).
prediction_record now lives in runtime, the specialist config gained size
fields (use defaults), and the tensor batch validator was missing the
instrument_present length.
… bridge

The training collator marks instrument_present only for ids > 0 (id 0 is the
learned unknown category). The bridge marked Some(0) as present, feeding the
model a context combination it never saw in training.
@singjc
singjc force-pushed the stack/03-andes-batch-distill branch from 7fe1ed1 to ef29855 Compare December 3, 2026 17:54
@singjc

singjc commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Action performed

Full review triggered.

This branch has not been deployed

No deployments
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