Model Info Utilities
Relevant source files
The following files were used as context for generating this wiki page:
The Model Info Utilities system provides the logic for simulating and analyzing ONNX model characteristics within the ONNX-Station workbench. Its primary purpose is to generate high-fidelity estimations of operator distributions, memory allocation (VRAM), and model architecture statistics based on user-defined export configurations.
This module acts as a bridge between the configuration stage and the visualization stage. It allows the workbench to display technical insights—such as estimated intermediate tensor allocations and operator frequencies—even before a physical model is exported or benchmarked, using heuristics derived from the model's path, modality, and optimization level.
Sources: src/utils/modelInfo.ts:1-7, src/WorkbenchContext.tsx:112-115
Core Data Structures
The system relies on standardized TypeScript interfaces to ensure consistency across the simulation logic, the application state, and the UI components.
Compiled Model Objects
The output of the utility is encapsulated in the CompiledModelInfo interface, which provides a comprehensive summary of the model's structural and resource requirements.
| Field | Type | Description |
|---|---|---|
status | idle | exporting | completed | Current state of the model info generation. |
operators | CompiledModelOperator[] | A list of specific ONNX operators and their estimated metrics. |
totalOps | number | The aggregate count of all operator nodes in the graph. |
totalMemoryMb | number | The total estimated VRAM footprint in Megabytes. |
isSimulated | boolean | Flag indicating if metrics are heuristic-based or live. |
Sources: src/types.ts:88-100
Operator Metrics
Each entry in the operator list contains granular data used for bar and donut chart visualizations.
| Field | Type | Description |
|---|---|---|
opType | string | The ONNX operator name (e.g., MatMul, Conv). |
count | number | Frequency of this operator in the model graph. |
memoryMb | number | Estimated memory consumption for this operator type. |
category | string | Classification (e.g., compute, memory, shape). |
Sources: src/types.ts:80-86
Simulation Logic Architecture
The central function generateCompiledModelInfo implements a multi-stage pipeline to transform an ExportConfig into technical metrics.
1. Model Identification and Scaling
The utility first parses the modelPath to determine the base architecture and layer count. It identifies specific model families like Whisper, LLaMA, BERT, or ResNet and assigns a base number of layers (e.g., 32 layers for LLaMA-style models).
Sources: src/utils/modelInfo.ts:8-44
2. Multiplier Application
Heuristics are adjusted based on the precision and optimization levels selected in the workbench:
- Dtype Scaling:
fp16andbf16reduce memory estimates by approximately 50%. - Optimization Scaling: Higher levels (O1-O3) decrease operator counts via fusion, while O4 (Quantization) increases node count due to the introduction of
QuantizeLinear/DequantizeLinearnodes but drastically reduces memory footprint.
Sources: src/utils/modelInfo.ts:46-75
3. Modality-Specific Operator Generation
The system populates the operator list based on the chosen modality (text, vision, or audio).
- Text: Focuses on
MatMul,Gather(embeddings), andLayerNormalization. - Vision: Differentiates between
ViT(Vision Transformer) and standardCNN(Convolutional) architectures, generatingConvorMatMulnodes accordingly. - Audio: Simulates complex encoder-decoder stacks like Whisper, involving
Conv1Dfrontends andFusedAttentionnodes.
Sources: src/utils/modelInfo.ts:93-195
Integration with Workbench State
The Model Info Utilities are integrated into the WorkbenchContext to provide reactive updates to the UI.
Visualization Components
The results from the model info utilities are consumed by the OnnxGraphVisualizer component, which uses D3.js to render two primary views:
- Operator Instance Counts: A horizontal bar chart showing the frequency of ONNX nodes, colored by category (Compute, Memory, Activation, Normalization, or Shape).
- VRAM Map: A donut chart illustrating the estimated memory distribution, highlighting potential bottlenecks where specific operators (like large MatMuls) consume significant VRAM.
Sources: src/components/OnnxGraphVisualizer.tsx:64-118, src/components/OnnxGraphVisualizer.tsx:174-219
Summary of Optimization Impacts
The utilities reflect the technical impact of Optimum CLI flags on the model structure as follows:
| Optimization Flag | Impact on CompiledModelInfo |
|---|---|
O1 - O3 | Fuses nodes (decreases totalOps), reduces totalMemoryMb. |
O4 | Adds QLinear nodes; reduces memory by ~65% via quantization. |
--dtype fp16 | Halves the memoryMb for weight-heavy operators. |
--modality | Changes the fundamental set of operators (e.g., Conv vs MatMul). |
Sources: src/utils/modelInfo.ts:51-75, src/components/CenterCanvas.tsx:136-155