# gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2 architecture

> Architecture diagram of the GitHub repository gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2
- Repository: https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2

## Overview

This repository is a collection of XDNA2 LLM analysis, quantization-planning, profiling, and model-optimization scripts rather than a complete packaged application. The principal workflow analyzes a model, plans mixed precision, estimates performance, and reports results; separate scripts build optimized GGUF/Q4NX models and measure live inference. The README documents the D2 planner’s ILP/greedy, tile-fitness, and roofline capabilities. Some orchestration imports a `core` package that is not present in the supplied tree, so its internals are not represented.

Main entry points: [`run_optimize.py`](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py) (Optimize runner), [`d2_npu_xdna2.py`](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_npu_xdna2.py) (XDNA2 planner), [`d2_xdna2_poc.py`](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_poc.py) (D2 PoC v1), [`d2_xdna2_pocv2.py`](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_pocv2.py) (D2 PoC v2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Quantization planning"]
  node_planner["XDNA2 planner<br/>[d2_npu_xdna2.py]"]
  node_poc_v1["D2 PoC v1<br/>[d2_xdna2_poc.py]"]
  node_poc_v2["D2 PoC v2<br/>[d2_xdna2_pocv2.py]"]
  node_poc_flm["FastFlowLM bridge"]
end

subgraph group_optimization["Model optimization"]
  node_run_optimize["Optimize runner<br/>[run_optimize.py]"]
  node_analyze["Model analysis<br/>[run_optimize.py]"]
  node_fusion["Fusion planning<br/>[run_optimize.py]"]
  node_schedule["NPU scheduling<br/>[run_optimize.py]"]
  node_mixed_quant["Mixed quantization<br/>[run_optimize.py]"]
  node_tps_predict["TPS prediction<br/>[run_optimize.py]"]
  node_report["Optimization reports<br/>[run_optimize.py]"]
  node_build_model["Q4NX model builder"]
end

subgraph group_measurement["Profiling and diagnosis"]
  node_layer_profile["Layer profiler<br/>[profile_layers.py]"]
  node_tensor_profile["Safetensors profiler"]
  node_flm_profile["FLM profiler<br/>[profile_flm.py]"]
  node_roofline["Roofline diagnosis"]
end

node_engineer(("Engineer"))

node_engineer -->|"runs"| node_run_optimize
node_run_optimize -->|"loads model"| node_analyze
node_run_optimize -->|"optimizes graph"| node_fusion
node_run_optimize -->|"plans jobs"| node_schedule
node_run_optimize -->|"applies quantization"| node_mixed_quant
node_run_optimize -->|"predicts throughput"| node_tps_predict
node_run_optimize -->|"saves reports"| node_report
node_engineer -->|"runs planner"| node_planner
node_engineer -->|"runs PoC"| node_poc_v1
node_engineer -.->|"runs PoC"| node_poc_v2
node_engineer -.->|"runs bridge"| node_poc_flm
node_engineer -->|"builds model"| node_build_model
node_engineer -->|"profiles layers"| node_layer_profile
node_engineer -->|"profiles tensors"| node_tensor_profile
node_engineer -->|"profiles FLM"| node_flm_profile
node_engineer -->|"diagnoses throughput"| node_roofline

click node_run_optimize "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_analyze "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_fusion "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_schedule "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_mixed_quant "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_tps_predict "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_report "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py"
click node_planner "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_npu_xdna2.py"
click node_poc_v1 "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_poc.py"
click node_poc_v2 "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_pocv2.py"
click node_poc_flm "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_pocv2flm.py"
click node_build_model "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/build_optimized_model.py"
click node_layer_profile "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_layers.py"
click node_tensor_profile "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_safetensors.py"
click node_flm_profile "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_flm.py"
click node_roofline "https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/roofline_diagnose.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_planner,node_poc_v1,node_poc_v2,node_poc_flm toneBlue
class node_run_optimize,node_analyze,node_fusion,node_schedule,node_mixed_quant,node_tps_predict,node_report,node_build_model toneAmber
class node_layer_profile,node_tensor_profile,node_flm_profile,node_roofline toneMint
class node_engineer toneIndigo
```

## Components

### Quantization planning

- [XDNA2 planner](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_npu_xdna2.py): `d2_npu_xdna2.py`
- [D2 PoC v1](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_poc.py): `d2_xdna2_poc.py`
- [D2 PoC v2](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_pocv2.py): `d2_xdna2_pocv2.py`
- [FastFlowLM bridge](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/d2_xdna2_pocv2flm.py): `d2_xdna2_pocv2flm.py`

### Model optimization

- [Optimize runner](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [Model analysis](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [Fusion planning](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [NPU scheduling](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [Mixed quantization](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [TPS prediction](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [Optimization reports](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/run_optimize.py): `run_optimize.py`
- [Q4NX model builder](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/build_optimized_model.py): `build_optimized_model.py`

### Profiling and diagnosis

- [Layer profiler](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_layers.py): `profile_layers.py`
- [Safetensors profiler](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_safetensors.py): `profile_safetensors.py`
- [FLM profiler](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/profile_flm.py): `profile_flm.py`
- [Roofline diagnosis](https://github.com/gatmannes/rapport-technique-optimisation-de-l-inf-rence-llm-sur-npu-xdna2/blob/main/roofline_diagnose.py): `roofline_diagnose.py`

### Other components

- **Engineer**

## Connections

- Engineer → Optimize runner: runs (evidence: `run_optimize.py`)
- Optimize runner → Model analysis: loads model (evidence: `run_optimize.py`)
- Optimize runner → Fusion planning: optimizes graph (evidence: `run_optimize.py`)
- Optimize runner → NPU scheduling: plans jobs (evidence: `run_optimize.py`)
- Optimize runner → Mixed quantization: applies quantization (evidence: `run_optimize.py`)
- Optimize runner → TPS prediction: predicts throughput (evidence: `run_optimize.py`)
- Optimize runner → Optimization reports: saves reports (evidence: `run_optimize.py`)
- Engineer → XDNA2 planner: runs planner (evidence: `d2_npu_xdna2.py`)
- Engineer → D2 PoC v1: runs PoC (evidence: `README.md`)
- Engineer → D2 PoC v2: runs PoC
- Engineer → FastFlowLM bridge: runs bridge
- Engineer → Q4NX model builder: builds model (evidence: `build_optimized_model.py`)
- Engineer → Layer profiler: profiles layers (evidence: `profile_layers.py`)
- Engineer → Safetensors profiler: profiles tensors (evidence: `profile_safetensors.py`)
- Engineer → FLM profiler: profiles FLM (evidence: `profile_flm.py`)
- Engineer → Roofline diagnosis: diagnoses throughput (evidence: `roofline_diagnose.py`)
