From c20bde7a2374c4fa0dc241a7a6853245066bf801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 1 Apr 2026 01:26:03 +0200 Subject: [PATCH 1/7] 2026 --- _doc/articles/2026-04-30-route2026.rst | 221 +++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 _doc/articles/2026-04-30-route2026.rst diff --git a/_doc/articles/2026-04-30-route2026.rst b/_doc/articles/2026-04-30-route2026.rst new file mode 100644 index 0000000..841dedb --- /dev/null +++ b/_doc/articles/2026-04-30-route2026.rst @@ -0,0 +1,221 @@ +.. _l-feuille-de-route-2025-3A: + +2026-04-30: Feuille de route 2025-2026 (3A) +=========================================== + +* Main Web Site : `https://sdpython.github.io/ `_ +* Material : `https://sdpython.github.io/doc/teachcompute/dev/ `_ + +Plan +++++ + +Les cours et séances se déroulent sur 4 séances de 3h au second semestre. + +Evaluation +++++++++++ + +Utilisation de vos compétences statistiques pour fabriquer un benchmark +adaptatif où l'on trouve la meilleure option de parallélisation +pour un algorithme parallélisé avec moins d'essais qu'une grille. + +Séance 1 - 1/04: pararalléliser comment? +++++++++++++++++++++++++++++++++++++++++ + +**Part 1** + +* stratégies de parallélisation (big data, deep learning, calcul matriciel...) +* coût, calcul, communication, caches +* CPU vs GPU +* conflits, synchronisation, mutex + +* L1: 32 Ko, 3/4 Go/s, 1/2 cycles d'horloge, L2: 1Mo, 20 Go/s, 3/5 cycles d'horloge, L3: 8Mo, 40 Go/s, 10/20 cycles d'horloge +* thread / process +* :epkg:`AVX` +* branching +* cas du produit vectoriel +* produit matriciel + +**Part 2** + +1. Environnement + +* C++ syntax +* Python +* présentation d'un package, C++ +* Outils de développement : :epkg:`cmake`, :epkg:`git`, :epkg:`pull request` +* Python : :epkg:`setup.py`, :epkg:`sphinx`, :epkg:`pybind11`, :epkg:`cython` +* style : :epkg:`black`, :epkg:`ruff` +* :epkg:`github` et intégration continue +* Copy/Pasting is your friend. +* LLMs +* `VSCode `_ + +Séance 2 - 8/04: python, pybind11, cython +++++++++++++++++++++++++++++++++++++++++++ + +* introduction à :epkg:`cython`, :epkg:`numba`, :epkg:`pybind11` +* voir `_tutoriels `_ + et `tutorials.yml `_ + + +Séance 3 - 15/04: alorithmes parallélisés ++++++++++++++++++++++++++++++++++++++++++ + +**Partie 1** + +Ecriture d'un benchmark. + +Comparaison d'une multiplication de matrice sparse et dense, +évolution en fonction du nombre des dimensions, du taux de "sparsité". + +Vaut-il mieux calculer *(XA, XB)* séparément ou *X(A,B)* où +*(A,B)* désigne une matrice où A et B sont concaténées selon les colonnes. + +*AB* est-il plus ou moins rapide que *AB'* si les matrices sont carrées ? + +Profiling + +Lecture de benchmark. + +* :ref:`l-parallelization-vector-sum` +* :ref:`l-parallelization-dot-product` +* :ref:`l-compare-filtering-implementation` +* :ref:`l-parallelization-processes` +* écrire un programme pour plusieurs processeurs +* CI, intégration continue +* :epkg:`cmake` + +**Pour aller plus loin** + +* :epkg:`blas`, :epkg:`lapack`, :epkg:`Eigen`, :epkg:`xtensor`, :epkg:`simd` +* `OpenMP `_ + +**Partie 2** + +* `Algorithme de Strassen `_ +* `HOGWILD !: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent + `_ +* problème de convergence +* quantization +* réseau de neurones +* parallélisation mémoire contrainte ou presque +* `A quantum-inspired classical algorithm for recommendation systems + `_ +* utilisation de plusieurs processeurs, CPUs, GPUs..., NPU, `intel-npu `_ +* qui fait quoi ? data scientist, développeur + +Séance 4 - 22/04: fusion d'opérations et projets +++++++++++++++++++++++++++++++++++++++++++++++++ + +* Benchmark à partir de `cython_mat `_ +* Profiling +* fusion d'opérations : cas de l'`attention `_: + +.. math:: + + Attention(Q,K,V)=softmax\left(\frac{QK'}{\sqrt{d_k}}\right)V + +avec + +:math:`Q \in \mathbb{R}^{m \times d_q}`, :math:`K \in \mathbb{R}^{m \times d_k}`, :math:`V \in \mathbb{R}^{m \times d_V}` +et : + +.. math:: + + softmax(z_1,...z_n)_i = \frac{e_i}{\sum_{i=1}^{n} e_i} + +Utilisation de vos compétences statistiques pour fabriquer un benchmark +adaptatif où l'on trouve la meilleure option de parallélisation +pour un algorithme parallélisé avec moins d'essais qu'une grille. + +Sujets connexes ++++++++++++++++ + +* hacking (attaque), Spectre, Meltdown +* https://fr.wikipedia.org/wiki/DO-178, PowerPC, RISC +* `MAIA `_ +* `TPU `_ +* Un tri ? +* Le calcul de la médiane ? (:epkg:`BJKST`) Propriétés statistiques ? +* Pourquoi est-ce si difficile de paralléliser un tri ? +* `scatter_nd `_, + Que faire quand les indices sont dupliqués ? +* Paralléliser une forêt aléatoire sur CPU, sur GPU ? +* La recherche de doublons dans une liste de + coordonnées géographiques (longitude, latitude) ? +* `An Efficient Matrix Transpose in CUDA C/C++ + `_, + notion de Bank Conflicts (voir + `CUDA C++ Programming Guide `_) + `CUDA, Cartes graphiques, Warp... `_ + +Installation de ce module ++++++++++++++++++++++++++ + +Il ensuite exécuter les instuctions suivantes en ligne de commande. + +:: + + git clone https://github.com/sdpython/teachcompute.git + cd teachcompute + pip install -e . -v --no-build-isolation -no-clean + +Si ça ne marche, installer `cmake `_. +Puis : + +:: + + export PYTHONPATH= + python _doc/examples/plot_bench_cpu_vector_sum.py + +Lectures +++++++++ + +Collège de France + +* `Une vision mathématique du "Deep Learning" + `_ +* `Stéphane Mallat, Représentation Parcimonieuse + `_ +* `Algorithmes quantiques : quand la physique quantique défie la thèse de Church-Turing + `_ +* `Génération de données en IA par transport et débruitage (1) + `_ + **pour comprendre ce que sont les LLMs** +* `Enseigner les maths par des challenges d'IA + `_ +* `Introduction aux réseaux de neurones profonds + `_ + +Points particuliers ++++++++++++++++++++ + +* `race condition ` +* `AVX `_ +* `Cache `_ + +Livres +++++++ + +* `Introduction to Algorithms `_ +* `Latency Numbers Every Programmer Should Know + `_ +* `What Every Computer Scientist Should Know About Floating-Point Arithmetic + `_ +* `What Every Programmer Should Know About Memory + `_ +* `Introduction to High Performance Scientific Computing + `_ + +Autres +++++++ + +* `AlphaFold `_ (Prix Nodel) + `Prix Nobel de chimie 2024 : quand l'IA permet de comprendre la structure des protéines + `_ +* `A quantum-inspired classical algorithm for recommendation systems `_ +* `CoqPilot, a plugin for LLM-based generation of proofs `_ +* `The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmap `_ +* `GraphCast: AI model for faster and more accurate global weather forecasting + `_ + From 497501c39399cf4f2e69af4ec4fabe9b4f10fa7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 1 Apr 2026 01:27:55 +0200 Subject: [PATCH 2/7] fix --- _doc/examples/plot_benchmark_dot_mul_timeit.py | 1 - _doc/examples/plot_serialisation_examples.py | 2 +- _unittests/ut_xrun_doc/test_documentation_examples.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/_doc/examples/plot_benchmark_dot_mul_timeit.py b/_doc/examples/plot_benchmark_dot_mul_timeit.py index 68cf058..e8949b8 100644 --- a/_doc/examples/plot_benchmark_dot_mul_timeit.py +++ b/_doc/examples/plot_benchmark_dot_mul_timeit.py @@ -39,7 +39,6 @@ c_multiply_matrix_parallel_transposed as cmulparamtr, ) - va = numpy.random.randn(150, 100).astype(numpy.float64) vb = numpy.random.randn(100, 100).astype(numpy.float64) ctx = { diff --git a/_doc/examples/plot_serialisation_examples.py b/_doc/examples/plot_serialisation_examples.py index dc1efd7..3f483a8 100644 --- a/_doc/examples/plot_serialisation_examples.py +++ b/_doc/examples/plot_serialisation_examples.py @@ -15,6 +15,7 @@ Ecriture (json) +++++++++++++++ """ + from io import StringIO, BytesIO import timeit import json @@ -25,7 +26,6 @@ import matplotlib.pyplot as plt import pandas - data = { "records": [ { diff --git a/_unittests/ut_xrun_doc/test_documentation_examples.py b/_unittests/ut_xrun_doc/test_documentation_examples.py index 4933deb..264b609 100644 --- a/_unittests/ut_xrun_doc/test_documentation_examples.py +++ b/_unittests/ut_xrun_doc/test_documentation_examples.py @@ -7,7 +7,6 @@ from teachcompute import __file__ as teachcompute_file, has_cuda from teachcompute.ext_test_case import ExtTestCase, has_transformers, is_apple - VERBOSE = 0 ROOT = os.path.realpath(os.path.abspath(os.path.join(teachcompute_file, "..", ".."))) From 036aeaa6fbe9fe1be424915d14e335b63d61a449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 1 Apr 2026 10:51:49 +0200 Subject: [PATCH 3/7] fix --- _doc/conf.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/_doc/conf.py b/_doc/conf.py index c570bb1..b4900d5 100644 --- a/_doc/conf.py +++ b/_doc/conf.py @@ -73,7 +73,7 @@ """ # The following is used by sphinx.ext.linkcode to provide links to github -linkcode_resolve = make_linkcode_resolve( +_linkcode_resolve = make_linkcode_resolve( "teachcompute", ( "https://github.com/sdpython/teachcompute/" @@ -82,6 +82,11 @@ ), ) + +def linkcode_resolve(domain, info): + return _linkcode_resolve(domain, info) + + latex_elements = { "papersize": "a4", "pointsize": "10pt", @@ -123,6 +128,9 @@ nitpick_ignore_regex = [ ("py:class", ".*numpy[.].*"), + ("py:class", "pandas.core.frame.DataFrame"), + ("py:class", ":.*"), + ("py:class", "\\].*"), ("py:func", ".*[.]PyCapsule[.].*"), ("py:func", ".*numpy[.].*"), ("py:func", ".*scipy[.].*"), From 58da9e0f67194c95e556a223e894ff3218c55405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 1 Apr 2026 10:58:53 +0200 Subject: [PATCH 4/7] fix --- _doc/articles/index.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_doc/articles/index.rst b/_doc/articles/index.rst index 93a2402..84285a8 100644 --- a/_doc/articles/index.rst +++ b/_doc/articles/index.rst @@ -6,6 +6,12 @@ Collections d'articles périssables Ou *blog*. +.. toctree:: + :caption: 2026 + :maxdepth: 1 + + 2026-04-30-route2026 + .. toctree:: :caption: 2025 :maxdepth: 1 From d9bc54e721dc941c924c8a7bf4f13053d553987b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 1 Apr 2026 11:48:51 +0200 Subject: [PATCH 5/7] fix --- _doc/articles/2026-04-30-route2026.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc/articles/2026-04-30-route2026.rst b/_doc/articles/2026-04-30-route2026.rst index 841dedb..215b2aa 100644 --- a/_doc/articles/2026-04-30-route2026.rst +++ b/_doc/articles/2026-04-30-route2026.rst @@ -1,4 +1,4 @@ -.. _l-feuille-de-route-2025-3A: +.. _l-feuille-de-route-2026-3A: 2026-04-30: Feuille de route 2025-2026 (3A) =========================================== From 716500e6ee8fdf8e107fa19f952f329224579130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Tue, 7 Apr 2026 23:13:51 +0200 Subject: [PATCH 6/7] fix --- _doc/articles/2026-04-30-route2026.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_doc/articles/2026-04-30-route2026.rst b/_doc/articles/2026-04-30-route2026.rst index 215b2aa..daa4ca8 100644 --- a/_doc/articles/2026-04-30-route2026.rst +++ b/_doc/articles/2026-04-30-route2026.rst @@ -53,6 +53,14 @@ Séance 1 - 1/04: pararalléliser comment? Séance 2 - 8/04: python, pybind11, cython ++++++++++++++++++++++++++++++++++++++++++ +* notion d'algortihmes parallélisés, algorithmes de streaming +* réduction : problèmes numériques +* générateur de hasard, séquences de hasard parallélisées +* cas de la descente de gradient, problème de converge +* offloading + +python et c++ + * introduction à :epkg:`cython`, :epkg:`numba`, :epkg:`pybind11` * voir `_tutoriels `_ et `tutorials.yml `_ From ce9717b67777b0fa0e0ffdbd0c2f58b498860f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Tue, 21 Apr 2026 23:51:21 +0200 Subject: [PATCH 7/7] plan --- _doc/articles/2026-04-30-route2026.rst | 36 ++++++++++---------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/_doc/articles/2026-04-30-route2026.rst b/_doc/articles/2026-04-30-route2026.rst index daa4ca8..9e6fd25 100644 --- a/_doc/articles/2026-04-30-route2026.rst +++ b/_doc/articles/2026-04-30-route2026.rst @@ -112,29 +112,19 @@ Lecture de benchmark. * utilisation de plusieurs processeurs, CPUs, GPUs..., NPU, `intel-npu `_ * qui fait quoi ? data scientist, développeur -Séance 4 - 22/04: fusion d'opérations et projets -++++++++++++++++++++++++++++++++++++++++++++++++ - -* Benchmark à partir de `cython_mat `_ -* Profiling -* fusion d'opérations : cas de l'`attention `_: - -.. math:: - - Attention(Q,K,V)=softmax\left(\frac{QK'}{\sqrt{d_k}}\right)V - -avec - -:math:`Q \in \mathbb{R}^{m \times d_q}`, :math:`K \in \mathbb{R}^{m \times d_k}`, :math:`V \in \mathbb{R}^{m \times d_V}` -et : - -.. math:: - - softmax(z_1,...z_n)_i = \frac{e_i}{\sum_{i=1}^{n} e_i} - -Utilisation de vos compétences statistiques pour fabriquer un benchmark -adaptatif où l'on trouve la meilleure option de parallélisation -pour un algorithme parallélisé avec moins d'essais qu'une grille. +Séance 4 - 22/04: mémoire et C++ +++++++++++++++++++++++++++++++++ + +* notion de cache line (64 octets cache miss, flase sharing) +* Translation Lookaside Buffer (TLB,), TLB miss +* mémoire alignée (posix_memalign) +* option de compilation + +* notions C/C++ +* STL +* OpenMP +* écriture de threads sans OpenMP +* interfaçage avec cython, nanobind Sujets connexes +++++++++++++++