<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mariia Baidachna on Medium]]></title>
        <description><![CDATA[Stories by Mariia Baidachna on Medium]]></description>
        <link>https://medium.com/@mashapotatoes?source=rss-e957fb28b112------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Fj8VTmA14XF2Wl8_092I0A.jpeg</url>
            <title>Stories by Mariia Baidachna on Medium</title>
            <link>https://medium.com/@mashapotatoes?source=rss-e957fb28b112------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:35:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mashapotatoes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The English Muffin Problem]]></title>
            <link>https://medium.com/@mashapotatoes/the-english-muffin-problem-eac4d9951569?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/eac4d9951569</guid>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[research]]></category>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 09:05:03 GMT</pubDate>
            <atom:updated>2026-07-04T09:05:13.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m70H-Cg583WrxlTBvG_pyw.png" /></figure><p>What’s the easiest bread recipe you can possibly think of? The answer, of course, is English muffins. You don’t need a sourdough starter, you don’t need multiple kneading sessions, you don’t even need an oven. You can just pan fry them. It feels like cheating because you can’t even call it “baking”, and yet it is indeed a fluffy, delicious recipe for bread.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FITmNN6GW80g%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2FITmNN6GW80g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FITmNN6GW80g%2Fhq2.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd6c5efadd3d1e1db2e9dffb777c67cb/href">https://medium.com/media/cd6c5efadd3d1e1db2e9dffb777c67cb/href</a></iframe><p>The biggest problem with AI for scientific discovery is innovation or lack thereof. I call this the English Muffin Problem. If you Google or ChatGPT the easiest bread recipe, you’ll get some simple sourdough starter, which is an art to maintain in itself, or some overnight dough mix like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJ9CLpUbKjoMntI_FJ6_tQ.png" /></figure><p>Firstly, I don’t have that kind of time. If I am craving something to spread my jam on, I want it today. Secondly, who even owns a Dutch oven? Thirdly, my student accommodation oven doesn’t even get that hot.</p><p>The problem is that we don’t think of English muffins as “bread” in the first place, and this propagates into search systems trained on human data. They will never go out of distribution enough to propose a recipe for English muffins, despite acknowledging them being a type of bread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mx5YGJ373--oR_LbzGE_Vw.png" /></figure><p>Similarly, autonomous AI systems will not go out of distribution enough to truly innovate and discover new concepts beyond marginal optimization. It will be forever stuck in a local optimum. Numerous branches of some idea may be thoroughly explored, but the process will never jump to a different tree to explore a fundamentally new idea in the forest of possibilities. In reality, an unlikely or high temperature idea that takes longer to plow through initially (it takes more thinking power to connect English muffins to bread and then realize it’s a much simpler process to make them) is actually better in the long-run (imagine how much time you’d save on making bread in the future).</p><p>Let’s take a specific example within machine learning. Neural networks work pretty well and have stemmed into various architectures from CNNs to Transformers for different use cases. However, they are not perfect; they require massive datasets to extract useful patterns within narrow domains, huge compute power for training and inferencing, and are abstracted as black boxes that take years of context in math and computer science to understand. These limitations combined with the fact that children can recognize patterns with a lot fewer samples and Watts make it reasonable to assume that we can do better. Let’s say, for instance, quantum computing solves some tasks in a more accurate and energy efficient way. Despite publicly available information on quantum advantage and current bottlenecks, only a niche group of scientists working on the intersection of these fields would even bring it up in the first place. When prompted to improve neural networks without any hints to quantum computing, AI systems almost definitely will not go that far (seemingly) out of scope.</p><p>An argument could be made in favor of the AI system because quantum hardware isn’t here yet to be able to run or test theories at scale. But shouldn’t we then pivot to spending more resources on innovating to accelerate the engineering of these systems, provided they would result in significantly better architectures? Back in the world of analogies, this equates to slowing down the English muffin production to build a bread making machine. These things are truly incredible and, if you can believe it, are even easier than making English muffins. All you do is throw in the ingredients, set a timer, and boom — bread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EgohhZrifbtvGq9loYdtng.png" /></figure><p><strong>So how do we solve it? </strong>How do we force new ideas to be explored without being outright unrealistic? One imperfect but practical way forward is to take inspiration from the research ecosystem in the human world and embed it into AI agents. This involves breaking down the research and innovation pipelines into components and assigning each component to a skilled agent. Labs are built on a supervisor-student dynamic, where a supervisor guides and critiques several PhD students, and a paper publication venue, which correlates to the novel contributions the lab has proposed. The papers are reviewed by a board of journal or conference chairs to ensure quality, and papers are often verified through in-house replication before building upon them. This simple model gives us four components already: student, supervisor, reviewer, and publication venue.</p><p>Ideally, we would improve the existing system as we rebuild it from scratch with AI agents. We can learn from the misaligned proxy metrics for success and innovation in research (e.g. h-index, paper publication count, grants), as well as time-consuming bureaucracy, and create more valuable artifacts in the form of .md files for reproducibility.</p><p><a href="https://github.com/mashathepotato/efferents">Efferents</a> is my attempt at solving the English Muffin Problem. Inspired by Moltbook, the idea is simulate multiple research labs simultaneously. The autonomous labs have a shared publication venue they can write to and injest relevant new work from. Instead of a polished methods section, a clear process is depicted for full reproducibility. At scale, multiple interconnected autonomous labs would overcome the problem of converging to a local optimum. They would go on to connect ideas over a seemingly great distance to discover the English Muffin solution and innovate beyond it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eac4d9951569" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Philosophers will win.]]></title>
            <link>https://medium.com/@mashapotatoes/philosophers-will-win-a881f79c8fbb?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/a881f79c8fbb</guid>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 20:38:44 GMT</pubDate>
            <atom:updated>2026-06-22T20:39:48.019Z</atom:updated>
            <content:encoded><![CDATA[<p>It is a meme universally acknowledged that, in the pursuit of the ultimate truth, physicists long to be mathematicians, mathematicians long to be philosophers, and philosophers long for a job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/0*MDJ0hbHZKL9MiSdD.png" /></figure><p>Today’s trends show that this will not be so for long. Abstract reasoning and critical thinking are becoming increasingly more valuable factors in the job market and overall success.</p><p>This is why philosophers will win.</p><p>Not philosophers in the narrow academic sense of the word, rather the modern archetype of someone who ponders, discusses, and revises their views. Not necessarily people who have read every original text or can recite Kant on command, but people who can think at the level of frameworks. People who can hold ambiguity without collapsing into vagueness. People who can ask better questions than the ones currently being answered. People who engage and interact with the world enough to build up a strong intuition about it.</p><p><strong>The point is not to become less precise. It is to become precise at a higher level.</strong></p><p>The best physicists are already partly philosophers. They are not only solving equations; they are deciding which simplifications are legitimate, which assumptions are hiding something important, and which conceptual frame makes a problem tractable. The best mathematicians are already partly philosophers. They use intuition to formulate theories that then turn into theorems and uncover additional insights into logical reasoning. The most successful people will not be generalists who know nothing deeply. That is not the point. The future does not belong to shallow abstraction. It belongs to people who combine deep expertise with the ability to step outside of it. World-class researchers, scientists, leaders, musicians, artists, teachers, architects, and others at the top of their domain share a common trait: filtering out noise and focusing on the important details.</p><p>Though this is nothing new, this distinction is becoming more important. Possessing the frameworks to be able to decipher novel complex information is much more sustainable way of learning.</p><p>Historically, we have been moving up the abstraction stack:</p><ul><li>Calculators automated arithmetics.</li><li>Computers automated protocols.</li><li>Algorithms automated decision rules.</li><li>Neural networks automated pattern recognition.</li><li>AI systems can automate analysis, creation, and implementation.</li><li>Agent systems will increasingly automate the writing and orchestration of the algorithms themselves.</li></ul><p>Concrete and verifiable tasks are increasingly automated and will keep getting automated as AI usage becomes more widespread.</p><h3>So what is left?</h3><p>If machines can effectively run the experiments, the valuable skill becomes knowing what experiments actually matter. The intuition built up over years of studying, learning, grinding, and actually using those skills out in the wild becomes a real differentiator. Besides, metacognitive qualities and constant self-improvement to infer oneself’s process of thinking produce novel connections that augment the general intuition.</p><p>Beyond telling machines what to do, convincing people why your work is of value is equally as important. Again, this requires zooming out of the details to see the bigger picture and the direction it’s going in. Framing ideas and reframing failures is everything.</p><p>However, one does not progress simply by the strength of thought. Urgent, practical applications of philosophy is required to put it into something useful. Agency is still what allows actions to be taken, but the best sets of actions will be guided by core philosophic ideas that frame the entire direction, the purpose of the vision, and the conviction needed to take others along for the ride.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/0*qDsSjJF5Led0107L" /></figure><p>It is well understood, especially by the STEM community, that pure philosophy will get us nowhere, but it is often forgotten that pure facts and logic are not enough either.</p><p>Enough philosophizing, I want to end this with a few practical steps. I urge everyone to spend a little more time on reading, podcasts, ingesting diverse perspectives, and just daydreaming and replace some of the content consumption time with creation based on your newly formed ideas.</p><p>Keep pontificating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a881f79c8fbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Final GSoC Blog: Quantum Diffusion Model]]></title>
            <link>https://medium.com/@mashapotatoes/final-gsoc-blog-quantum-diffusion-model-ebdf868a6ffa?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebdf868a6ffa</guid>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 21:40:36 GMT</pubDate>
            <atom:updated>2025-11-11T21:40:36.677Z</atom:updated>
            <content:encoded><![CDATA[<p>For context, this is the fourth and final GSoC progress blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2yQcN_PlAk42GZ3T.jpeg" /></figure><p>Here is the previous part:</p><p><a href="https://medium.com/@mashapotatoes/scaling-the-quantum-diffusion-model-e8c15e10e72e">Scaling the Quantum Diffusion Model</a></p><h3>Recap:</h3><p>The goal of this project is to build a quantum diffusion model, or a diffusion model for image generation that can (at least in theory) run on quantum hardware, and train it on high energy physics data. The motivation behind this work is to be able to generate new unique samples that are similar to the ones in the data but at much lower computational costs than a regular diffusion model. The quantum model would be a success if it can perform the same or better than a classical diffusion model.</p><p>Having analyzed the time and qubit complexity previously, I have come to a conclusion that the encoding of classical data to quantum states is a bottleneck. It is computationally difficult (both in simulators and on real quantum hardware) to encode a large classical dataset with most encoding methods. Unfortunately, it is a necessary step, as the quantum model cannot directly operate on classical images, so it cannot be replaced entirely. However, what we can do is set an upper bound on how many samples we would need to convert. Afterall, there has been research implying that quantum learning models can converge faster on smaller datasets.</p><h3>Data Augmentation:</h3><p>The idea is to apply data augmentation to quantum states after encoding a small number of randomly chosen samples from the classical dataset. Similar to classical data augmentation, each sample in the dataset receives multiple inexact copies of itself, multiplying the original cardinality by the number of augmentations applied. In our case, we generate multiple random quantum circuits (as many as the number of augmentations we want) and apply them to scrambling one encoded point to many. We then attach each noised image (at the final step of the forward diffusion process) to its original image and feed them into the training loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8R94-lBMmidHTrNXeISKOA.png" /><figcaption>Quantum circuit used for scrambling the dataset.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*w8eBPCzshAreRyxp.png" /><figcaption>Example of quantum data augmentation on MNIST.</figcaption></figure><p>Empirical results show that using angle encoding on MNIST and then augmenting the dataset as described above increases the speed of convergence. This means that we can potentially limit the effect of the bottleneck encoding brings and make QML more practical and scalable.</p><p>Another data augmentation method to try in the future could be applying some augmentations to the data directly after encoding. This would actually mimic classical data augmentation more closely, as it would not require scrambling the dataset as in diffusion models and augmenting at the end. Additionally, it would be more generalizable to other models that do not follow the diffusion flow architecture. However, it is not trivial to do, as it is not very intuitive how to make new encoded samples without disrupting the original distribution, but it can be an interesting direction to explore.</p><h3>Quantum Flow Matching:</h3><p>During experimentation, one small but important change was made to the pipeline. Specifically, now the model takes in the generated random circuits that were used to scramble the dataset in addition to the data itself. This was done to eliminate mode collapse and improve expressivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*dNfE21ouoLKo6KMBIsvi1A.png" /><figcaption>On the left, the reconstructed samples show a kind of mode collapse, where they generate the same patch-wise pattern (due to patch-wise encoding) in different levels of intensity. The reconstructed images on the right are all unique, as expected, and are a result of feeding the conditional unitary into the model during training.</figcaption></figure><p>This change in the workflow makes the quantum model relatively similar to conditional flow matching, where the condition is the random circuit and the flow of how to invert the image from noise and reconstruct the original distribution from the latent space is what’s being learned.</p><p>Elaborating on this idea, a useful extension would be to implement the flow matching model on the quark and gluon jet dataset and benchmark it against the existing classical and quantum diffusion models. Furthermore, drawing inspiration from multiple classical architecture to build the quantum one could result in improved performance and overall quantum architecture search. It can also be argued that a more physics-informed is required for QML models, but I think that “translating” classical to quantum models is a good start. Now, I am at a point where the bounds of the classical architectures are possibly preventing the quantum model to perform to its fullest potential, so a multi-architecture and physics-driven approach is worth exploring in future research.</p><h3>Other Progress:</h3><p>Throughout the program, I attended several workshops and conferences where I got the chance to present this project to the broader machine learning and quantum computing communities. Most recently, the paper on this work was accepted as a presentation at the AAAI QIML Symposium in Washington DC and is to be published in AAAI proceedings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*cb3uyK3hMcryNgh8m_cTkA.jpeg" /><figcaption>AAAI QIML Quantum Diffusion Model presentation by Masha Baidachna.</figcaption></figure><p>This symposium was a relatively small group of researchers (~40) primarily focused on quantum information and machine learning. This was the very first workshop on the topic, and it was really cool to see a community of people really passionate about this field being formed. I am excited to be a part of it as it grows and expands in the future!</p><h3>Final thoughts…</h3><p>Overall, GSoC has been an incredibly positive experience. I think my invovlement as a contributor for two consecutive years and hopefully return as a mentor speak louder than words. I would highly recommend applying, particularly to ML4Sci if you’re interested in conducting the most cutting edge research.</p><p>On the technical side, I have gained so much technical experience. Before starting the project, I did not have a good (or any) grasp on what a qubit was. Now, I feel I am able to converse with experts in the field and even contribute with my own views. Additionally, weekly presentations trained me to be able to better communicate some very technical work.</p><p>I want to thank the mentors at GSoC ML4Sci, particularly Isabel Pedraza, Konstantin Matchev, Katia Matcheva, and A special enormous thank you to Sergei Gleyzer for organizing ML4Sci and keeping the QMLHEP group going.</p><h3>All code is open source on my GitHub:</h3><p><a href="https://github.com/mashathepotato/GSoC-Quantum-Diffusion-Model">GitHub - mashathepotato/GSoC-Quantum-Diffusion-Model</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebdf868a6ffa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum data augmentation: resolving bottlenecks in quantum machine learning]]></title>
            <link>https://medium.com/@mashapotatoes/quantum-data-augmentation-resolving-bottlenecks-in-quantum-machine-learning-12bf9acfc037?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/12bf9acfc037</guid>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[quantum-machine-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Sun, 02 Nov 2025 19:48:57 GMT</pubDate>
            <atom:updated>2025-11-02T19:48:57.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Quantum Bottleneck</h3><p>Quantum machine learning (QML) has the potential to significantly accelerate the training and inference of machine learning models. If we can load classical data into quantum computers, the applications would go far beyond quantum system simulations. However, there are a few bottlenecks that persist.</p><p>One of the first bottlenecks in a typical QML workflow is the process of classical to quantum data encoding. Since quantum computers cannot directly read classical data, it must be converted to quantum states. This can be done by several methods: angle encoding, instantaneous quantum polynomial encoding, amplitude encoding, and sinusoidal encoding. Though there is a multitude of methods, many of these are slow, especially for dense data. For the purpose of this example, let’s use Rx rotation gates for data encoding like done in Pennylane:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cMqvAT9BYOd_MGwR" /></figure><p>Due to this extra step that is not present in classical machine learning, QML models evaluated on simulators are faster only in theory. In practice, encoding the data sometimes takes O(n²) time complexity, reducing the speed ups promised by quantum computers.</p><h3>Data Augmentation</h3><p>Data augmentation emerged from the need to augment the existing data by applying certain transformations (or generating new data in the same distribution as the original with the popularity of GenAI). It is commonly applied after preprocessing in the form of rotations, contrast, noise, etc.. Taking inspiration from this idea, we can potentially apply data augmentation techniques to quantum data post encoding. If successful, this would reduce the amont of samples needed to be funneled through the encoding bottleneck and make quantum computers more practically useful for machine learning.</p><h3>Quantum Data Augmentation</h3><p>So how do we apply data augmentation to quantum states?</p><p>Let’s take a concrete example of diffusion and flow matching models on the MNIST dataset. The reasong behind this choice is because it is state-of-the-art for image generation but is computationally intensive to train. An additional perk is that it’s easier to show this idea with image-based datasets.</p><p>Intuitively, we would apply transformations to the original numbers like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/0*8xHcsI23xBrM-qMy.png" /></figure><p>However, when converting this to quantum, this becomes a bit more challenging to do without breaking the underlying structure of the data. Instead, let’s use the fact that diffusion and flow matching models have a forward process that output completely random noise. Then we can augment the fully noised data at the end of the noising process for each sample.</p><p>Using angle encoding and Haar-like noising (a method to randomize quantum states), we would get the following result with n samples for 1 image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZC1zpPqtDRV3NqEI2SZ30A.png" /></figure><p>Then, we can load these into the model only encoding a small (say 100) amount of samples.</p><h3>Learnability</h3><p>This method leaves the question of whether or not variational quantum circuits can still learn the distribution with the data augmentation setup described above. Early results training the model described <a href="https://medium.com/@mashapotatoes/scaling-the-quantum-diffusion-model-e8c15e10e72e">here </a>show that the augmented version decreases loss a lot faster than the original dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvmHe_-AAMgTiJiiS5g58w.png" /></figure><p>The dataset used here is 100 encoded MNIST samples and n=4. So, for every sample, you get 4 scrambled sampels. The next steps would be scaling, evaluating, and experimenting, but this already shows the potential of quantum data augmentation for machine learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12bf9acfc037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling the Quantum Diffusion Model]]></title>
            <link>https://medium.com/@mashapotatoes/scaling-the-quantum-diffusion-model-e8c15e10e72e?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8c15e10e72e</guid>
            <category><![CDATA[quantum]]></category>
            <category><![CDATA[quantum-machine-learning]]></category>
            <category><![CDATA[diffusion-models]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 14:24:07 GMT</pubDate>
            <atom:updated>2025-09-02T15:08:11.192Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is a continuation of my GSoC 2024 work with blogs posted here:</p><ul><li><a href="https://medium.com/@mashapotatoes/gsoc-2024-quantum-diffusion-models-for-high-energy-physics-892e59ddcd3e">GSoC 2024 | Quantum Diffusion Models for High Energy Physics</a></li><li><a href="https://medium.com/@mashapotatoes/gsoc-quantum-diffusion-model-for-high-energy-physics-part-ii-6e693d625931">GSoC Quantum Diffusion Model for High Energy Physics (Part II)</a></li></ul><h3>Recap:</h3><p>In the GSoC 2024 season, I built a quantum and hybrid diffusion-inspired model for generating new high energy physics images. These models were simulated on a scaled down dataset of quark and gluon jets (from 125x125 images to 16x16). Through these initial proof-of-concept prototypes, I’ve been exploring how ideas from quantum computing can reshape the way we think about diffusion models, the state-of-the-art of today’s image generation. Classical diffusion models work by gradually adding noise to data and then training a model to reverse the process. My work looks at whether we can replace some of those classical operations with quantum operations, leveraging the natural randomness and high-dimensional structure of quantum states.</p><p>I’ve experimented with encoding images of jet data into quantum states, scrambling them into state vectors, and reshaping them into forms that resemble what classical diffusion models expect. From there, I’ve been testing whether quantum variations can perform as well as architecturally similar classical models.</p><p>To evaluate this, I’ve been reconstructing data from these quantum encodings and measuring the quality of the results using standard metrics for image quality like FID (Fréchet Inception Distance). Early findings suggest that we can achieve comparable results with the quantum and hybrid models and generate images that are just as high-quality as from the classical model. The advantage here is the potential to speed up training of these models when deployed on a quantum computer.</p><p>The figure below shows the overall workflow and architecture of each model: classical, hybrid, and quantum. From left to right, the flow goes from standard preprocessing to different encoding strategies, to scrambling or noising the data, to learning the parameters required to generate new images from the original distribution. The final step is decoding the encoded generated data and some basic postprocessing. Current work builds on this structure, zooming in on certain features and taking a step back for theoretical support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IiiiakKjAIPQzTEGBeF2SA.png" /><figcaption>Overall workflow and architecture of each model: classical, hybrid, and quantum.</figcaption></figure><p>Despite the progress, some questions remained unsolved:</p><ul><li>Is it scalable? Theoretically and empirically?</li><li>Why are we choosing these particular embeddings/circuits/architectures?</li></ul><h3>Scaling:</h3><p>After building proof-of-concept models at 16×16, the next step was to see whether these methods could scale to more realistic image sizes. For jet physics, higher-resolution representations capture more nuance in the jet distribution.</p><p>The difference becomes very apparent with visuals. The 64x64 crops out a lot of blank space, while keeping the meaningful data on the image. Unlike the 16x16 dataset, there are no images that end up completely blank. The discretized version on the far right in the figure below preprocesses the data further by combining nearest points into one, reducing the complexity. Previously, the discretized dataset was used for simplicity. Current results use the more raw cropped version to keep the physical characteristics of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*hWEhxka3Trbb8ATETqkOAg.png" /><figcaption>Preprocessing steps (from left to right) for 3 samples. The original images (left) show centered jet hits surrounded by a lot of empty space. The 64x64 reduces image size without cropping out significant data.</figcaption></figure><p>The scaling effect propagates onto the next steps of the pipeline. Particularly, the encoding and scrambling parts. Again, there are no blank encoded channels with the 64x64, forcing every data point to contribute to the training in some way. The scrambled data is then produced by applying the Haar measure unitary to each channel, producing completely random noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztG_1VICnzLT7jMRVDqYNw.png" /><figcaption>Two samples of encoded and scrambled data pictured by channel.</figcaption></figure><p>Paradoxically, the results after training are interesting because of being anticlimactic. The training curves converge after about 50 epochs for the classical, hybrid, and quantum models. The generated samples are reasonably distributed without mode collapse. The mean samples are consistent with the original distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rZf8TxxUYvfY8mzXzbiLkw.png" /></figure><p>The FID score was calculated for the final generated distribution of 1k images against randomly selected 1k original images. The starting FID for each model of 64x64 images is around 3000. The drop to around 2 for each model indicateds similarity between distributions increases significantly with training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fmLRVj2AjKUP49Y_F1J9rw.png" /><figcaption>Final FID scores table.</figcaption></figure><p>In short, the results are remarkably similar to the 16x16 experiments. This is good news, as it shows that there is no significant decay with quality as the dataset is scaled.</p><h3>Complexity:</h3><p>In practice, scaling a diffusion model from 16×16 to 64×64 is an increase in resolution, where the number of pixels grows by a factor of 16, and because diffusion requires applying the denoising network at each of T steps, the total compute grows roughly as O(T⋅N), where N is the number of pixels. For classical U-Nets, this means significantly more memory and training time.</p><p>With quantum variants, the trade-off looks a bit different. Encoding 64×64 jets into quantum state vectors requires more qubits, but once encoded, applying unitary scrambling scales polynomially with the number of qubits O(n²) rather than directly with the pixel count. The reverse process still relies on a quantum circuit for denoising, so it is several orders of magnitude more expensive to simulate than a classical network. Analyzing the complexity of the quantum “network” is still a work in progress.</p><h3>Embedding comparison:</h3><p>The time and space complexities of possible embedding methods for our use case have been scrutinously compared. When working with<strong> </strong>64×64 images,<strong> </strong>which correspond to 4096 pixels, choosing the right quantum embedding becomes a trade-off between efficiency, expressiveness, and practicality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1lBrg2GaPU3RpD8ah0VEA.png" /><figcaption>Angle, amplitude, and IQP embedding methods.</figcaption></figure><p>The most straightforward method is the angle encoding (Rx or Ry rotations). It scales as <em>O(p²)</em> and requires p² qubits — that’s 4096 qubits for 64×64 data. It’s not qubit-efficient, especially given that our jet data is highly sparse, but it has the advantage of being simple to implement. In fact, this is the approach that has worked reliably for us so far, even if it’s not the most resource-friendly.</p><p>A more compact alternative is amplitude encoding. It also has <em>O(p²)</em> complexity, but instead of thousands of qubits, it only needs log₂(p²) = 12 qubits for our 64×64 case. This is a huge saving in terms of hardware. There’s also the potential to amplify meaningful entries using Grover-based state loading, which could make it especially powerful for sparse data. The cost can be reduced further if we assume a sparsity measure <em>s</em>, since most entries carry little information.</p><p>Then there’s IQP (Instantaneous Quantum Polynomial) embeddings, which are far more expressive. They scale as <em>O(N²) = O(p⁴)</em> and require 4096 qubits for our images. This expressiveness comes at a steep cost, so to make it feasible, they need to be applied in patches or in a sparsity-aware way. The idea here is to only apply IQP transformations to the “active” features, where the data is actually meaningful, and leave out the rest.</p><p>Another approach we’ve looked into is sinusoidal embedding, inspired by the positional encodings commonly used in transformer models. Like some of the earlier methods, it has a cost of <em>O(kp²)</em> and requires p² qubits — 4096 in the 64×64 case.</p><p>For sparse data, the cost can drop all the way to <em>O(s)</em>, since we only need to encode the non-trivial entries. In practice, this means that instead of treating every pixel as equally important, we only apply sinusoidal encodings to the regions of the data where meaningful structure actually exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ysnEPHGfP3bzAD5mHp-Ng.png" /><figcaption>A table of four types of embedding comparisons for classical to quantum data. The analysis includes time complexity and qubit efficiency for raw 64x64 data, where p=64 in this case, and sparsity-aware data.</figcaption></figure><p>In practice, we could encode only the non-trivial parts of the data. Given that the sparsity measure of our raw 64×64 jet data is over s = 0.99 at all preprocessing steps, this route looks particularly promising, since 99% of the data carries no useful signal information.</p><p>In summary, while angle encoding has been the reliable workhorse so far, amplitude and sparsity-aware approaches are where the real efficiency gains lie. How each encoding works in practice remains to be seen.</p><h3>Other achievements:</h3><ul><li><strong>EEML poster presentation:</strong> the quantum diffusion model work was accepted to be a poster presentation at the Eastern European School of Machine Learning (EEML) run by Google Deepmind. The work won a Best Poster award in the applications category.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k1zU-VzTeIUv6n9yPtYX5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQ0kPratQHfCSzaIK1mXpQ.jpeg" /></figure><ul><li>Paper submitted and accepted to <strong>AAAI QIML</strong> archival symposium.</li></ul><h3>Future goals:</h3><ul><li>Empirically compare the time complexity and quality of different embedding versions.</li><li>Find and try a compatible quantum computer to strengthen empirical results.</li><li>Expand on theoretical foundations of choosing parts of the models beyond the first encoding step.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8c15e10e72e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Quantum Diffusion Model for High Energy Physics (Part II)]]></title>
            <link>https://medium.com/@mashapotatoes/gsoc-quantum-diffusion-model-for-high-energy-physics-part-ii-6e693d625931?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e693d625931</guid>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 15:44:46 GMT</pubDate>
            <atom:updated>2024-11-04T15:52:01.127Z</atom:updated>
            <content:encoded><![CDATA[<p>My name is Masha, and this is my second blog for what I’ve done for ML4Sci as part of Google Summer of Code this year.</p><p>Part I: <a href="https://medium.com/@mashapotatoes/gsoc-2024-quantum-diffusion-models-for-high-energy-physics-892e59ddcd3e">https://medium.com/@mashapotatoes/gsoc-2024-quantum-diffusion-models-for-high-energy-physics-892e59ddcd3e</a></p><p>All my code is open source: <a href="https://github.com/mashathepotato/GSoC-Quantum-Diffusion-Model">https://github.com/mashathepotato/GSoC-Quantum-Diffusion-Model</a></p><p>All quantum ML4Sci projects: <a href="https://github.com/ML4SCI/QMLHEP">https://github.com/ML4SCI/QMLHEP</a></p><h3>Recap:</h3><p>This blog assumes the reader is familiar with the previous part that includes diffusion model overview, variational quantum circuits in diffusion models, the quark and gluon dataset description, detailed preprocessing/quantum encoding, and some preliminary results. Here is a short recap up to the midterm update on the previous work that was completed.</p><p>What worked:</p><ul><li>Quark and gluon data preprocessing</li><li>Classical diffusion model on MNIST</li><li>A simple classical model on quark and gluon dataset</li><li>A classical Gaussian noising and quantum U-Net hybrid model</li></ul><p>What didn’t:</p><ul><li>Attention-enhanced U-Net architecture (produced weird patterns and did not learn)</li><li>Fully quantum model (hybrid variants only)</li><li>The FID was jumping from 250 to near-zero despite similar performance (this was occuring due to the flip function and was patched)</li><li>A form of mode collapse or very similar generated images</li></ul><h3>Model Architectures:</h3><p>Given that diffusion models can be split into noising and denoising, we can use different methods for doing each and mix and matching them to create new models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LzwxHyDzmqw7hpYu2ndQA.png" /><figcaption>A diagram illustrating different combinations of blocks a diffusion model can be made of.</figcaption></figure><h4>Forward Noising:</h4><p>Forward noising in a diffusion model, whether classical or quantum, is simply an arbitrary degredational transformation. The work in [1] showed that the choice of transformation that is applied does not strongly affect the model’s behavior. Our experiments with Haar measure and Gaussian noising are consistent with these findings. Therefore, it is best to choose the method most suited to the hardware requirements. For the purposes of making a fully quantum model, we use Haar measure scrambling for all experiments that require quantum noising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NvHPcoiaBLW3uyyYIFUzw.png" /><figcaption>The forward Gaussian process in a classical model becomes the Haar measure that sends each quantum state to random points on a Bloch sphere.</figcaption></figure><h4>Hybrid Denoising:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYn6E2CmX3i5IKSkgs7btg.png" /><figcaption>The denoising process introduces quantum layers into the classical UNet architecture</figcaption></figure><p>The denoising process follows a U-Net architecture with downsampling and upsampling, but a strongly entangling layer is introduced. It is implemented in Pennylane and applies quantum rotation operations followed by CNOT gates for entanglement over each qubit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JSjxdNrPv4Znn-laE5w6g.png" /><figcaption>Quantum layer preceded by quantum encoding on a 4 qubit example.</figcaption></figure><h4>Fully Quantum Denoising:</h4><p>The fully quantum model consists of purely quantum layers. Similar to classical diffusion models, the denoising neural network is trained on learned parameters with a classically computed loss function. The hybrid model uses a quantum strongly entangling layer surrounded by fully convolutional layers, but the fully quantum model relies only on the quantum layers. The circuit in the quantum layer, consisting of rotation and strongly entangling gates, is kept uniform across all models, with the number of layers treated as a tunable parameter.</p><h4>Loss Functions:</h4><p>The loss function originally used is the standard mean squared error (MSE) loss function. However, as new metrics are introduced, a custom loss function should be developed to steer the model towards performing well on those metrics. This could be a weighted sum of the MSE and another indicator that answers for structural similarity of individual samples to form a custom function. Metrics specific to high energy physics data, like the ones defined in [2], would be the most interpretable in this scenario.</p><h3>Experiments:</h3><p>In each experiment, we compare the performance using the Fréchet Inception Distance (FID) and the loss function. We also experimented with the Wasserstein-1 distance, which is a baseline metric for comparing original and generated distribution on high energy physics data, and the Structural Similarity Index, which compares the individual data points to the original.</p><h4>Sample quality:</h4><p>Though the loss functions and the FID computed throughout training are good indicators of the model learning, the quality of the generated samples ultimately determines the model’s performance. In the figure below, the model generates very similar images, especially the fully quantum model in the bottom two rows. Seeing this, we decided to conduct some experiments to test for mode collapse or any patterns the model may be learning where the original data looks more random.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNFcyglFp0hZwYt7t-e5sQ.png" /><figcaption>Loss and FID functions throughout training for classical (top), hybrid (middle), and quantum (bottom) models. On the right are the respective generated samples, two for each model, with the first four columns being the channel encodings described in Part I.</figcaption></figure><p>First, we tuned the hyperparameters and the quantum layer parameters from 50 epochs, 4 qubits, 6 quantum layers to 300 epochs, 8 qubits, and 8 quantum layers. The generated samples of the resulting model also converge to a similar FID of around 2, but the visualization and post-processed (noiseless) points mimic the randomness of the original data much more closely. While the model learns the distribution of the original data, the generated samples are different from each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PQ6Bu1bKMzHJ9dvy" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMzq0rPxcRRggwApVdV-nQ.png" /><figcaption>A subsection of generated samples of the final model (left) and the corresponding fully denoised samples (right).</figcaption></figure><p>We also tried training the model separately on quarks and separately on gluons, which yields the following results:</p><p>Quarks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cmvuGFFfkeEUat4agiBHQ.png" /></figure><p>Gluons:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWRoZntsNRydOiWaM6W-dA.png" /></figure><p>These are very similar to model trained on the entire data simultaneously, implying that the choice of distribution (only quarks or only gluons) in this case makes no significant difference.</p><h4>Evaluation metrics:</h4><p>Furthermore, the table compiled below shows all the experiments conducted with additional metrics: Structural Similarity Index Metric (SSIM) and Wasserstein distance (also known as Wasserstein-1 and FID is Wasserstein-2). The models tested here differ in training size, number of qubits, and number of quantum layers. There are two values for each metric: the raw generated output and the post-processed output. It’s clear that post-processed metrics will be better, but the difference between them becomes less significant when the model itself is better.</p><p>Throughtout most of the time, FID was the only quantitative metric used, and the models were tuned to lower the FID. This explains why FID shows the best results of the three metrics. The SSIM is a common benchmark metric for generative models, but it may not be beneficial here as the sparsity of the quark and gluon jet distribution makes it difficult to compare structural similarity. The Wasserstein distance is defined by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcL2ksla2hRAegLv5ukHdg.png" /></figure><p>where γ is the function giving the amount of mass to move from x to y. It is similar to the FID in the way that it measures similarity between distributions, and it performs similarly for different parameters as well.</p><p>The optimal model that was shown above is in bold. Notice that the increase from 100 to 1000 samples with constant qubits and layers only makes a marginal difference in model performance. This can be further explored to see if quantum variants converge faster with less data than classical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZMOMJ3VIbQexqOLxrYNcw.png" /><figcaption>Table showing experiments of how different parameters affect the quantitative metrics.</figcaption></figure><h4>Scaling:</h4><p>Note that the model scales both with increasing the number of data points and the number of pixels in images. However, the model can be adapted to any dimensions by changing the patch size. To test performance on scaled data, a 1000 image 64x64 subset of the original quark and gluon dataset was curated. The forward Haar-based process ran with no problems, producing these scrambled images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrWKk3PvTWfPKscxv3YD5A.png" /></figure><p>However, no meaningful parameters for the denoising process were reached due to kernel crashes. A 16 image subset trained on 50 epochs (stopped before convergence full) generated the same images for every new sample, likely due to the fact that the training data was not large enough to contain enough diverse samples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0CgSUU1k-RIQq1Vf2fPhQ.png" /></figure><p>This is an area to explore in the future with upgraded hardware. If the 64x64 experiments produce acceptable results, we can scale to the original 125x125.</p><h4>Normalization:</h4><p>Another area of experimentation was changing the way the dataset was preprocessed. So far, we’ve been using a cropped and discretized dataset. The cropping function takes a block to take the average of, thus keeping as much information as possible. Here are some potential crop fractions and how the original and discretized data looks for each:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKQ3NrESCuAElaqu5CibOA.png" /><figcaption>The original data under different crop functions. The top row is non discretized and the bottom row is discretized.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*egDc38VxZjECr6m389F7mw.png" /><figcaption>The mean of the original data in non discretized (left) and discretized (right) formats.</figcaption></figure><p>The main difference between the two is the amount and intensity of jets recorded in each image. Though the final results use the discretized version, we tested the fully quantum model on the non-discretized dataset as well. The results are trained on 100 samples with 4 qubits and 6 layers. The discretized version has a final FID of 10.2744 and the raw data is 20.9577. The jump in FID indicates the model may not perform as well on raw data, but it is under conditions that favor the discretized data and could be adjusted based on requirements. Here are the generated samples for the non-discretized results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKIFLtGewYP36Pp-eivAbA.png" /></figure><p>Note that the post-processing would need to be adjusted to not discretize the image at the end but take the spectrum of the top jets.</p><h3>Conclusion:</h3><p>Quantum diffusion models have been largely relying on hybrid architectures and evaluated on datasets lacking complexity. This work has ventured into previously unexplored areas of developing a fully quantum diffusion model for complex high energy physics data with potential to be scalable. Moreover, this project has contributed to the open-source community of researchers.</p><p>This is the conclusion of the blog and the 2024 GSoC program, but the work on quantum diffusion models will continue. We have been working on finalizing the results and publishing the work. We’ve been accepted for the ML with New Compute Paradigms workshop at NeurIPS, and the paper and the poster will be available on Openreview in the upcoming months. There will always be directions to extend the work into, so here are a few:</p><ul><li>Test on a quantum computer</li><li>Try other simulation frameworks in addition to Pennylane. For example, TensorCircuit would be compatible with Google Colab, so more computationally heavy experiments could be done</li><li>Scale up and run on upgraded hardware</li><li>Conclude which loss function (MSE vs custom) is best (work in progress)</li></ul><h3>Acknowledgements:</h3><p>A huge thanks to Sergei Gleyzer for his time and expertise in organizing and leading ML4Sci. I would also like to extend a thank you to all who provided valuable comments and suggestions in the QMLHEP team, especially the mentors Konstantin Matchev, Katia Matcheva, Abhay Kamble, Gopal Dahale, Tom Magorsch, Isabel Pedraza, and Rui Zhang.</p><h3>References:</h3><p>[1] Bonsal et al., Cold Diffusion: Inverting Arbitrary Image Transforms Without Noise. <a href="https://arxiv.org/abs/2208.09392">https://arxiv.org/abs/2208.09392</a></p><p>[2] Kansal et al., Evaluating generative models in high energy physics. <a href="https://arxiv.org/pdf/2211.10295">https://arxiv.org/pdf/2211.10295</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*YO1gl5ZcSGUbcgUg6fFzKg.png" /><figcaption>Adobe Firefly: scientist cat doing physics and machine learning</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e693d625931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC 2024 | Quantum Diffusion Models for High Energy Physics]]></title>
            <link>https://medium.com/@mashapotatoes/gsoc-2024-quantum-diffusion-models-for-high-energy-physics-892e59ddcd3e?source=rss-e957fb28b112------2</link>
            <guid isPermaLink="false">https://medium.com/p/892e59ddcd3e</guid>
            <category><![CDATA[quantum-machine-learning]]></category>
            <category><![CDATA[diffusion-models]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Mariia Baidachna]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 20:54:52 GMT</pubDate>
            <atom:updated>2024-08-15T20:54:52.912Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m Masha Baidachna, a contributor for ML4Sci as a part of Google Summer of Code, and I am building a quantum diffusion model. This is a mid-project update on what I’ve done so far.</p><p>All code is open source and is available here: <a href="https://github.com/mashathepotato/GSoC-Quantum-Diffusion-Model">https://github.com/mashathepotato/GSoC-Quantum-Diffusion-Model</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvAHREk0GVCpwhOSBpdvVQ.jpeg" /></figure><h3>Motivation</h3><p>Diffusion models (DM) have recently exploded in popularity due to their high quality and realistic image generation. They are also less prone to mode collapse, the problem of generating the same image, unlike Generative Adversarial Networks (GANs) that are also used for image generation. A variation of diffusion is used in some of the most popular text-to-image generative systems, such as DALL-E2, Midjourney, and Adobe Firefly, with immense success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sc--uPYh-POlz2QqmxSVdw.jpeg" /><figcaption>Adobe Firefly prompt: A cat that is a research scientist with glasses studiously floating through space.</figcaption></figure><p>However, there are some major drawbacks of DMs. The biggest is perhaps extensive training time on millions of data points, especially when combined with text-based generation. To train a model, thousands of powerful GPUs are run for many hours, contributing to costs, power usage, and the carbon footprint. This is where the quantum bit (aka qubit) comes in (no pun intended).</p><p>Quantum computing has the potential to speed up many tasks, including machine learning algorithms. By replacing classical bottlenecks withd quantum operations, we can manipulate qubit states that can hold more information than 0s and 1s and achieve faster training time on less data.</p><h3>How Diffusion Models Work</h3><p>Classical DMs have two main steps: noising and denoising. The forward noising step applies random noise incrementally, and the backward denoising step is where the model learns to generate the original image with some variation, resulting in a new image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lvpPI6o3N-z9AEW93ih1Q.png" /></figure><p>Mathematically, the Gaussian noise schedule is applied linearly or exponentially at each time step T by the following function, where the normal (N) noise is added to each point based off the previous point at t-1.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8__pycLkqHDHdV3wgY2gmA.jpeg" /></figure><p>The scheduling is important because the model learns the noise distribution between each step. Then the predicted noise is removed and we are left with a slightly better defined image. Intuitively, this is easier than trying to predict the original image from a completely noised image in one step. However, the problem with predicting small amounts of noise for each time step is that the same process needs to be used for inference. If T=1000 was used for training, the inference will have to go through 1000 steps, and there is no way to speed it up. Instead, DMs predict all the noise at each time step that take it to the original image, thus being able to predict images from any t and not needing to go through each step at inference.</p><p>The denoising step most commonly uses a U-Net architecture with downsampling and upsampling of the data in the process. A cross-attention mechanism is often used between the text prompts and the generated images in stable diffusion models. However, the task of generating QG jets does not require an additional large language model attachment, so attention could be used differently. For example, it could be taken across the three QG channels and/or across previous images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHYQ_uav_s0Onf6ajXWDIw.png" /><figcaption>Source: <a href="https://medium.com/@kemalpiro/step-by-step-visual-introduction-to-diffusion-models-235942d2f15c">https://medium.com/@kemalpiro/step-by-step-visual-introduction-to-diffusion-models-235942d2f15c</a></figcaption></figure><p>Before beginning to work with the high energy physics datasets, a classical DM was built and tested on the MNIST dataset. This is a commonly used dataset of 60k images belonging to 10 classes of digits from 0 to 9. Though this is a toy dataset, the difficulty here are the 10 different distributions which were accounted for by the model. It uses the U-Net structure described above with the following results after a few hours of training locally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*cIEjb5_ZcjLCXSeQeMXIPg.png" /></figure><p>The dataset was cropped to 16x16 from the original 28x28, but the resolution is high enough to see distinct numbers being generated from random noise.</p><h3>LHC Jet Data</h3><p>There are two main datasets considered in this work: Quark-Gluon (QG) jets and Electron-Photon jets. As of right now, only the QG dataset has been tested on. It is made up of ~100,000 data points with X and Y columns. Column X represents the 125x125 matrices that can be plotted as images and Y is a column vector of 0s and 1s for the labels. There are three detectors used to measure different properties of QG jets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*2-7kL_GH326E41miFDe4QA.png" /><figcaption>The mean QG jets of channel 1.</figcaption></figure><p>Though we are not focusing on classifying quarks and gluons, it is still important to note that their distributions are different due to differences between particles. For example, gluons have more color charge and less electric charge. This means the model must be built considering labels of 0s and 1s (the two quark and gluon classes) and separate channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*2V8I4krrWYO_Ar3o" /></figure><h3>Data Preprocessing</h3><p>To lighten the load of initial model testing, the QG dataset was cropped and normalized. At first, 3x3 dimensions were chosen, but the visualized samples made it clear that the size is too small to capture meaniningful data due to some points being entirely empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PUZUUt6lmaDLGUhe" /></figure><p>Therefore, a cropping of 16x16 was chosen to capture more jets within one point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QjlfdHNBlm7nN0hkkNNFcg.png" /></figure><p>The same process can be applied to all three channels of the QG dataset.</p><p>After preprocessing the QG data and successfully generating MNIST digits from a previously built DM, the next natural step was to modify the dimensions and parameters of the existing DM to only include two classes and attempt to generate the QG jets. However, after experimenting with different noising schedules and multiple hours of training, the model did not seem to learn the QG distributions. The output always looks like random noise generated at the last step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*ohODYsrwh-AZsXJ5" /><figcaption>A sample of the QG data point during noising with T=80.</figcaption></figure><p>This may be attributed to the fact that the QG dataset, unlike the MNIST dataset, is very sparse. The original image is divided into 0s and 1s and the noise actually makes the image more complex rather than simplifying it with random Gaussian values. In conclusion, a different architecture would have to be employed that would capture the complexity of the QG distribution while keeping the simplicity of QG jets.</p><h3>Paper Recreation</h3><p>There has been previous research on quantum DMs (QuDMs). The method proposed by Zhang et al. for a quantum Denoising Diffusion Probabilistic Model (QuDDPM) uses quantum scrambling and denoising in order to predict the original unknown distribution of quantum states. This is represented on a Bloch sphere in the following diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*9OmPnAbR1OosQg1S" /></figure><p>Briefly, the forward diffusion process involves applying random unitaries to each state in the distribution with the goal of generating a single Haar random state or a K-design state. Similarly to the classical variant, there are T “time steps”, only this time they define the unitary U applied to the state so that the given ensemble S reaches a random distribution at k=T.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*v2FLUPIOxkZEzX2WJLrVXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzvTpnzY-hWoU-2n3qfKBw.png" /></figure><p>The paper uses Tensorcircuit and Jax to accomplish this, but this work uses Pennylane for all quantum simulations and Pytorch for neural network related modules. With this in mind, the paper was recreated using Pennylane and Pytorch as well and may not be a perfect replication. However, the main idea with the forward diffusion remains the same, with the following code generating fully scrambled quantum states. Here is our result for two sample distributions being scrambled into random states for T=250.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vols2sSi58PXVkI2aAfkZQ.png" /></figure><p>The entire QuDDPM architecture uses two quantum circuits: one for forward diffusion via scrambling and another for backward denoising via measurement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OR5TTooOvfhsfbzPiJmGig.png" /></figure><p>In the code made public by the authors, the backward step applying a random measurement is iteratively called by the prepareInput_t function like so:</p><pre>def backwardOutput_t(self, inputs, params):<br>    &#39;&#39;&#39;<br>    Backward denoise process at step t<br>    Args:<br>    inputs: the input data set at step t<br>    &#39;&#39;&#39;<br>    # outputs through quantum circuits before measurement<br>    output_full = self.backCircuit_vmap(inputs, params) <br>    # perform measurement<br>    output_t = self.randomMeasure(output_full)<br>    return output_t<br><br>def prepareInput_t(self, inputs_T, params_tot, t, Ndata):<br>    &#39;&#39;&#39;<br>    prepare the input samples for step t<br>    Args:<br>    inputs_T: the input state at the beginning of backward<br>    params_tot: all circuit parameters till step t+1<br>    &#39;&#39;&#39;<br>    self.input_tplus1 = torch.zeros((Ndata, 2**self.n_tot)).cfloat()<br>    self.input_tplus1[:,:2**self.n] = inputs_T<br>    params_tot = torch.from_numpy(params_tot).float()<br>    with torch.no_grad():<br>        for tt in range(self.T-1, t, -1):<br>            self.input_tplus1[:,:2**self.n] = self.backwardOutput_t(<br>                                                  self.input_tplus1, <br>                                                  params_tot[tt])<br>    return self.input_tplus1</pre><p>The results after training are visualized in the following graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*kRB7ogYiu-OnffzagtEzWQ.png" /></figure><p>The paper focused on comparing different quantum models to each other, so the training pictures QuDDPM, quantum generative adversarial networks, and quantum direct transport, with QuDDPM showing promising results. Conversely, in our work on the QuDM, we are working with classical data and comparing the results to a classical DM.</p><h3>Quantum Embedding</h3><p>Before feeding the QG data into the quantum model, it must be converted to its respective quantum representation. While there are multiple quantum embedding techniques to choose from, encoding angle rotations with Rx rotations had been previously successfully used by Cara et al. (paper: <a href="https://arxiv.org/pdf/2405.10284">https://arxiv.org/pdf/2405.10284</a>) for the QG dataset in the following variational quantum circuit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIIcoCxEYz-LlFZXkYUfeQ.png" /></figure><p>This work also uses Rx rotations for angle encoding, but on 2x2 patches obtained from applying a grid on the QG data. Each 16x16 image is then reordered as 64 2x2 squares, where each square can be represented by a single quantum state after angle encoding is applied. This method is largely follows Pennylane’s tutorial on Ry encoding on the MNIST dataset for quanvolutional neural networks (source <a href="https://pennylane.ai/qml/demos/tutorial_quanvolution/">https://pennylane.ai/qml/demos/tutorial_quanvolution/</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xiEK6wH-0_GxmueD.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*kxmI7Hk67bkhJ0sdFPM7Dw.png" /></figure><p>As a result, we get four 8x8 channels for each sample. Now, the data is in a usable format to apply quantum operations to in the QuDM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsCc1KMx26XG2JSGLiFLrg.png" /><figcaption>Sample QG data point before and after angle encoding.</figcaption></figure><h3>Proposed Architecture for QuDM</h3><p><strong>Forward Diffusion:</strong></p><p>Inspired by the work of Zhang et al., random unitaries in a Haar distribution were applied to each embedded quantum state to scramble the distribution into random noise of four embedded channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKb601ZGmWLLSWlPXuFRjQ.png" /><figcaption>Scrambled states from the same sample as the angle encoding example above.</figcaption></figure><p><strong>Denoising:</strong></p><p>The denoising step originally proposed in the QuDM is a U-Net where the attention block at the bottom of the U is replaced with a quantum attention block that uses a variational quantum circuit. However, as suggested by one of the mentors, <a href="https://tommago.com/">Tom Magorsch</a>, a fully quantum model would be a better goal for the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msPDY39CiQS73fAAL8CjzQ.png" /></figure><p>The model presented here uses three classical fully convolutional layers and one quantum layer with this circuit, where the first Rx gates are angle embedding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Myowgpo6D7w5FO8" /></figure><p>In the future, more layers will be implemented with variational quantum circuit, making it fully quantum and more scalable.</p><p>At first, results weren’t very promising. The generated channels mostly contained random noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yv_zMs6vnnDjywzM3d5b6g.png" /></figure><p>Then after increasing the learning rate from 0.001 to 0.01 and some other hyperparameter experementation, the model started generating plausible output with some noise in the fourth channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99A9f1tpx9hi66LcwUT7Fw.png" /></figure><p>Some structural changes were made to improve this result. Dropout layers were added in between fully convolutional layers and the dataset was expanded. The resulting generated sample improved the fourth channel noise that was happening before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAQ_PJ0H8vo0Mq6TEellkw.png" /></figure><p>The training was conducted with the Adam optimizer and the MSE loss function is plotted below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*_qQ8SuBbO0h2_D08va_a8w.png" /></figure><p>For a more quantitative evalutation of generative models, FID is a commonly used metric. Though some research critiques its lack of standardization and possible bias, it is sensetive to both quality and mode collapse, though it weights quality much higher when the FID score is high. It is represented by the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CIdroit4th8DQLi_.png" /></figure><p>The FID builds on an earlier metric called inception score, which was used to measure the distribution of generated images, but it adds the comparison between the real and generated results (subscripts r and g in the formula above). The trace of the matrix expressed in parentheses indicates that if the sum of the diagonals, or the sum of the eigenvalues, is large in magnitude, then the FID score is also large and the image is more distorted. The code uses the following trace addition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*tgoSkuce9boaFc-qrWY_UA.png" /></figure><p>to calculate the FID with the following functions:</p><pre>def calculate_statistics(data):<br>      data = data.reshape(data.shape[0], -1)  # flatten images<br>      mean = np.mean(data, axis=0)<br>      covariance = np.cov(data, rowvar=False)<br>      return mean, covariance<br><br>def calculate_fid(mu1, sigma1, mu2, sigma2, eps=1e-6):<br><br>    diff = mu1 - mu2<br>    covmean, _ = scipy.linalg.sqrtm(sigma1 @ sigma2, disp=False)<br>    if np.iscomplexobj(covmean):<br>        covmean = covmean.real<br>    <br>    fid = diff @ diff + np.trace(sigma1) + np.trace(sigma2) - 2 * np.trace(covmean)<br>    return fid</pre><pre>mu1, sigma1 = calculate_statistics(data_X)<br>mu2, sigma2 = calculate_statistics(decoded_data)</pre><p>The final FID value calculated using this method is 2.381 after training the QuDM for 50 epochs. The decoded data (far right) needs to be flipped with a (1-data) operation in order to represent the dataset better, hence the opposite color change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHg0MO18Psk1rkTdaBkDJA.png" /></figure><p>This model was trained on only 100 QG data points, so it’s likely not performing to its full potential. Also, although the final FID is low, it always converged to generating the middle jet, rather than spreading out according to the jet distribution. Some modifications of this architecture with experiments are outlined in the next section.</p><h3>Experiments</h3><p>Now that we have classical and quantum noising, as well as classical and quantum denosing, we can mix and match these blocks to experiment with different architectures.</p><p>First, let’s take the quantum noising and classical denoising. This means that we are encoding the dataset into quantum states, then noising it with Haar measurements, then feeding it into a classical U-Net. At this point in time, I increased the dataset size to 1000 for all subsequent models and added an 80/20 training/validation split for more robust training. The training and validation loss and the FID are decreasing reasonably, with the FID closely following the validation loss trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KAt1OmmbH69VAGw-" /></figure><p>The random samples generated from the image are fairly diverse channel by channel, but again, the decoded image seems to average out in the middle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*G5lJpa3TxTktV4o-" /></figure><p>The next model is classical Gaussian noising and fully quantum denoising. The denoising network contains no classical layers at all, making it very scalable. This model also showed reasonable loss graphs, but an oscillating FID graph that converged around 250.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Co2d0KJ68w-uavFk" /></figure><p>The results from the sample generation were quite good despite the FID. The samples appear diverse and almost completely denoised. At this point, the models are nearly ready for comparison to the classical counterpart and some advantage measurements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*xldAio6BYgVXeUuNsutOkg.png" /></figure><p>Here are the argmax of the samples above. A different method needs to be written to display multiple jets other than the strongest one, but this is an example of what 10 samples of QG jets would look like after some rule-based denoising as post-processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BM7XL635qJc5KTVy" /></figure><p>At this point in time, the classical noising-quantum denoising is the best performing hybrid model even though it has not yet been finetuned or trained on the full QG data.</p><h3>Classical Counterpart</h3><p>In order to be able to draw conclusions on the QuDM performance, we need a similar classical architecture to compare it to. It is also worth remembering that the DM that performed well on the MNIST dataset did not work on the QG dataset, so structural changes had to be made either way. The new architecture followed the QuDM architecture exactly with the exception of the quantum circuit and quantum embedding. The random Haar unitaries became Gaussian noise with a linear scheduling function. However, training directly on the 16x16 QG data proved futile as the resulting generated images were just random noise.</p><p>An alternate approach was employed where each 16x16 image was broken down into four channels of 8x8 images. This method is very similar to the quantum embedding, but it does not use any quantum operations. It only reshapes the data and presents it in a different form to the model. The generated result is also four channels per image, and a decoding function combines the four channels into one 16x16 decoded image.</p><p>This new preprocessing worked much better, with the DM’s loss function decreasing as expected and the generated samples looking more like the original data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*HgrfG0mxuKNvbk3kl9LVoA.png" /><figcaption>Classical DM training loss over 300 epochs.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNv084JcjEuy5prWzxA_6Q.png" /><figcaption>Five classically generated samples (far right) with their respective encoded channel generations (four left).</figcaption></figure><p>The FID computed after the final iteration for these results is 1.526. This is comparatively low considering image datasets rarely achieve an FID below 2, but there isn’t a standardized threshold for the FID across all generative models. This may be due to some datasets, such as the QG dataset, being very different from a typical images (e.g. faces) dataset. It is much more sparse and binary within each channel. In the future, it may be helpful to graph the FID trend over steps to see how it changes as the model is trained.</p><p>It is important to note that the decoded results from this fully classical model look similar to the hybrid model with a fully quantum U-Net, meaning the models are coming to similar conclusions with different algorithms.</p><p>Additionally, the classical model’s training time is much shorter than that of the QuDM due to the fact that quantum simulations are notoriously slow. The consequence is that it is easier to experiment with the classical DM on larger datasets without having access to powerful hardware.</p><p>The classical model was also tested on the three QG channels from different detectors. Here are sample generated results from all three channels side by side, with the first channel from the results above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uF1ytrkkMui2bglnP3kC1w.png" /></figure><p>The model was trained on the same hyperparameters (epochs, batch size, learning rate, etc), but shows different amounts of noising in the final images for each. This may be a problem when training the model to generate three channels per sample in the future.</p><h3>Attention Block</h3><p>So far, we have only used fully convolutional U-Net architecture. Although the original U-Net proposed by <a href="https://link.springer.com/chapter/10.1007/978-3-319-24574-4_28">Ronneberger et al.</a> in 2015 does not use any attention blocks, more recent works have seen success when planting attention between layers in between fully convolutional layers like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aGG3l3ZgmQDy4kcB.jpg" /><figcaption>Source: <a href="https://idiotdeveloper.com/attention-unet-and-its-implementation-in-tensorflow/">https://idiotdeveloper.com/attention-unet-and-its-implementation-in-tensorflow/</a></figcaption></figure><p>In the case of the QG dataset, adding self-attention blocks in between layers did not work that well. In the classical model, the training and FID would jump to really high values and not converge afterwards (with the final FID hovering around 250).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sc78YyXNaFgeiwq6" /></figure><p>The generated results are correspondingly off. All the random samples generated are the same, displaying a type of mode collapse, and the final decoded images are not an accurate representation of the dataset distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*tw3-22Mk3E3yxMVT" /></figure><p>Similar results were displayed when using the hybrid model with quantum scrambling and a classical U-Net with self-attention. Again, the FID hovers around 200 and the loss stays the same after the spike around the 2nd epoch. The generated results are consistently unrepresentative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*We17yrqJZoQCQRaz" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/0*DZuI6KzgXP89ZxDI" /></figure><p>A few reasons as to why this may not be working as expected is due to the sparsity of the values within each sample. Since the self-attention is taken over each individual sample here rather than over the channels, most of the dot products computed would be the same value. Though computing attention this way may not work, trying cross-attention over the encoded channels or over the three detector channels would be worthwhile experimenting with.</p><h3>Conclusion and Future Directions</h3><p>In conclusion, a lot of progress has been made throughout this project towards developing a fully quantum DM and implementing a custom classical DM for high energy physics data, specifically the QG jets dataset.</p><p>Though considerable progress has already been made, there are many ways to build on this work and expand the results. The future directions of this project to be accomplished within the given timeline are the following:</p><ul><li>Train the models on all channels, generating three channels for one sample</li><li>Experiment with cross-attention over the three channels of the QG dataset</li><li>Combine the hybrid models into a fully quantum model</li><li>Experiment with the noising process and scheduling in the quantum model (e.g. Gaussian transformations via Gaussian circuit)</li><li>Experiment with different quantum embedding techniques (e.g. amplitude encoding)</li><li>Scale up → expand the dataset size, increase cropping dimensions, train on better hardware if available</li></ul><h3>Acknowledgements</h3><p>I want to thank Sergei Gleyzer for organizing and leading ML4Sci. I would also like to extend a thank you to all who provided valuable comments and suggestions, especially my mentors Abhay Kamble, Gopal Dahale, Tom Magorsch, and Rui Zhang.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892e59ddcd3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>