Skip to content

Initial migration of mobius package - #3

Merged
justinchuby merged 4 commits into
mainfrom
justinchu/migration
Mar 18, 2026
Merged

Initial migration of mobius package#3
justinchuby merged 4 commits into
mainfrom
justinchu/migration

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Migrated from onnx-genai-models with full rename:

  • PyPI package: mobius-ai
  • Python import: mobius
  • CLI command: mobius

Migrated from onnx-genai-models with full rename:
- PyPI package: mobius-ai
- Python import: mobius
- CLI command: mobius

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@github-actions

github-actions Bot commented Mar 18, 2026

Copy link
Copy Markdown

Performance Comparison

Model Metric Baseline Current Delta
bert model_size_bytes 359 KB 359 KB +0.0%
bert num_nodes 61 61 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 109 107 -1.8%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 60 60 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 68 68 +0.0%
mamba model_size_bytes 360 KB 360 KB +0.0%
mamba num_nodes 109 109 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 68 68 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 68 68 +0.0%
t5 model_size_bytes 836 KB 836 KB +0.0%
t5 num_nodes 174 174 +0.0%
whisper model_size_bytes 1008 KB 1008 KB +0.0%
whisper num_nodes 140 140 +0.0%

No performance regressions.

@github-actions

github-actions Bot commented Mar 18, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Model Sub-model Changes Status

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby merged commit cc1fc14 into main Mar 18, 2026
4 of 16 checks passed
@justinchuby
justinchuby deleted the justinchu/migration branch March 18, 2026 00:19
justinchuby added a commit that referenced this pull request Apr 13, 2026
Issue #1: Add 2D RoPE to Gemma4VisionSelfAttention with precomputed
cos/sin lookup tables (rope_theta=100.0, head_dim//2 frequencies).
First head_dim//2 dims use x-coord rotation, last use y-coord rotation,
matching HF apply_multidimensional_rope.

Issue #2: Add Gemma4VisionPooler with 3x3 AveragePool to reduce N patches
to N/9 before projector. Scales by sqrt(hidden_size) matching HF pooler.
Adds pooling_kernel_size to VisionConfig (default 3).

Issue #3: Gemma4VisionEncoderLayer now reads hidden_act from VisionConfig
(default gelu_pytorch_tanh) instead of hardcoding silu. Adds hidden_act
to VisionConfig.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
justinchuby added a commit that referenced this pull request May 4, 2026
… tests (#240)

Addresses 4 review comments from PR #239:

### 1. GQA rewrite rule head_dim limit (#1)
Updated `_MAX_GQA_HEAD_DIM` from 256 to 512 in the Attention→GQA rewrite
rule to match latest ORT support for head_dim=512.

### 2. GGUF path missing `attention_k_eq_v` (#2)
Added `attention_k_eq_v=True` to Gemma4 GGUF postprocessor when
`num_global_key_value_heads` is detected. Fixes `build_from_gguf()` for
26b-a4b/31b checkpoints.

### 3. DRY expert weight rename (#3)
Extracted `_remap_moe_expert_weights()` shared helper used by both
`Gemma4CausalLMModel.preprocess_weights()` and
`Gemma4Model.preprocess_weights()`. Single source of truth for expert
rename + router scale folding.

### 4. Missing multimodal preprocess_weights test (#4)
Added `gemma4_test.py` with 5 targeted tests covering both
`Gemma4CausalLMModel` and `Gemma4Model` weight preprocessing: expert
rename, router scale folding, and per_expert_scale passthrough.

### Testing
- 5/5 new preprocess_weights tests pass
- 2668/2668 full suite pass

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
titaiwangms added a commit that referenced this pull request Jun 5, 2026
Addresses the Copilot-bot findings from the #340 review assessment:

- COPILOT #3 (completes the M3 is_causal=1 sweep): build_graph_test.py
  test_static_cache_graph_inputs had a stale inline comment claiming causal
  masking is "handled by is_causal=1 on the Attention op". Updated to the
  shipped reality (is_causal=0 + explicit offset-aware mask from write_indices).
  The is_causal=1-mention sweep is now complete across _causal_lm.py (:64,
  Falcon block) + build_graph_test.py (the remaining :4561/:4610 mentions are
  correct references to the *rejected* old form, not stale claims).

- COPILOT #1 + #2 (indentation): the two negative-control assertions in the
  decode-frontier and prefill-causal tests were dedented outside their
  `with tempfile.TemporaryDirectory()` block. Moved them back inside.

- Negative-control comparison semantics: reverted the three "logits MUST change"
  negative controls to exact `assert not np.array_equal` (any bit of change
  proves the slot was attended). The np.array_equal -> assert_allclose
  conversion correctly applies ONLY to the "logits UNCHANGED" equality/parity
  checks, which keep the fp-tolerance compare. Applied consistently to the new
  batch>1 per-batch mask test as well, and clarified the tolerance-constants
  comment.

Lint clean; static-cache decode 4/4 (CUDA) and build_graph static-cache 10/10
green.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
justinchuby added a commit that referenced this pull request Jun 12, 2026
…al batch=1

Root cause (PR review finding #3): create_padding_mask and
create_sliding_window_mask returned a 3-D (batch, q_len, total) bool mask.
The ONNX Attention op right-aligns the mask onto
(batch, q_num_heads, q_seq, kv_seq), so the batch axis was read as
q_num_heads — harmless for batch==1 (broadcasts as heads=1) but ORT
rejects batch>1 ('attn_mask ... not compatible with q_num_heads'). Text
decoders therefore silently only supported batch=1 despite declaring a
symbolic batch dim.

Fix: both maskers now emit a 4-D (batch, 1, q_len, total) mask with an
explicit singleton head dim (create_attention_bias already did this).
batch==1 output is numerically identical (extra unit dim only).

Verified batch=2 prefill (with ragged per-row padding) runs and produces
independent rows for qwen2/llama/mistral/gemma2 (plain, GQA,
sliding-window). Added:
- _common_test.py: 4-D rank + per-row independence tests for both maskers.
- build_graph_test.py: TestTextDecoderBatchGreaterThanOne ORT batch=2 test.

Multimodal contract honesty: the VLM decoder now genuinely supports
batch>1, but the multimodal splits (gemma3 vision Squeeze([0]); phi4mm
scalar vision_gate/speech_gate + single flattened feature stream) remain
batch=1. Documented those preconditions explicitly. True multimodal
batch>1 (per-row modalities, ragged features) is tracked as a follow-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
titaiwangms added a commit that referenced this pull request Jun 22, 2026
Fix justinchuby's non-blocking review nits (PR #367):

- _dense_reference docstring: correct the stale claim that a fully-masked
  query row 'yields exactly 0'. The bias-MEA contract keeps every query
  row's own diagonal slot valid, so a fully-masked row is unreachable by
  design — the impl asserts idx.size > 0 rather than returning 0. Align
  the docstring with the assertion (assertion unchanged).

- Graph-wiring assertions: read the is_causal attribute via the as_int()
  convention used in tests/build_graph_test.py and assert the attribute is
  present (not None) before reading it. For the bias-on case, assert the
  additive bias (Attention input #3) is both non-None and non-empty
  (name != '').

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: titaiwang <titaiwang@microsoft.com>
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