<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mushahid Intesum</title>
    <description>The latest articles on DEV Community by Mushahid Intesum (@skondho_kata).</description>
    <link>https://dev.to/skondho_kata</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3397604%2Ff0f06676-5edc-4436-8c2e-2ce1ed3fc71d.png</url>
      <title>DEV Community: Mushahid Intesum</title>
      <link>https://dev.to/skondho_kata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/skondho_kata"/>
    <language>en</language>
    <item>
      <title>Can you run a GNN without anyone seeing the data? Journal of our experiments on privacy-preserving GNN inference on microcontrollers</title>
      <dc:creator>Mushahid Intesum</dc:creator>
      <pubDate>Mon, 10 Aug 2026 02:56:24 +0000</pubDate>
      <link>https://dev.to/skondho_kata/can-you-run-a-gnn-without-anyone-seeing-the-data-journal-of-our-experiments-on-privacy-preserving-l14</link>
      <guid>https://dev.to/skondho_kata/can-you-run-a-gnn-without-anyone-seeing-the-data-journal-of-our-experiments-on-privacy-preserving-l14</guid>
      <description>&lt;p&gt;I have been keenly interested in how to make Graph Neural Networks (GNN) run securely on resource-constrained devices. The question driving this work is deceptively simple: can three microcontrollers jointly compute GNN inference on traffic data such that &lt;em&gt;no single device ever sees the plaintext&lt;/em&gt;, not the input features, not the model weights, not the intermediate activations? This post is about the findings I have found so far in this independent research endeavor.&lt;/p&gt;

&lt;h1&gt;
  
  
  Background on Secure GNN Inference
&lt;/h1&gt;

&lt;p&gt;A standard GCN layer [1] computes: &lt;code&gt;H' = σ(A · H · W + b)&lt;/code&gt;, where &lt;code&gt;A&lt;/code&gt; is the normalized adjacency matrix (graph topology), &lt;code&gt;H&lt;/code&gt; is the node feature matrix, &lt;code&gt;W&lt;/code&gt; is the learned weight matrix, and &lt;code&gt;σ&lt;/code&gt; is an activation function. In a traffic signal coordination setting, &lt;code&gt;A&lt;/code&gt; encodes which intersections connect to each other, &lt;code&gt;H&lt;/code&gt; holds the per-intersection sensor readings (queue lengths, phase states, flow rates), and the output dictates signal timing decisions.&lt;/p&gt;

&lt;p&gt;The privacy concern is real: traffic flow data reveals movement patterns, congestion bottlenecks, and potentially individual vehicle trajectories. If multiple jurisdictions or agencies need to collaboratively optimize signals at their shared borders, no party may want to expose their raw data to the others. Secure Multi-Party Computation (MPC) lets them jointly compute the model output without any single party seeing the full picture.&lt;/p&gt;

&lt;p&gt;We use &lt;strong&gt;Replicated Secret Sharing (RSS)&lt;/strong&gt; [2] in a 3-party semi-honest setting. Each value &lt;code&gt;x&lt;/code&gt; is split into three shares &lt;code&gt;(x₁, x₂, x₃)&lt;/code&gt; such that &lt;code&gt;x₁ + x₂ + x₃ = x mod 2⁶⁴&lt;/code&gt;. Party &lt;code&gt;i&lt;/code&gt; holds two of the three shares &lt;code&gt;(xᵢ, xᵢ₊₁)&lt;/code&gt;, so any single party sees only random-looking numbers. Reconstruction requires combining shares from at least two parties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────┐
│             REPLICATED SECRET SHARING               │
│                                                     │
│  Secret x split into (x₁, x₂, x₃)                 │
│  where x₁ + x₂ + x₃ = x  (mod 2⁶⁴)               │
│                                                     │
│  Party 0 holds: (x₁, x₂)                           │
│  Party 1 holds: (x₂, x₃)                           │
│  Party 2 holds: (x₃, x₁)                           │
│                                                     │
│  → No single party can recover x                    │
│  → Secure addition is FREE (no communication)       │
│  → Secure multiplication costs 1 round of comm      │
└─────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The arithmetic properties are what make this practical. Secure addition of two shared values requires zero communication: each party just locally adds their shares. Secure multiplication is more expensive. It requires one round of communication between parties using a PRF-based resharing protocol to maintain the share structure, but the cost is bounded and predictable.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Key Insight: Public Adjacency, Private Features
&lt;/h1&gt;

&lt;p&gt;Here's the critical observation that makes GNN inference on microcontrollers feasible. In a traffic network, the &lt;em&gt;graph topology&lt;/em&gt; is public knowledge. Everyone knows which intersections connect to which. The adjacency matrix &lt;code&gt;A&lt;/code&gt; is not secret. Only the node features &lt;code&gt;H&lt;/code&gt; (sensor readings) and the model weights &lt;code&gt;W&lt;/code&gt; (the learned policy) need protection.&lt;/p&gt;

&lt;p&gt;This means the message-passing step &lt;code&gt;A · H&lt;/code&gt; is a &lt;strong&gt;public-matrix × secret-matrix multiply&lt;/strong&gt;, which requires &lt;strong&gt;zero communication&lt;/strong&gt;. Each party can locally compute it from their shares alone. Only the feature transformation step &lt;code&gt;H · W&lt;/code&gt; (secret × secret) requires the full RSS multiplication protocol.&lt;/p&gt;

&lt;p&gt;Compared to CryptGNN [3] which treats everything as secret, this roughly halves the communication cost. In a 2-layer GCN, we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Layer 1: A·X (free) → (A·X)·W₁ (1 round) → activation (1 round)
Layer 2: A·H (free) → (A·H)·W₂ (1 round)
Total:   3 communication rounds (vs 5+ if A were secret)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Test Bed
&lt;/h1&gt;

&lt;p&gt;The target hardware is &lt;strong&gt;ESP32-S3&lt;/strong&gt; microcontrollers, 240MHz dual-core Xtensa processors with WiFi and ~320KB usable SRAM. Three boards form the 3-party RSS computation, communicating over TCP/WiFi. For the model, I use a 2-layer GCN trained on a 20-node synthetic traffic grid (4×5 intersection layout):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4×5 Grid Topology:        Model Architecture:

○─○─○─○─○                 GCN(16 → 16 → 4)
│ │ │ │ │                  • 20 nodes, 16 input features
○─○─○─○─○                 • 16 hidden features, 4 output classes
│ │ │ │ │                  • Polynomial activation: 0.1x² + 0.5x + 0.1
○─○─○─○─○                 • 340 total parameters
│ │ │ │ │                  • Q20 fixed-point arithmetic
○─○─○─○─○
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The input features per node are: one-hot phase encoding (4 dims), queue lengths per direction (4 dims), flow rates (4 dims), occupancy, and time-of-day (sin/cos encoding), 16 features total. The model predicts which direction has the highest traffic demand.&lt;/p&gt;

&lt;p&gt;An important design choice: we use a &lt;strong&gt;polynomial activation&lt;/strong&gt; &lt;code&gt;0.1x² + 0.5x + 0.1&lt;/code&gt; instead of ReLU. ReLU requires a comparison (&lt;code&gt;x &amp;gt; 0&lt;/code&gt;), which is expensive in MPC because comparisons need bit-decomposition. A degree-2 polynomial can be evaluated using only one secure multiplication (for the &lt;code&gt;x²&lt;/code&gt; term), keeping the activation cost to a single communication round. Training with the polynomial activation achieves 52.1% accuracy vs 54.0% with ReLU, a modest 1.9 percentage point drop that we consider acceptable for the massive reduction in protocol complexity.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Pipeline
&lt;/h1&gt;

&lt;p&gt;The full system goes from training through to secure inference verification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Train GCN → Export Q20 Fixed-Point → Generate RSS Shares → Secure Inference → Verify Against Plaintext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Python side handles training (&lt;code&gt;train_model.py&lt;/code&gt;), fixed-point export with RSS share generation (&lt;code&gt;export_model.py&lt;/code&gt;), and offline analysis (&lt;code&gt;analyze.py&lt;/code&gt; + &lt;code&gt;rss_emulator.py&lt;/code&gt;). The C side implements the actual protocol: RSS primitives, secure matrix operations, and the 2-layer GCN inference pipeline. Both sides are designed to produce bit-identical results for a given set of shares.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 1: Fixed-point quantization preserves inference fidelity
&lt;/h1&gt;

&lt;p&gt;Before worrying about secret sharing, the first question is whether the float-to-fixed-point conversion introduces unacceptable error. We use Q16 fixed-point (16 fractional bits) for the offline analysis with an 8-node ring graph as a controlled test bed.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;Float Output&lt;/th&gt;
&lt;th&gt;Q16 Output&lt;/th&gt;
&lt;th&gt;Absolute Error&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0.293579&lt;/td&gt;
&lt;td&gt;0.293488&lt;/td&gt;
&lt;td&gt;0.000091&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0.273324&lt;/td&gt;
&lt;td&gt;0.273224&lt;/td&gt;
&lt;td&gt;0.000100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0.276208&lt;/td&gt;
&lt;td&gt;0.276123&lt;/td&gt;
&lt;td&gt;0.000085&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0.302083&lt;/td&gt;
&lt;td&gt;0.302002&lt;/td&gt;
&lt;td&gt;0.000081&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;0.328208&lt;/td&gt;
&lt;td&gt;0.328125&lt;/td&gt;
&lt;td&gt;0.000083&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;0.354583&lt;/td&gt;
&lt;td&gt;0.354492&lt;/td&gt;
&lt;td&gt;0.000091&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0.357505&lt;/td&gt;
&lt;td&gt;0.357422&lt;/td&gt;
&lt;td&gt;0.000083&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;0.337120&lt;/td&gt;
&lt;td&gt;0.337036&lt;/td&gt;
&lt;td&gt;0.000084&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The mean quantization error is &lt;strong&gt;0.0000875&lt;/strong&gt; and the max is &lt;strong&gt;0.0001002&lt;/strong&gt;. Both output features show identical values per node (the test model uses uniform weights that produce symmetric outputs), confirming the fixed-point pipeline is numerically faithful. All errors are sub-0.01% relative to the output magnitudes, well within acceptable bounds for traffic signal decisions.&lt;/p&gt;

&lt;p&gt;Figure 1: Output comparison across nodes showing near-identical float and Q16 fixed-point values. The bars are visually indistinguishable, confirming minimal quantization degradation.&lt;/p&gt;

&lt;p&gt;The error is also spatially uniform across nodes. This matters: if quantization error concentrated at specific graph positions, it could systematically bias decisions at those intersections.&lt;/p&gt;

&lt;p&gt;Figure 2: Per-node quantization error heatmap. Error values are uniformly distributed across all nodes and output features, staying within the 0.00008 to 0.0001 range.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 2: RSS primitives are bit-exact
&lt;/h1&gt;

&lt;p&gt;The RSS protocol correctness was verified through four escalating tests in the Python emulator:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Share/Reconstruct&lt;/td&gt;
&lt;td&gt;Split 42, reconstruct from shares&lt;/td&gt;
&lt;td&gt;✅ PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secure Addition&lt;/td&gt;
&lt;td&gt;100 + 200 = 300, zero communication&lt;/td&gt;
&lt;td&gt;✅ PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secure Multiplication&lt;/td&gt;
&lt;td&gt;7 × 6 = 42, with PRF resharing&lt;/td&gt;
&lt;td&gt;✅ PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Random Multiplication&lt;/td&gt;
&lt;td&gt;100 random pairs, full ring arithmetic&lt;/td&gt;
&lt;td&gt;100/100 ✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last test is the important one. We generate 100 random integer pairs in &lt;code&gt;[0, 10000)&lt;/code&gt;, secret-share both operands, perform secure multiplication with the full PRF-based resharing protocol, reconstruct, and verify against the plaintext product modulo &lt;code&gt;2⁶⁴&lt;/code&gt;. All 100 pass, confirming that the resharing logic correctly maintains the share invariant &lt;code&gt;x₁ + x₂ + x₃ = x mod 2⁶⁴&lt;/code&gt; through multiplication.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 3: All three parties agree on the output
&lt;/h1&gt;

&lt;p&gt;The C desktop emulator spawns three processes (one per party) communicating over localhost TCP sockets. Each party holds its own shares of the features and weights, runs the full GCN inference protocol (5 steps: public matmul, secure matmul, polynomial activation, public matmul, secure matmul), and then opens the output shares to reconstruct the final result.&lt;/p&gt;

&lt;p&gt;All 3 parties produce &lt;strong&gt;identical reconstructed outputs&lt;/strong&gt;, confirming protocol correctness across the inter-process communication boundary. The desktop emulation completes in approximately &lt;strong&gt;0.39 ms average&lt;/strong&gt; across the three parties (Party 0: 0.43 ms, Party 1: 0.39 ms, Party 2: 0.35 ms).&lt;/p&gt;

&lt;p&gt;Figure 3: Inference time per party in the desktop emulator. The slight variation is expected from OS scheduling; the important thing is that all three parties complete within a tight band.&lt;/p&gt;

&lt;p&gt;The per-party timing spread (~0.08 ms) is purely from OS scheduling jitter on the desktop. On dedicated ESP32-S3 hardware without a preemptive OS, we expect tighter synchronization.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 4: The secure pipeline mirrors the C implementation
&lt;/h1&gt;

&lt;p&gt;The Python RSS emulator (&lt;code&gt;rss_emulator.py&lt;/code&gt;) replicates the exact same protocol as the C implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: A * X      ← public × shared, FREE
Step 2: (A*X) * W₁ ← shared × shared, 1 communication round
Step 3: Activation  ← polynomial, 1 communication round
Step 4: A * H₁     ← public × shared, FREE
Step 5: (A*H₁) * W₂ ← shared × shared, 1 communication round
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both implementations use identical truncation semantics (arithmetic right shift on signed 64-bit values), the same PRF-based resharing (splitmix64 hash for deterministic randomness), and the same polynomial activation coefficients (Q-format &lt;code&gt;0.1&lt;/code&gt;, &lt;code&gt;0.5&lt;/code&gt;, &lt;code&gt;0.1&lt;/code&gt;). This dual-stack approach, Python for rapid prototyping and verification, C for deployment, lets us catch protocol bugs early. If the Python emulator and the C binary produce different outputs for the same shares, something is wrong in the C implementation.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Firmware Side
&lt;/h1&gt;

&lt;p&gt;The ESP32-S3 firmware is written in C with ESP-IDF. Each board connects to the others over WiFi/TCP, loads its pre-generated share files (&lt;code&gt;model_shares_p{0,1,2}.bin&lt;/code&gt;), and runs the inference protocol. The PRF uses mbedtls hardware-accelerated AES on the ESP32-S3 (replacing the OpenSSL backend used on desktop). The transport layer abstracts over POSIX sockets (desktop) vs lwIP TCP (ESP32), so the core protocol code is identical on both platforms.&lt;/p&gt;

&lt;p&gt;This is fully built and compiles, but the actual on-device deployment and benchmarking is the next step. This will be the next part.&lt;/p&gt;

&lt;h1&gt;
  
  
  Future Directions
&lt;/h1&gt;

&lt;p&gt;This is an ongoing experiment. This blog serves as a journal of my progress so far and will continually be updated once new findings are found. A few concrete next steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hardware deployment and benchmarking&lt;/strong&gt;: flash the firmware to 3 ESP32-S3 boards, run the full protocol over WiFi, and measure end-to-end latency, per-step communication overhead, and memory usage. The key question: can the protocol complete within a traffic signal cycle (~1-5 seconds) to be practically useful? This will be the next part.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale to the full 20-node model&lt;/strong&gt;: the current desktop verification uses an 8-node ring graph with small weight matrices. The trained traffic model has 20 nodes with 16→16→4 dimensions, significantly larger matrices that will stress both computation and communication budgets on the ESP32.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real traffic data integration&lt;/strong&gt;: replace the synthetic training data with real-world traffic signal datasets to evaluate whether the fixed-point quantization error affects decision quality on non-synthetic distributions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comparison with CryptGNN&lt;/strong&gt;: quantitatively benchmark our "public adjacency" optimization against the fully-secret approach to measure the actual communication savings in practice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hopefully we'll be able to get a paper through this independent endeavor.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;[1] T. N. Kipf, M. Welling, "Semi-Supervised Classification with Graph Convolutional Networks," ICLR 2017.&lt;br&gt;
[2] T. Araki, J. Furukawa, Y. Lindell, A. Nof, K. Ohara, "High-Throughput Semi-Honest Secure Three-Party Computation with an Honest Majority," CCS 2016.&lt;br&gt;
[3] R. Ran, W. Wang, Q. Gang, J. Rao, "CryptGNN: Fast Privacy-Preserving Graph Neural Network Inference," 2022.&lt;br&gt;
[4] ESP-IDF Programming Guide, Espressif Systems, &lt;a href="https://docs.espressif.com/projects/esp-idf/" rel="noopener noreferrer"&gt;https://docs.espressif.com/projects/esp-idf/&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>gnn</category>
      <category>security</category>
      <category>iot</category>
    </item>
    <item>
      <title>Can you steal a robot's next move by watching its clock? Journal of our experiments on timing side channels in multi agent RL</title>
      <dc:creator>Mushahid Intesum</dc:creator>
      <pubDate>Mon, 10 Aug 2026 02:46:47 +0000</pubDate>
      <link>https://dev.to/skondho_kata/can-you-steal-a-robots-next-move-by-watching-its-clock-journal-of-our-experiments-on-timing-side-1k5f</link>
      <guid>https://dev.to/skondho_kata/can-you-steal-a-robots-next-move-by-watching-its-clock-journal-of-our-experiments-on-timing-side-1k5f</guid>
      <description>&lt;p&gt;I have been keenly interested in the intersection of multi-agent reinforcement learning (MARL) and hardware security. When you deploy a trained RL policy onto a microcontroller, the model runs inference to decide what action to take. But here's the thing: different actions can take different amounts of &lt;em&gt;time&lt;/em&gt; to compute. If an adversary can measure that timing, can they figure out what the agent is about to do without ever seeing the input? This post is about the findings I have found so far in this independent research endeavor.&lt;/p&gt;

&lt;h1&gt;
  
  
  Background on the Threat Model
&lt;/h1&gt;

&lt;p&gt;The core question is straightforward. A MARL policy, say two cooperative agents navigating a grid, runs on an ESP32-S3 microcontroller. The attacker sits on the outside. They can measure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Total inference duration (and per-operator breakdowns)&lt;/li&gt;
&lt;li&gt;Number of inferences per timestep&lt;/li&gt;
&lt;li&gt;Network packet timing if WiFi is involved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They &lt;strong&gt;cannot&lt;/strong&gt; see the raw observations fed to the policy, the internal activations, or the weights. Pure black-box timing. The goal: predict the agent's &lt;strong&gt;action&lt;/strong&gt; from timing alone, without ever seeing the observation input.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────┐
│                   ATTACKER                      │
│  Can observe:                                   │
│    • Inference duration (total + per-layer)      │
│    • Number of inferences per timestep           │
│    • Network packet timing (if WiFi used)        │
│  Cannot observe:                                │
│    • Raw observations fed to the policy          │
│    • Internal activations or weights             │
│    • Source code (black box timing only)           │
│                                                 │
│  Goal: Predict the agent's ACTION from timing   │
│        without seeing the observation input      │
└─────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This threat model matters because MARL is increasingly being deployed on edge devices like autonomous drones, warehouse robots, and cooperative IoT networks where an adversary with physical proximity could realistically tap into timing signals. If the leakage is real, it's a serious vulnerability: you can predict what an agent will do before it does it.&lt;/p&gt;

&lt;h1&gt;
  
  
  Test Bed
&lt;/h1&gt;

&lt;p&gt;For the environments, I set up three test beds with increasing complexity:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Cooperative Grid Navigation (Custom, Primary):&lt;/strong&gt; Two agents on a 5×5 grid with swapped goals. They communicate their position and intended direction. There's a wall with a single gap in the middle, so they need to coordinate to avoid collision. The policy is a small MLP: &lt;code&gt;MLP(9 → 32 → 32 → 5)&lt;/code&gt; with 5 discrete actions (stay, up, down, left, right).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A . . . .     2 agents, 5×5 grid, swapped goals
. . . . .     Comm: position + intended direction
# # . # #     Shared reward, collision penalty
. . . . .     
. . . . B     Policy: MLP(9 → 32 → 32 → 5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. CartPole (Gymnasium Baseline):&lt;/strong&gt; The classic single-agent balance task. This serves as a sanity check. It establishes whether timing leakage is a general phenomenon of NN inference on MCUs or specific to multi-agent setups. Policy: &lt;code&gt;MLP(4 → 32 → 32 → 2)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. MPE Simple Spread (PettingZoo):&lt;/strong&gt; 3 agents cooperatively covering 3 landmarks. A standard MARL benchmark with a larger policy: &lt;code&gt;MLP(18 → 64 → 64 → 5)&lt;/code&gt;. This one hasn't been fully analyzed yet.&lt;/p&gt;

&lt;p&gt;For both grid_nav and CartPole, the policies are trained using PPO (and IPPO for multi-agent), then exported to TFLite (both FP32 and INT8 quantized variants) for deployment. The export pipeline goes PyTorch → Keras → TFLite, and also generates a &lt;code&gt;.h&lt;/code&gt; C header for embedding directly into the ESP32 firmware.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Pipeline
&lt;/h1&gt;

&lt;p&gt;The full analysis pipeline I built goes from training all the way through to leakage quantification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Train Policy → Export TFLite → Flash ESP32-S3 → Collect Timing → Analyze Leakage → Generate Report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analysis module is the core of the project. For each model configuration, it computes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mutual Information&lt;/strong&gt; &lt;code&gt;MI(timing; action)&lt;/code&gt;: how many bits of action information leak through timing, with bootstrap confidence intervals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statistical Tests&lt;/strong&gt;: Kruskal-Wallis H test and one way ANOVA to determine if timing distributions across actions are statistically different&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Effect Sizes&lt;/strong&gt;: Cohen's d between all action pairs to quantify &lt;em&gt;how&lt;/em&gt; different the distributions are&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classifier Accuracy&lt;/strong&gt;: a Random Forest and an MLP trained to predict the action from timing features alone (total cycles + per op breakdown)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the classifiers beat random baseline by a significant margin, the system is operationally vulnerable: an attacker can build the same model.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 1: Simulated timing shows the pipeline detects leakage when present
&lt;/h1&gt;

&lt;p&gt;Before touching real hardware, I validated the pipeline with simulated timing. The &lt;code&gt;SimulatedCollector&lt;/code&gt; runs real TFLite inference on the laptop but generates synthetic cycle counts that are intentionally action dependent: &lt;code&gt;base_cycles + action × bias + noise&lt;/code&gt;. This confirms that when there &lt;em&gt;is&lt;/em&gt; leakage baked in, the analysis correctly detects it.&lt;/p&gt;

&lt;p&gt;The results across 2000 simulated traces per configuration:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Config&lt;/th&gt;
&lt;th&gt;MI (bits)&lt;/th&gt;
&lt;th&gt;RF Accuracy&lt;/th&gt;
&lt;th&gt;KW p-value&lt;/th&gt;
&lt;th&gt;Max Cohen's d&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cartpole_fp32&lt;/td&gt;
&lt;td&gt;0.011&lt;/td&gt;
&lt;td&gt;99.5%&lt;/td&gt;
&lt;td&gt;1.98e-9&lt;/td&gt;
&lt;td&gt;0.274&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cartpole_int8&lt;/td&gt;
&lt;td&gt;0.022&lt;/td&gt;
&lt;td&gt;99.8%&lt;/td&gt;
&lt;td&gt;1.71e-9&lt;/td&gt;
&lt;td&gt;0.276&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;grid_nav_fp32&lt;/td&gt;
&lt;td&gt;0.976&lt;/td&gt;
&lt;td&gt;99.8%&lt;/td&gt;
&lt;td&gt;1.46e-281&lt;/td&gt;
&lt;td&gt;8.879&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;grid_nav_int8&lt;/td&gt;
&lt;td&gt;1.005&lt;/td&gt;
&lt;td&gt;100.0%&lt;/td&gt;
&lt;td&gt;1.15e-286&lt;/td&gt;
&lt;td&gt;8.838&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A few observations jump out immediately:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The grid_nav environment leaks significantly more than CartPole.&lt;/strong&gt; Grid navigation has 5 actions with MI near 1 bit (out of a max of ~2.32 bits for 5 actions), while CartPole's MI hovers near 0. This makes sense: the simulated timing injects &lt;code&gt;action × 200&lt;/code&gt; cycles of bias, and with 5 spread out actions, there's more room for distinct timing signatures than CartPole's 2 actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classifiers hit near perfect accuracy.&lt;/strong&gt; Both RF and MLP classifiers achieve 99.5%+ accuracy on the simulated data, far exceeding the 20% random baseline for 5 actions and 50% for 2 actions. This demonstrates that even simple models can operationally exploit timing leakage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Kruskal-Wallis p values are absurdly small.&lt;/strong&gt; Values like 1.46e-281 are effectively zero. The null hypothesis (timing distributions are the same across actions) is annihilated. Combined with Cohen's d values above 8 for grid_nav (anything above 0.8 is conventionally "large"), this signals massive, unmistakable effect sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;INT8 quantization doesn't suppress leakage.&lt;/strong&gt; In fact, the INT8 variants show slightly &lt;em&gt;higher&lt;/em&gt; MI and comparable classifier accuracy. This is notable because quantization changes the computational profile of each operator, and we had hypothesized it might reduce timing variance by simplifying the computation paths. At least in simulation, it doesn't.&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 2: Per operator timing is where the signal lives
&lt;/h1&gt;

&lt;p&gt;Beyond total inference time, I also measured per operator cycle counts (5 simulated operators: two FullyConnected, two activation, one Softmax). The per operator MI analysis revealed that the leakage isn't uniform. Specific operators (the FullyConnected layers and the final Softmax) carry most of the timing signal, while activation functions contribute very little.&lt;/p&gt;

&lt;p&gt;This has practical implications: if you wanted to &lt;em&gt;defend&lt;/em&gt; against timing side channels, you'd focus your constant time countermeasures on the matmul and softmax operators specifically, rather than trying to make the entire inference pipeline constant time (which is much harder).&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding 3: Observation timing correlation exists
&lt;/h1&gt;

&lt;p&gt;Using Spearman correlation between individual observation dimensions and total timing, I found statistically significant correlations in multiple dimensions. This means timing doesn't &lt;em&gt;only&lt;/em&gt; leak the output action, it also leaks information about the &lt;em&gt;input&lt;/em&gt; observations. In a MARL context, this is arguably worse: an adversary could potentially reconstruct features of the agent's perceived state, not just its decision.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Firmware Side
&lt;/h1&gt;

&lt;p&gt;The ESP32-S3 firmware is written in C/C++ with ESP-IDF and TFLite Micro. The key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cycle accurate timing&lt;/strong&gt; via &lt;code&gt;esp_cpu_get_cycle_count()&lt;/code&gt; at 240MHz (4.17ns resolution)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per operator profiling&lt;/strong&gt; using TFLite's &lt;code&gt;MicroProfiler&lt;/code&gt; to attribute timing to individual operators (FullyConnected, ReLU, Softmax)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary UART protocol&lt;/strong&gt; at 921600 baud for high throughput data collection: the laptop sends observation vectors and the ESP32 sends back &lt;code&gt;(action, total_cycles, per_op_cycles[])&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is fully built and compiles, but the actual on device data collection is the next step. This will be covered in the next part.&lt;/p&gt;

&lt;h1&gt;
  
  
  Future Directions
&lt;/h1&gt;

&lt;p&gt;This is an ongoing experiment. This blog serves as a journal of my progress so far and will continually be updated once new findings are found. A few concrete next steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Real hardware timing collection&lt;/strong&gt;: flash the firmware to the ESP32-S3, collect 10K+ traces per environment, and compare against the simulated results. The key question: does &lt;em&gt;actual&lt;/em&gt; hardware exhibit exploitable timing variance, or does the ESP32-S3's SIMD/vector acceleration (ESP-NN) make inference sufficiently constant time? This will be the next part.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constant time countermeasures&lt;/strong&gt;: if leakage is confirmed on hardware, experiment with software mitigations: padding inference to a fixed duration, adding random delays, or using constant time matmul implementations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross environment comparison&lt;/strong&gt;: run the full analysis on Simple Spread (3 agents, larger policy) to see if leakage scales with model size or action space complexity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adversarial observation sampling&lt;/strong&gt;: instead of uniform random observations, use adversarially chosen inputs that maximize timing variance to establish worst case leakage bounds.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hopefully we'll be able to get a paper through this independent endeavor.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>security</category>
      <category>iot</category>
      <category>reinforcementlearning</category>
    </item>
    <item>
      <title>Experiments on Token Transformation of Vision Mamba</title>
      <dc:creator>Mushahid Intesum</dc:creator>
      <pubDate>Wed, 06 Aug 2025 17:55:14 +0000</pubDate>
      <link>https://dev.to/skondho_kata/experiments-on-token-transformation-of-vision-mamba-221d</link>
      <guid>https://dev.to/skondho_kata/experiments-on-token-transformation-of-vision-mamba-221d</guid>
      <description>&lt;p&gt;State Space Models such as &lt;a href="https://arxiv.org/pdf/2312.00752" rel="noopener noreferrer"&gt;Mamba&lt;/a&gt; have become a promising alternative to &lt;a href="https://arxiv.org/pdf/1706.03762" rel="noopener noreferrer"&gt;attention mechanism&lt;/a&gt;, which is difficult to compress due to the quadratic complexity of the attention mechanism. For handling image data, models such as &lt;a href="https://arxiv.org/pdf/2401.09417" rel="noopener noreferrer"&gt;ViM&lt;/a&gt; and &lt;a href="https://arxiv.org/pdf/2401.10166" rel="noopener noreferrer"&gt;VMamba&lt;/a&gt; have been proposed. Though Mamba has been shown to perform well for long contexts, there is still a lot of understanding to be had on the mechanisms of this model. In this study, I attempt to run some experiments on vision token transformation for the ViM model to see how it performs and try find any possible improvements. This post will serve as a journal of the progress of this independent study.&lt;/p&gt;

&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Attention Mechanism of Transformer
&lt;/h2&gt;

&lt;p&gt;Transformers took the world by storm for its unmatched ability in handling long contexts and scalability. Modern Large Language Models such as ChatGPT, Claude, Gemini, DeepSeek have been built using transformers. These models have billions of parameters, and this can be done because transformers can be very easily parallelized as text is not parsed sequentially, unlike previous seq2seq models. At its core is the self-attention mechanism presented in the following equation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7mbbv1lywbit0gx0g7h0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7mbbv1lywbit0gx0g7h0.png" alt=" " width="335" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the input is split into Q, K, V matrices and passed through the above formula to get the attention score for the input. Multiple such attention scores are calculated for each input sequence in a process called multi-headed attention. This provides robust outputs and responses.&lt;/p&gt;

&lt;p&gt;Transformers have been adapted to vision tasks by dividing the images into a set number of tokens or patches, inserting positional information and then passing them to the transformer layers. A CLS token is added for identifying which class the image belongs too when needed.&lt;/p&gt;

&lt;p&gt;For all its ability of scalability, transformers are notoriously difficult to compress because of the same self-attention mechanism. The quadratic complexity makes it hard for parsing long input sequences under resource constraints. Many optimizations have been proposed to address this.&lt;/p&gt;

&lt;h2&gt;
  
  
  State Space Models &amp;amp; Mamba
&lt;/h2&gt;

&lt;p&gt;State Space Models (SSM) are a type of mathematical formulation which describes the state of an object in a continuous space with the least number of parameters. It is described using the following equation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cvtdn0iybuhv4cx105d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cvtdn0iybuhv4cx105d.png" alt=" " width="283" height="123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first equation describes how the system's internal state evolves over time, while the second equation relates the system's internal state to its observable outputs. Neural networks using SSM make matrices &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; shared across the network. Matrix &lt;code&gt;D&lt;/code&gt; can be thought of as a skip connection and is usually ignored. To make this equation usable for a neural network, the matrices are discretized by introducing another variable &lt;code&gt;delta&lt;/code&gt; and transforming the matrices in the following way:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7lvy93zw6tzw7ukdw00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7lvy93zw6tzw7ukdw00.png" alt=" " width="493" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These shared weights allows us to pre-calculate a portion of the equation and then reuse over and over again. Similar to convolutions, the pre-calculated value can be used to calculate proceding representations efficiently. This allows us to save computation costs. This can be visualized using the following figure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffs40wrmmoiz0vvcwbhra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffs40wrmmoiz0vvcwbhra.png" alt=" " width="695" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Neural networks using SSMs have been proposed and were shown to be more efficient than transformers, but their performance was not good enough to be considered as a replacement for it. This is because of the static nature of the &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; matrices. The model cannot focus on relevant parts of the input like transformers and thus struggles when sequences are longer. The introduction of Mamba changed that notion by addressing the performance issue by making SSMs selective. This notion of selectivity is introduced by making matrices &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; input dependent. That is, each token will have its own &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; matrices instead of having a shared one. This would allow the model to focus on specific input tokens, just like transformers. Though this would not allow us to use the kernel trick, this was addressed by designing a hardware aware algorithm. Mathematical calculations are less time-consuming than memory movement. That is, it takes more time to more data from high-bandwidth SRAM to low bandwidth DRAM and vise versa. In order to make &lt;/p&gt;

&lt;h2&gt;
  
  
  Mamba for Vision
&lt;/h2&gt;

&lt;p&gt;Different models have been proposed for handling image data using Mamba such as VMamba and ViM. For my experiments, I will be utilizing VMamba. Similar to vision transformers, VMamba divides the image into patches and then the patches are fed through a linear block to get intermediate representations. To properly get positional information, 4-directional SSM is done so that model can get positional information of all the patches properly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2l6rpy0l8usv1yx0is2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2l6rpy0l8usv1yx0is2.png" alt=" " width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Methodology
&lt;/h1&gt;

&lt;p&gt;This experiment is inspired by &lt;a href="https://arxiv.org/pdf/2409.09808" rel="noopener noreferrer"&gt;Famba-V&lt;/a&gt;, which merges tokens after passing through the forward and backward SSM blocks, as can be seen in the following image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdp2wiigpzdzkqgeswgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdp2wiigpzdzkqgeswgk.png" alt=" " width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the tokens pass through the SSM blocks, similar tokens are merged using cosine similarity and a new representation matrix is formed. This allowed for lower training time and memory usage. &lt;/p&gt;

&lt;p&gt;Instead of merging, we aim to transform the tokens. As proposed in &lt;a href="https://arxiv.org/pdf/2506.05709" rel="noopener noreferrer"&gt;this paper&lt;/a&gt;, just simply pruning or merging vision tokens can lead to relevant information loss. Instead of doing either one, the vision tokens would be transformed using a transformation matrix.&lt;/p&gt;

&lt;p&gt;The construction of this transformation matrix first involves calculating attention scores using the attention equivalence scores for mamba models as formulated in &lt;a href="https://arxiv.org/pdf/2403.01590" rel="noopener noreferrer"&gt;this paper&lt;/a&gt;, which is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falcefdotnz3razt0p5xa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falcefdotnz3razt0p5xa.png" alt=" " width="200" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Afterwards, the transformation matrix is created in the following order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The attention score of each token with respect to others is summed to create a vector of aggregated attention scores.&lt;/li&gt;
&lt;li&gt;Another matrix of size (patch length * patch length) is created by taking the cosine similarity of each token&lt;/li&gt;
&lt;li&gt;This new matrix is then softmaxed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After this, the outputs from the selective scan operation is multiplied with this matrix to get the new latent representations.&lt;/p&gt;

&lt;p&gt;This token transformation can be visualized from the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq394fqypxqe5ycknjkop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq394fqypxqe5ycknjkop.png" alt=" " width="800" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The inner workings of the token transformation can be visualized in the following way:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjr8a61uqlpldjd1qiwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjr8a61uqlpldjd1qiwt.png" alt=" " width="640" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Potential Pitfalls:
&lt;/h1&gt;

&lt;p&gt;Calculation of this attention matrix involves a quadratic calculation. This might become a bottleneck. In order to alleviate this, we could utilize the linear attention equivalence proposed in &lt;a href="https://arxiv.org/pdf/2305.07027" rel="noopener noreferrer"&gt;EfficientViT&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion:
&lt;/h1&gt;

&lt;p&gt;This is an ongoing blog and, as I mentioned earlier, is going to act as a journal of whatever updates I have on this project. &lt;/p&gt;

</description>
      <category>tinyml</category>
      <category>efficientai</category>
      <category>mamba</category>
      <category>vim</category>
    </item>
    <item>
      <title>Journal of our experiments on VLM token pruning</title>
      <dc:creator>Mushahid Intesum</dc:creator>
      <pubDate>Sat, 02 Aug 2025 04:14:39 +0000</pubDate>
      <link>https://dev.to/skondho_kata/vlms-have-an-excess-tokens-2ho5</link>
      <guid>https://dev.to/skondho_kata/vlms-have-an-excess-tokens-2ho5</guid>
      <description>&lt;p&gt;I and &lt;a class="mentioned-user" href="https://dev.to/oldpilluwu"&gt;@oldpilluwu&lt;/a&gt;  have been keenly interested in how to make Large Vision Models (VLM) work and wanted to know if these really large models can be made more efficient. Because, let's face it, the current AI landscape is dominated by these massive models which can be properly utilized through API calls and using these API can get really expensive really quickly. For that, we started poking into Llava-7B [1] to observe it's characteristics and try to find any possible avenues for efficiency and redundancy removal. This post is about the findings we have found so far in this independent research endeavor.&lt;/p&gt;

&lt;h1&gt;
  
  
  Background on Llava Model:
&lt;/h1&gt;

&lt;p&gt;Llava[1] is a family of vision language models introduced in 2023 with many size variants. For our experiments, we use the Llava-7B variant. Llava has 2 parts: a vision tower and an LLM. The vision tower processes the image tokens. It does so by breaking the input image into multiple tokens (577 including CLS token), encoding positional information and then passing them through the attention heads in the vision tower. CLIP[3] is used as the vision tower for Llava which has 24 attention heads. &lt;/p&gt;

&lt;p&gt;The text is tokenized separately and the both the image and text tokens are passed to the LLM for cross-modal fusion which produces the final output. Llama-7B is used as the LLM for Llava-7B.&lt;/p&gt;

&lt;h1&gt;
  
  
  Test Bed
&lt;/h1&gt;

&lt;p&gt;For experimentation, we utilized the Llava-7B implementation from transformers[2]. Since LLava 7B requires atleast 24GB VRAM to run, I utilized the GPU resources available at Kaggle. This was a bottleneck because of limited availability. We experimented on different images with various prompts to see the characteristics. We selected 4 random images from the Coco validation and test sets and tried 4 different prompts for our experiments. These are the images being used for testing:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqauvcqvhezp0xd52jruo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqauvcqvhezp0xd52jruo.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt;: Images used for testing. Image ordering goes from left to right and top to bottom&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 1: Significant drop-off in attention entropy in Vision Tower
&lt;/h2&gt;

&lt;p&gt;First, we analyzed the per‐head entropy within the vision tower to quantify each head’s dispersion of focus across image tokens. Entropy, defined as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnil0svq8yqyquzlmqrqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnil0svq8yqyquzlmqrqp.png" alt=" " width="196" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;represents the normalized attention weight to token (i), serves as a proxy for the breadth of a head’s receptive field: high entropy implies a diffuse attention spread over many tokens, whereas low entropy indicates concentrated focus on a few salient regions. Across a diverse set of natural and synthetic images, we observed a pronounced and reproducible drop in entropy values between attention heads 10 and 11, and head 12, as illustrated in Figure 1. This inflection point suggests that heads 1–11 progressively refine their contextual aggregation, but head 12—and those beyond—begin to collapse onto a narrower subset of tokens. Notably, this pattern held regardless of image content or complexity, implying an architectural or learned bias in the middle‐to‐late vision layers. We hypothesize that low‐entropy heads may prematurely discard secondary but potentially relevant features, thereby propagating suboptimal token representations into deeper layers. In the next section, we systematically probe individual token attention scores to determine whether these low‐entropy dynamics indeed lead to persistent information loss during forward propagation.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ra5vuizihoh5ag02qct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ra5vuizihoh5ag02qct.png" alt="Entropy graph of vision tower attention heads" width="543" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt;: Entropy graph of vision tower attention heads. The trend shows a drop in attention scores from the halfway mark.&lt;/p&gt;

&lt;p&gt;This was reflected in the CLS-token attention map of each layer. The first half of the layers show a wide distribution of attention whereas the latter ones have sparse distribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gey5f663dp3mcduegx8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gey5f663dp3mcduegx8.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Figure 2&lt;/strong&gt;: CLS-token attention maps of vision tower layer. Attention distribution clearly shows that sparse distribution of tokens in latter half of layers across different images&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 2: Llava can tolerate visual token pruning pre cross-modal fusion, especially in the latter attention heads of vision tower
&lt;/h2&gt;

&lt;p&gt;Based on the previous findings, we conducted experiments to see how many tokens are below a certain threshold in the vision tower attention heads and if pruning image tokens based on those low scores affect inference performance of the model. &lt;/p&gt;

&lt;p&gt;Let &lt;code&gt;n&lt;/code&gt; be the number of attention heads we wish to scan and &lt;code&gt;t&lt;/code&gt; be the maximum attention score threshold. We want to find what percentage of attention scores in the last &lt;code&gt;n&lt;/code&gt; heads are below threshold &lt;code&gt;t&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;We tested the percentage of attention scores below certain thresholds and present the results in the table below:&lt;/p&gt;

&lt;h2&gt;
  
  
  Percentage of Attention Scores Below Various Thresholds
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.00005&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.0003&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.0004&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.0005&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.005&lt;/th&gt;
&lt;th&gt;&amp;lt; 0.05&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0.82%&lt;/td&gt;
&lt;td&gt;13.96%&lt;/td&gt;
&lt;td&gt;19.76%&lt;/td&gt;
&lt;td&gt;25.38%&lt;/td&gt;
&lt;td&gt;99.65%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;8.08%&lt;/td&gt;
&lt;td&gt;30.77%&lt;/td&gt;
&lt;td&gt;35.95%&lt;/td&gt;
&lt;td&gt;40.95%&lt;/td&gt;
&lt;td&gt;97.32%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;6.46%&lt;/td&gt;
&lt;td&gt;32.52%&lt;/td&gt;
&lt;td&gt;40.81%&lt;/td&gt;
&lt;td&gt;48.30%&lt;/td&gt;
&lt;td&gt;98.82%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;5.84%&lt;/td&gt;
&lt;td&gt;28.39%&lt;/td&gt;
&lt;td&gt;37.76%&lt;/td&gt;
&lt;td&gt;47.07%&lt;/td&gt;
&lt;td&gt;99.31%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;4.76%&lt;/td&gt;
&lt;td&gt;30.78%&lt;/td&gt;
&lt;td&gt;38.34%&lt;/td&gt;
&lt;td&gt;45.55%&lt;/td&gt;
&lt;td&gt;97.53%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;2.20%&lt;/td&gt;
&lt;td&gt;27.84%&lt;/td&gt;
&lt;td&gt;36.09%&lt;/td&gt;
&lt;td&gt;43.13%&lt;/td&gt;
&lt;td&gt;97.56%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;0.00%&lt;/td&gt;
&lt;td&gt;9.57%&lt;/td&gt;
&lt;td&gt;17.20%&lt;/td&gt;
&lt;td&gt;25.62%&lt;/td&gt;
&lt;td&gt;98.51%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;0.03%&lt;/td&gt;
&lt;td&gt;6.16%&lt;/td&gt;
&lt;td&gt;10.36%&lt;/td&gt;
&lt;td&gt;15.82%&lt;/td&gt;
&lt;td&gt;98.62%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;0.04%&lt;/td&gt;
&lt;td&gt;7.73%&lt;/td&gt;
&lt;td&gt;12.86%&lt;/td&gt;
&lt;td&gt;18.47%&lt;/td&gt;
&lt;td&gt;97.81%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;2.08%&lt;/td&gt;
&lt;td&gt;15.49%&lt;/td&gt;
&lt;td&gt;21.95%&lt;/td&gt;
&lt;td&gt;28.01%&lt;/td&gt;
&lt;td&gt;95.00%&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;0.04%&lt;/td&gt;
&lt;td&gt;10.74%&lt;/td&gt;
&lt;td&gt;16.95%&lt;/td&gt;
&lt;td&gt;23.33%&lt;/td&gt;
&lt;td&gt;95.74%&lt;/td&gt;
&lt;td&gt;99.98%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;0.17%&lt;/td&gt;
&lt;td&gt;14.88%&lt;/td&gt;
&lt;td&gt;22.18%&lt;/td&gt;
&lt;td&gt;28.58%&lt;/td&gt;
&lt;td&gt;94.89%&lt;/td&gt;
&lt;td&gt;99.98%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;0.66%&lt;/td&gt;
&lt;td&gt;21.53%&lt;/td&gt;
&lt;td&gt;31.55%&lt;/td&gt;
&lt;td&gt;40.64%&lt;/td&gt;
&lt;td&gt;96.86%&lt;/td&gt;
&lt;td&gt;99.72%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;5.89%&lt;/td&gt;
&lt;td&gt;47.40%&lt;/td&gt;
&lt;td&gt;57.06%&lt;/td&gt;
&lt;td&gt;63.80%&lt;/td&gt;
&lt;td&gt;97.89%&lt;/td&gt;
&lt;td&gt;99.36%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;3.75%&lt;/td&gt;
&lt;td&gt;40.18%&lt;/td&gt;
&lt;td&gt;51.04%&lt;/td&gt;
&lt;td&gt;60.34%&lt;/td&gt;
&lt;td&gt;98.30%&lt;/td&gt;
&lt;td&gt;99.35%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;11.05%&lt;/td&gt;
&lt;td&gt;44.39%&lt;/td&gt;
&lt;td&gt;53.24%&lt;/td&gt;
&lt;td&gt;61.02%&lt;/td&gt;
&lt;td&gt;98.13%&lt;/td&gt;
&lt;td&gt;99.35%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;9.72%&lt;/td&gt;
&lt;td&gt;46.95%&lt;/td&gt;
&lt;td&gt;56.74%&lt;/td&gt;
&lt;td&gt;64.59%&lt;/td&gt;
&lt;td&gt;97.84%&lt;/td&gt;
&lt;td&gt;99.31%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;td&gt;15.25%&lt;/td&gt;
&lt;td&gt;40.60%&lt;/td&gt;
&lt;td&gt;48.07%&lt;/td&gt;
&lt;td&gt;54.99%&lt;/td&gt;
&lt;td&gt;97.60%&lt;/td&gt;
&lt;td&gt;99.36%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;td&gt;20.20%&lt;/td&gt;
&lt;td&gt;46.34%&lt;/td&gt;
&lt;td&gt;53.83%&lt;/td&gt;
&lt;td&gt;59.77%&lt;/td&gt;
&lt;td&gt;97.49%&lt;/td&gt;
&lt;td&gt;99.38%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;18.83%&lt;/td&gt;
&lt;td&gt;43.90%&lt;/td&gt;
&lt;td&gt;51.63%&lt;/td&gt;
&lt;td&gt;58.17%&lt;/td&gt;
&lt;td&gt;97.02%&lt;/td&gt;
&lt;td&gt;99.41%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;21&lt;/td&gt;
&lt;td&gt;23.20%&lt;/td&gt;
&lt;td&gt;47.12%&lt;/td&gt;
&lt;td&gt;54.46%&lt;/td&gt;
&lt;td&gt;60.34%&lt;/td&gt;
&lt;td&gt;97.01%&lt;/td&gt;
&lt;td&gt;99.45%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;4.73%&lt;/td&gt;
&lt;td&gt;45.62%&lt;/td&gt;
&lt;td&gt;52.39%&lt;/td&gt;
&lt;td&gt;57.87%&lt;/td&gt;
&lt;td&gt;96.78%&lt;/td&gt;
&lt;td&gt;99.50%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;23&lt;/td&gt;
&lt;td&gt;24.97%&lt;/td&gt;
&lt;td&gt;51.91%&lt;/td&gt;
&lt;td&gt;57.64%&lt;/td&gt;
&lt;td&gt;62.88%&lt;/td&gt;
&lt;td&gt;95.82%&lt;/td&gt;
&lt;td&gt;99.67%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;24&lt;/td&gt;
&lt;td&gt;19.57%&lt;/td&gt;
&lt;td&gt;52.44%&lt;/td&gt;
&lt;td&gt;58.51%&lt;/td&gt;
&lt;td&gt;63.48%&lt;/td&gt;
&lt;td&gt;95.58%&lt;/td&gt;
&lt;td&gt;99.53%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Table 1: Attention score percentage under different threshold for all layers in vision tower. All the values are in the range of (0.00005, 0.005)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As the preceding table shows, most of the attention scores are between 0.00005 and 0.005, excluding. Based on this finding, we experiment using 0.0003, 0.0004 and 0.0005 as pruning thresholds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Patch-wise Pruning:
&lt;/h3&gt;

&lt;p&gt;In this technique, we compute each patch’s importance by averaging its attention to the CLS token over all layers and a selected subset of the final N heads. From the full attention tensor of shape [L, B, H, T, T], we extract CLS-to-patch scores (yielding [L, B, H, P]), retain only the last N heads ([L, B, H′, P]), and collapse layers and heads to produce a [B, P] matrix of mean attention values. Patches whose scores fall below a fixed threshold t are deemed uninformative; their corresponding feature vectors in the [B, P, hidden_dim] image tensor are zeroed out, while all others remain intact. &lt;/p&gt;

&lt;p&gt;The results of pruning out tokens using the previously mentioned thresholds are given in the following table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Image&lt;/th&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0003&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0004&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0005&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items like forks or knives in the image. The woman is holding two donuts on a paper plate&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items like forks or knives in the image. The woman is holding two donuts on a paper plate&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features a woman wearing a hat and glasses, standing in front of a doughnut shop. She is holding two plates,&lt;/td&gt;
&lt;td&gt;The image features a woman standing in front of a doughnut shop, holding two plates with doughnuts on them. She is sm&lt;/td&gt;
&lt;td&gt;The image features a woman wearing a hat and glasses, standing in front of a doughnut shop. She is holding two plates,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is night in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Donuts 2. Ice cream cones 3. A woman 4. A doughnut 5. A&lt;/td&gt;
&lt;td&gt;The objects in the image include a woman holding two donuts, a doughnut on a plate, a doughnut on a napkin,&lt;/td&gt;
&lt;td&gt;1. Donuts 2. Ice cream 3. Woman 4. Donuts 5. Ice cream 6. Woman&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there is a pair of scissors in the image.&lt;/td&gt;
&lt;td&gt;No, there are no knives or any other sort of cutlery visible in the image. The focus is on the woman holding a kite&lt;/td&gt;
&lt;td&gt;Yes, there is a woman in the image who is holding a pair of scissors.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features a woman standing in a grassy field, holding a kite in her hand. She is wearing a red shirt and blue&lt;/td&gt;
&lt;td&gt;The image features a woman standing in a grassy field, holding a kite in her hand. She is wearing a red shirt and appears&lt;/td&gt;
&lt;td&gt;The image features a woman standing in a grassy field, holding a kite in her hand. She is wearing a red shirt and blue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;Day&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;[Empty response with newlines]&lt;/td&gt;
&lt;td&gt;In the image, there are several objects, including a woman holding a kite, a car, a truck, a bus, a boat,&lt;/td&gt;
&lt;td&gt;[Empty response with newlines]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image.&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items in this image. The image features a red and white ambulance and a red bus parked next&lt;/td&gt;
&lt;td&gt;Yes, there is a cutlery in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image depicts a city street at night, with a red and white ambulance parked next to a red and black bus. The&lt;/td&gt;
&lt;td&gt;The image depicts a city street at night, with a red and white bus driving down the road. A white ambulance is parked&lt;/td&gt;
&lt;td&gt;The image shows a city street at night, with a red and white ambulance parked next to a red and black bus. The bus is&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Ambulance 2. Bus 3. Tree 4. Firemen 5. Fire truck 6. Bus&lt;/td&gt;
&lt;td&gt;In the image, there are two buses, a truck, and a fire hydrant. The buses are parked next to each other&lt;/td&gt;
&lt;td&gt;1. Ambulance 2. Bus 3. tree 4. firemen 5. fire truck 6.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there are two cats in the image.&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image.&lt;/td&gt;
&lt;td&gt;Yes, there are two cats in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features two cats lying on a pink couch. One cat is located on the left side of the couch, while the other&lt;/td&gt;
&lt;td&gt;The image features two cats lying on a pink couch. One cat is positioned on the left side of the couch, while the&lt;/td&gt;
&lt;td&gt;The image features two cats lying on a pink couch. One cat is on the left side of the couch, while the other cat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is night in this image, as the two cats are sleeping on the couch.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Cat 2. Remote 3. Couch&lt;/td&gt;
&lt;td&gt;The objects in the image include a cat, a remote control, and a couch.&lt;/td&gt;
&lt;td&gt;The objects in the image include a cat, a remote control, a couch, and a blanket.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Table 2: Patch-wise pruning on different thresholds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Experimentally, we found that pruning the last 8 heads yielded the best results. Pruning more than 8 caused significant performance degradation and pruning any less did not give any performance enhancements. Experiments showed that different pruning thresholds gave good or bad results based on prompts. For example, for the prompt "Are there any cutlery in the image?" for Image 2, only pruning threshold 0.0004 was able to answer properly, whereas the others failed. For the same prompt, all pruning thresholds caused the model to hallucinate in some cases. There were also some instances where only threshold of 0.0004 was able to generate a response and the others were not able to. &lt;/p&gt;

&lt;h3&gt;
  
  
  Layer-wise Pruning:
&lt;/h3&gt;

&lt;p&gt;In this layer‐wise pruning scheme, for each layer l we extract the CLS‐to‐patch attention scores from the full tensor of shape [L, B, H, T, T], yielding [L, B, H, P], and retain only the final N heads to form [L, B, H′, P]. We then average over those N heads within each layer to produce a [B, P] matrix of mean attention values per layer, apply a fixed threshold to identify uninformative patch–head pairs, and expand the resulting binary mask into a full [B, P, hidden_dim] feature mask by assigning each head to its contiguous hidden‐dimension segment. Finally, this mask is applied element‐wise to the image features [B, P, hidden_dim], zeroing out only those head‐specific features that fall below the threshold while preserving all others.&lt;/p&gt;

&lt;p&gt;The table below shows the generation results for different threshold values:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Image&lt;/th&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0003&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0004&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;t&lt;/code&gt; = 0005&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items in the image. The focus is on the two donuts being held by the person.&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items in the image. The focus is on the two donuts being held by the person.&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items in the image. The focus is on the two donuts being held by the person.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features a woman standing in front of a doughnut stand, holding up two doughnuts for display. One doughnut is&lt;/td&gt;
&lt;td&gt;The image features a woman standing in front of a doughnut stand, holding up two doughnuts for display. One doughnut is&lt;/td&gt;
&lt;td&gt;The image features a woman standing in front of a doughnut stand, holding up two doughnuts for display. One doughnut is&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 1&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Donuts 2. Doughnuts 3. Doughnuts 4. Doughnuts 5.&lt;/td&gt;
&lt;td&gt;1. Donuts 2. Doughnuts 3. Doughnuts 4. Doughnuts 5.&lt;/td&gt;
&lt;td&gt;1. Donuts 2. Doughnuts 3. Doughnuts 4. Doughnuts 5.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image.&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image.&lt;/td&gt;
&lt;td&gt;Yes, there is a pair of scissors in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features a woman standing in a grassy field, holding a kite that is flying high in the sky. She is wearing a red&lt;/td&gt;
&lt;td&gt;The image features a woman standing in a grassy field, holding a kite that is flying high in the sky. She is wearing a red&lt;/td&gt;
&lt;td&gt;The image features a woman wearing a red and blue dress, standing on a grassy field. She is holding a kite, which is flying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 2&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Kite 2. Woman 3. Pants 4. Shirt 5. Sunglasses 6.&lt;/td&gt;
&lt;td&gt;1. Kite 2. Woman 3. Pants 4. Shirt 5. Sunglasses 6.&lt;/td&gt;
&lt;td&gt;The objects present in the image include a woman wearing a red shirt and holding a kite, a kite, a field, a par&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image, which is located near the bus.&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image, which is located near the bus.&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image, which is located on the side of the road.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image depicts a city street at night, with a large red bus parked on the side of the road. The bus is positioned&lt;/td&gt;
&lt;td&gt;The image depicts a city street at night, with a large red bus parked on the side of the road. The bus is positioned&lt;/td&gt;
&lt;td&gt;The image depicts a city street at night, with a large red bus parked on the side of the road. The bus is positioned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;td&gt;It is night in this image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 3&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Bus 2. Tree 3. Fire hydrant 4. Person 5. Bus stop 6. Fire truck&lt;/td&gt;
&lt;td&gt;1. Bus 2. Tree 3. Fire hydrant 4. Person 5. Bus stop 6. Fire truck&lt;/td&gt;
&lt;td&gt;1. Bus 2. Tree 3. Fire hydrant 4. Bus stop 5. Fire truck 6. Bus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image, which is placed on the couch along with the two cats.&lt;/td&gt;
&lt;td&gt;Yes, there is a knife in the image, which is placed on the couch along with the two cats.&lt;/td&gt;
&lt;td&gt;No, there are no cutlery items in the image. The image features a cat and a remote control, with the cat lying on a p&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;The image features a couch with two cats lying on it. One cat is positioned towards the left side of the couch, while the&lt;/td&gt;
&lt;td&gt;The image features a couch with two cats lying on it. One cat is positioned towards the left side of the couch, while the&lt;/td&gt;
&lt;td&gt;The image features a couch with two cats lying on it. One cat is positioned towards the left side of the couch, while the&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;td&gt;It is daytime in the image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image 4&lt;/td&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;1. Cat 2. Cat 3. Remote control 4. Remote control 5. Cat 6. Cat&lt;/td&gt;
&lt;td&gt;1. Cat 2. Cat 3. Remote control 4. Remote control 5. Cat 6. Cat&lt;/td&gt;
&lt;td&gt;1. Cat 2. Cat 3. Remote control 4. Remote control 5. Cat 6. Cat&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Table 3: Layer-wise pruning on different thresholds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For layer-wise pruning, we found that pruning the last 9 attention heads yielded the best results. Unlike patch-wise pruning all thresholds were able to produce responses, whether it be correct or incorrect. Responses were more or less consistent in all cases. However, just like patch-wise pruning, the model hallucinated responses in all cases.&lt;/p&gt;

&lt;p&gt;In the following table, we provide generation time across unmodified model and our two pruning strategies:&lt;/p&gt;

&lt;h3&gt;
  
  
  Image 1
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;No Change (s)&lt;/th&gt;
&lt;th&gt;Layer-wise Pruning&lt;/th&gt;
&lt;th&gt;Patch-wise Pruning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;19.50&lt;/td&gt;
&lt;td&gt;17.20&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7.54&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;18.95&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.19&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.62&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;5.70&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.44&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.48&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;19.64&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.30&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.58&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Image 2
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;No Change (s)&lt;/th&gt;
&lt;th&gt;Layer-wise Pruning&lt;/th&gt;
&lt;th&gt;Patch-wise Pruning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;18.45&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9.12&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;12.53&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;19.21&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.28&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.62&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;5.64&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.46&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.56&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;19.13&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.44&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.56&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Image 3
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;No Change (s)&lt;/th&gt;
&lt;th&gt;Layer-wise Pruning&lt;/th&gt;
&lt;th&gt;Patch-wise Pruning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;18.65&lt;/td&gt;
&lt;td&gt;13.31&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7.83&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;19.51&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.38&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;19.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;5.44&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4.92&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4.92&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;20.37&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18.62&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.76&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Image 4
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prompt&lt;/th&gt;
&lt;th&gt;No Change (s)&lt;/th&gt;
&lt;th&gt;Layer-wise Pruning&lt;/th&gt;
&lt;th&gt;Patch-wise Pruning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Are there any sort of cutlery in this image?&lt;/td&gt;
&lt;td&gt;32.89&lt;/td&gt;
&lt;td&gt;32.13&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;13.68&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Describe this image&lt;/td&gt;
&lt;td&gt;17.90&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;17.73&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;26.79&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is it night or day in this image?&lt;/td&gt;
&lt;td&gt;12.05&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.28&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all the objects here&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;11.63&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;18.07&lt;/td&gt;
&lt;td&gt;13.70&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Table 4: Comparison of generation time across all models for different prompt per image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the table, we can see that patch-wise pruning achieved 17.7% faster generation times compared to the baseline, with some individual queries running up to 4x faster. Even the more conservative layer-wise pruning approach showed 4.4% improvements over baseline processing.&lt;/p&gt;

&lt;p&gt;Not all tasks benefit equally from masking:&lt;/p&gt;

&lt;p&gt;-Object Detection Queries: Patch-wise pruning dominated, reducing "cutlery detection" times from 22.37s (baseline) to just 10.40s on average&lt;br&gt;
-Simple Binary Questions: "Is it night or day?" queries were consistently fast across all approaches (5-6 seconds)&lt;br&gt;
-Complex Description Tasks: Showed more mixed results, with layer-wise pruning often performing best&lt;br&gt;
-Object Listing: Layer-wise pruning provided the most consistent performance&lt;/p&gt;

&lt;p&gt;While patch-wise pruning won on raw speed, layer-wise pruning proved most reliable, winning 62.5% of individual comparisons. This approach rarely produced the slowest times and maintained steady performance across different image types and question complexity.&lt;/p&gt;

&lt;h1&gt;
  
  
  Future Directions
&lt;/h1&gt;

&lt;p&gt;This is an ongoing experiment. This blog serves as a journal of our progress so far and will continually be updated once new findings are found. A lot more things need to be added; a more comprehensive reference section and more thorough experimentation are the two things that come to mind. Hopefully we'll be able to get a paper through this independent endeavor of ours.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;[1] H. Liu, C. Li, Q. Wu, Y. J. Lee, “Visual Instruction Tuning,” presented at the A. Oh, T. Naumann, A. Globerson, K. Saenko, M.Hardt, S. Levine (Eds.), Advances in Neural Information Processing Systems, vol. 36, pp. 34892–34916 (2023).&lt;/p&gt;

&lt;p&gt;[2] T. Wolf, L. Debut, V. Sanh, J. Chaumond, C. Delangue, A. Moi, P. Cistac, T. Rault, R. Louf, M. Funtowicz, J. Davison, S. Shleifer, P. von Platen, C. Ma, Y. Jernite, J. Plu, C. Xu, T. L. Scao, S. Gugger, M. Drame, Q. Lhoest, A. M. Rush, “Transformers: State-of-the-Art Natural Language Processing,” presented at the Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp.38–45 (2020 Oct.).&lt;/p&gt;

&lt;p&gt;[3] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, G. Krueger, I. Sutskever, “Learning Transferable Visual Models From Natural Language Supervision,” (2021), URL &lt;a href="https://arxiv.org/abs/2103.00020" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2103.00020&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>vlm</category>
    </item>
  </channel>
</rss>
