# ankitsharma285/inferencescaling-qwen architecture

> Architecture diagram of the GitHub repository ankitsharma285/inferencescaling-qwen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankitsharma285/inferencescaling-qwen
- Repository: https://github.com/ankitsharma285/inferencescaling-qwen

## Overview

InferenceScale-Qwen is a command-line MATH-500 evaluator for measuring inference-time scaling with Qwen3. The workflow initializes a model and tokenizer, formats each benchmark problem, samples reasoning paths with configurable decoding, selects a consensus answer, symbolically grades it, and writes evaluation records. The README also describes difficulty-wise analysis and sampling-budget comparisons; those are study capabilities rather than separate runtime stages. Edges follow shown calls or explicit README claims; the excerpts do not establish how the batched and optimized model implementations are selected at runtime.

Main entry points: [`main.py`](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/main.py) (Evaluation CLI), [`engine.py`](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/engine.py) (Model initialization), [`utils.py`](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py) (Benchmark loading), [`model_lib/utils.py`](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/utils.py) (Model asset downloads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evaluation["Evaluation workflow"]
  node_cli["Evaluation CLI<br/>[main.py]"]
  node_device["Compute setup<br/>[utils.py]"]
  node_prompt["Prompt formatting<br/>[utils.py]"]
  node_pipeline["Model initialization<br/>[engine.py]"]
  node_evaluation_results["Evaluation results"]
end

subgraph group_reasoning["Reasoning and decoding"]
  node_consensus["Path consensus<br/>[engine.py]"]
  node_generation["Sampling and streaming"]
end

subgraph group_models["Qwen3 model implementations"]
  node_qwen_model["Qwen3 model<br/>[qwen3.py]"]
  node_batched_model["Batched Qwen3<br/>[qwen3_batched.py]"]
  node_optimized_model["Optimized Qwen3<br/>[qwen3_optimized.py]"]
  node_model_assets["Model asset downloads<br/>[utils.py]"]
end

subgraph group_math["Math data and grading"]
  node_benchmark["MATH-500 benchmark<br/>[math500_test.json]"]
  node_benchmark_loader["Benchmark loading<br/>[utils.py]"]
  node_answer_parse["Answer parsing"]
  node_math_grade["Symbolic equivalence"]
end

node_user(("Evaluator user"))
node_asset_host(("Model asset host"))
node_sympy["SymPy"]
node_benchmark_source(("Benchmark source"))

node_user -->|"configures"| node_cli
node_cli -->|"initializes"| node_device
node_cli -->|"initializes"| node_pipeline
node_cli -->|"loads"| node_benchmark_loader
node_benchmark_loader -->|"reads"| node_benchmark
node_benchmark_loader -->|"downloads from"| node_benchmark_source
node_cli -->|"formats problems"| node_prompt
node_cli -->|"requests paths"| node_consensus
node_pipeline -->|"constructs"| node_qwen_model
node_pipeline -->|"downloads assets"| node_model_assets
node_model_assets -.->|"fetches files"| node_asset_host
node_consensus -->|"generates paths"| node_generation
node_consensus -->|"parses candidates"| node_answer_parse
node_generation -->|"runs inference"| node_qwen_model
node_cli -->|"grades prediction"| node_math_grade
node_math_grade -->|"checks equivalence"| node_sympy
node_cli -->|"writes records"| node_evaluation_results
node_batched_model -->|"reuses cache and tokenizer"| node_qwen_model
node_optimized_model -->|"uses download helper"| node_model_assets

click node_cli "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/main.py"
click node_device "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py"
click node_prompt "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py"
click node_benchmark "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/data/math500_test.json"
click node_benchmark_loader "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py"
click node_pipeline "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/engine.py"
click node_consensus "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/engine.py"
click node_generation "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/generation_factory.py"
click node_answer_parse "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/math_postprocessing.py"
click node_math_grade "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/math_postprocessing.py"
click node_qwen_model "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3.py"
click node_batched_model "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3_batched.py"
click node_optimized_model "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3_optimized.py"
click node_model_assets "https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_device,node_prompt,node_pipeline,node_evaluation_results,node_user toneBlue
class node_consensus,node_generation toneAmber
class node_qwen_model,node_batched_model,node_optimized_model,node_model_assets toneMint
class node_benchmark,node_benchmark_loader,node_answer_parse,node_math_grade toneRose
class node_asset_host,node_sympy,node_benchmark_source toneIndigo
```

## Components

### Evaluation workflow

- [Evaluation CLI](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/main.py): `main.py`
- [Compute setup](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py): `utils.py`
- [Prompt formatting](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py): `utils.py`
- [Model initialization](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/engine.py): `engine.py`
- **Evaluation results**

### Reasoning and decoding

- [Path consensus](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/engine.py): `engine.py`
- [Sampling and streaming](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/generation_factory.py): `generation_factory.py`

### Qwen3 model implementations

- [Qwen3 model](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3.py): `model_lib/qwen3.py`
- [Batched Qwen3](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3_batched.py): `model_lib/qwen3_batched.py`
- [Optimized Qwen3](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/qwen3_optimized.py): `model_lib/qwen3_optimized.py`
- [Model asset downloads](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/model_lib/utils.py): `model_lib/utils.py`

### Math data and grading

- [MATH-500 benchmark](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/data/math500_test.json): `data/math500_test.json`
- [Benchmark loading](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/utils.py): `utils.py`
- [Answer parsing](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/math_postprocessing.py): `math_postprocessing.py`
- [Symbolic equivalence](https://github.com/ankitsharma285/inferencescaling-qwen/blob/main/math_postprocessing.py): `math_postprocessing.py`

### Other components

- **Evaluator user**
- **Model asset host**
- **SymPy**
- **Benchmark source**

## Connections

- Evaluator user → Evaluation CLI: configures (evidence: `README.md`)
- Evaluation CLI → Compute setup: initializes (evidence: `main.py`)
- Evaluation CLI → Model initialization: initializes (evidence: `main.py`)
- Evaluation CLI → Benchmark loading: loads (evidence: `main.py`)
- Benchmark loading → MATH-500 benchmark: reads (evidence: `utils.py`)
- Benchmark loading → Benchmark source: downloads from (evidence: `utils.py`)
- Evaluation CLI → Prompt formatting: formats problems (evidence: `main.py`)
- Evaluation CLI → Path consensus: requests paths (evidence: `main.py`)
- Model initialization → Qwen3 model: constructs (evidence: `engine.py`)
- Model initialization → Model asset downloads: downloads assets (evidence: `engine.py`)
- Model asset downloads → Model asset host: fetches files
- Path consensus → Sampling and streaming: generates paths (evidence: `engine.py`)
- Path consensus → Answer parsing: parses candidates (evidence: `engine.py`)
- Sampling and streaming → Qwen3 model: runs inference (evidence: `generation_factory.py`)
- Evaluation CLI → Symbolic equivalence: grades prediction (evidence: `main.py`)
- Symbolic equivalence → SymPy: checks equivalence (evidence: `math_postprocessing.py`)
- Evaluation CLI → Evaluation results: writes records (evidence: `main.py`)
- Batched Qwen3 → Qwen3 model: reuses cache and tokenizer (evidence: `model_lib/qwen3_batched.py`)
- Optimized Qwen3 → Model asset downloads: uses download helper (evidence: `model_lib/qwen3_optimized.py`)
