Merged
Conversation
New --student and --moe-experts flags on infer command. Loads model → converts to CpuBlockAttnResModel (ternary base) → optional MoE expansion → autoregressive generation. generate_student() function: full forward per step with logging. Memory diagnostic reports ternary footprint on load. [3da81652]
9f8c141 to
25f4438
Compare
shift
added a commit
that referenced
this pull request
Apr 22, 2026
…ontention (#63) rayon par_iter on 35 layers caused memory bandwidth saturation on 32GB system with 10GB mmap + 4GB student model. Sequential conversion is faster because single thread has exclusive bandwidth access. Conversion: 770s (rayon) → expected ~470s (sequential, matching PR #60) Prefill: 123s (rayon build) → expected ~42s (matching PR #60) Keep rayon for ternary_matmul_parallel() only (small matrices, no contention).
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.
Ternary Student Inference Path
Summary
Adds
--studentand--moe-expertsflags to theinfercommand for end-to-end inference through the FerrisRes student model (ternary base + optional MoE).Usage
Pipeline
gemma4_to_block_attnres()→ ternaryCpuBlockAttnResModeldense_ffn_to_moe()→ MoE expansion (2 or 4 experts)generate_student()→ autoregressive generation with per-step loggingMemory
All base weights are ternary {-1, 0, +1} from creation:
New code
generate_student(): autoregressive generator forCpuBlockAttnResModelcmd_infer()with memory diagnostics--student/--moe-expertsCLI flagsDepends on #59 (ternary-everywhere refactor).
[3da81652]