Skip to content

Add SmolLM2 and SmolLM3 on iron.lm - #255

Open
hunhoffe wants to merge 1 commit into
resnet-yoloxfrom
smollm-family
Open

hunhoffe wants to merge 1 commit into
resnet-yoloxfrom
smollm-family

Conversation

@hunhoffe

Copy link
Copy Markdown
Collaborator

Stacked on #253. a0162c7 kept #222 to the library, Llama, EmbeddingGemma 2 and Gemma 4, moving eighteen applications to follow-up pull requests. This is the SmolLM family's: SmolLM2 is Llama's architecture at its own shape; SmolLM3 is Llama's layer with RoPE skipped on every fourth layer (NoPE).

  • SmolLM2 1.7B Instruct (iron/applications/smollm2/) restored unchanged, with its own test.py (generation, accuracy, determinism, chat turn, and a TestEachStep class for npu1) and toy golden.
  • SmolLM3 3B (iron/applications/smollm3/) restored, and brought to the same npu1-compile standing Granite 4.0-H 1B got in Granite 4.2 3B and Granite 4.0-H 1B #249: an empty npu1.json profile, and a new test.py holding only its per-step TestEachStep class. Its full-ELF generation, accuracy and determinism already run through tests/applications/decoders and long_context, beside Gemma 3, Gemma 4, Qwen3.5 and Qwen3-MoE. Its config gains precision=Precision.HIGH, as 3B's other dense decoder (Llama 3.2 3B) and Granite 4.2 3B are.
  • Wired SmolLM3 into tests/applications/decoders and both SmolLM2 and SmolLM3 into tests/applications/long_context, the way Qwen3's family was in Add Qwen3, Qwen3-Embedding, Qwen3-Reranker and Qwen3-MoE on iron.lm #251.
  • README's model table gets both rows.

Measured (Strix Halo, npu2)

SmolLM3's per-step form (TestEachStep): generation passes; determinism passes (0 differing runs over 3 draws); accuracy KL(fp32 CPU || NPU) over 20 steps mean 0.0045, p90 0.012, max 0.019, 2 top-1 swaps, well under the 0.02/0.04/0.08 bound. Its missing each-step golden row (20 steps, a 256-character prompt) is recorded, device-free.

SmolLM2 and SmolLM3's shortest call (13-token prompt, 1 token) both pass on npu2.

npu1

SmolLM3 compiles for npu1 with no device bound (TestEachStep, device-free). Its real npu1 run is CI's Phoenix runner, as Granite 4.0-H 1B's and both models' long_context deep checks are.

CI

Checked: black, reuse lint clean. Device-free: reference suites (smollm2 6, smollm3 7) and long_context's test_every_decoder_application_is_held_to_its_context pass.

Each runner needs smollm2-1.7b-instruct/ and smollm3-3b/ under /srv; staging zip not yet built for this PR.

@hunhoffe
hunhoffe requested a balanced review from Copilot October 29, 2026 02:41
@hunhoffe
hunhoffe changed the base branch from devel to resnet-yolox October 29, 2026 02:41
@hunhoffe
hunhoffe added this pull request to stack #252 October 29, 2026 02:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

SmolLM2 and SmolLM3 tests omit explicit model release, allowing reference cycles to retain multi-GB device buffers and overlap subsequent model allocations.

3 open issues
What changed in this PR

Restores SmolLM2 and SmolLM3 on the shared iron.lm decoder infrastructure, with device profiles, reference checks, and application tests.

Changes:

  • Adds Llama-based SmolLM2 and SmolLM3 with selective RoPE disabling and high-precision projections.
  • Adds model-specific tests and extends shared decoder and long-context coverage.
  • Documents both models, their checkpoint requirements, and device profiles.
File Description
tests/​applications/​smollm3/​test.py Adds per-step generation, accuracy, and determinism checks.
tests/​applications/​smollm3/​reference/​test.py Adds toy reference and NoPE configuration validation tests.
tests/​applications/​smollm2/​test.py Adds generation, accuracy, sampling, chat, and per-step checks.
tests/​applications/​smollm2/​reference/​test.py Adds toy reference checks using the shared decoder suite.
tests/​applications/​long_context/​test.py Registers both models for long-context checks.
tests/​applications/​decoders/​test.py Registers SmolLM3 for shared decoder tests.
README.md Adds both models to the application catalog.
iron/​applications/​smollm3/​README.md Documents architecture, profiles, tests, and checkpoint files.
iron/​applications/​smollm3/​profiles/​npu2.json Sets four attention pipelines for decode and prefill.
iron/​applications/​smollm3/​profiles/​npu1.json Adds an empty profile using operator defaults.
iron/​applications/​smollm3/​model.py Defines SmolLM3 configuration and selective RoPE disabling.
iron/​applications/​smollm3/​__init__.py Exposes SmolLM3 through lazy exports.
iron/​applications/​smollm2/​README.md Documents architecture, context costs, and checkpoint files.
iron/​applications/​smollm2/​profiles/​npu2.json Adds an empty profile using operator defaults.
iron/​applications/​smollm2/​profiles/​npu1.json Adds an empty profile using operator defaults.
iron/​applications/​smollm2/​model.py Specializes Llama with SmolLM2-specific profiles.
iron/​applications/​smollm2/​__init__.py Exposes SmolLM2 through lazy exports.

Review effort: Balanced

@pytest.fixture(scope="module")
def model(load):
"""The model, compiled and loaded once."""
yield load()
Comment on lines +81 to +82
if aie_utils.DefaultNPURuntime is not None:
aie_utils.DefaultNPURuntime.cleanup()
Comment on lines +43 to +44
if aie_utils.DefaultNPURuntime is not None:
aie_utils.DefaultNPURuntime.cleanup()
a0162c7 kept #222 to the library, Llama, EmbeddingGemma 2 and Gemma 4,
moving eighteen applications to follow-up pull requests. This is the
SmolLM family's: SmolLM2 is Llama's architecture at its own shape;
SmolLM3 is Llama's layer with RoPE skipped on every fourth (NoPE).

- SmolLM2 1.7B Instruct (iron/applications/smollm2) restored unchanged,
  with its test.py (TestEachStep included) and toy golden.
- SmolLM3 3B (iron/applications/smollm3) restored, and brought to the
  same npu1-compile standing granite_hybrid got in #249: an empty
  npu1.json profile, and a new test.py holding only its per-step
  TestEachStep (its full-ELF generation, accuracy and determinism
  already run through the decoders and long_context suites, beside
  Gemma 3, Gemma 4, Qwen3.5 and Qwen3-MoE). Its config gains
  precision=Precision.HIGH, as 3B's other dense decoder (Llama 3.2 3B)
  and Granite 4.2 3B are.
- Wired SmolLM3 into tests/applications/decoders and both SmolLM2 and
  SmolLM3 into tests/applications/long_context, the way Qwen3's family
  was in 8ae0479.
- README's model table gets both rows.

Checked: black, reuse lint clean; device-free reference suites
(smollm2 6, smollm3 7) and long_context's
test_every_decoder_application_is_held_to_its_context pass. On npu2
(Strix Halo): smollm2's shortest call and smollm3's shortest call (in
decoders) pass; smollm3's per-step form (TestEachStep) passes
generation, determinism (0 differing runs), and accuracy (KL mean
0.0045, p90 0.012, max 0.019 over 20 steps, 2 top-1 swaps), its
missing each-step golden row recorded device-free for this. SmolLM3
compiles for npu1 with no device bound; its real npu1 run is CI's
Phoenix runner.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

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.

2 participants