import{s as FM,o as HM,n as OM}from"../chunks/scheduler.18a86fab.js";import{S as KM,i as PM,g as y,s as t,r as j,A as Ms,h as U,f as l,c as n,j as bM,u as o,x as w,k as LM,y as h,a,v as C,d as u,t as J,w as i}from"../chunks/index.98837b22.js";import{D as ss}from"../chunks/Docstring.6758ea23.js";import{C as NM}from"../chunks/CodeBlock.8d0c2e8a.js";import{E as ls}from"../chunks/ExampleCodeBlock.0c42463f.js";import{H as r}from"../chunks/Heading.7e7e0c5b.js";import{E as as}from"../chunks/index.92f616ba.js";function ts(MM){let e,I;return e=new NM({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBMbGF2YVByb2Nlc3NvciUyQyUyMExsYXZhRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbF9kZWJ1Z2dpbmdfdXRpbHMlMjBpbXBvcnQlMjBtb2RlbF9hZGRpdGlvbl9kZWJ1Z2dlcl9jb250ZXh0JTBBdG9yY2gucmFuZG9tLm1hbnVhbF9zZWVkKDY3MyklMEElMEElMjMlMjBsb2FkJTIwcHJldHJhaW5lZCUyMG1vZGVsJTIwYW5kJTIwcHJvY2Vzc29yJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJsbGF2YS1oZiUyRmxsYXZhLTEuNS03Yi1oZiUyMiUwQXByb2Nlc3NvciUyMCUzRCUyMExsYXZhUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFtb2RlbCUyMCUzRCUyMExsYXZhRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMGxvd19jcHVfbWVtX3VzYWdlJTNEVHJ1ZSklMEElMEElMjMlMjBjcmVhdGUlMjByYW5kb20lMjBpbWFnZSUyMGlucHV0JTBBcmFuZG9tX2ltYWdlJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KHRvcmNoLnJhbmRpbnQoMCUyQyUyMDI1NiUyQyUyMCgyMjQlMkMlMjAyMjQlMkMlMjAzKSUyQyUyMGR0eXBlJTNEdG9yY2gudWludDgpLm51bXB5KCkpJTBBJTBBJTIzJTIwcHJvbXB0JTBBcHJvbXB0JTIwJTNEJTIwJTIyJTNDaW1hZ2UlM0VEZXNjcmliZSUyMHRoaXMlMjBpbWFnZS4lMjIlMEElMEElMjMlMjBwcm9jZXNzJTIwaW5wdXRzJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0Rwcm9tcHQlMkMlMjBpbWFnZXMlM0RyYW5kb21faW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQSUyMyUyMGNhbGwlMjBmb3J3YXJkJTIwbWV0aG9kJTIwKG5vdCUyMC5nZW5lcmF0ZSEpJTBBd2l0aCUyMG1vZGVsX2FkZGl0aW9uX2RlYnVnZ2VyX2NvbnRleHQobW9kZWwlMkMlMjBkZWJ1Z19wYXRoJTNEJTIyWW91cl9kZWJ1Z19wYXRoJTIyJTJDJTIwZG9fcHJ1bmVfbGF5ZXJzJTNERmFsc2UpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0JTIwJTNEJTIwbW9kZWwuZm9yd2FyZCgqKmlucHV0cyk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LlavaProcessor, LlavaForConditionalGeneration
<span class="hljs-keyword">from</span> transformers.model_debugging_utils <span class="hljs-keyword">import</span> model_addition_debugger_context
torch.random.manual_seed(<span class="hljs-number">673</span>)

<span class="hljs-comment"># load pretrained model and processor</span>
model_id = <span class="hljs-string">&quot;llava-hf/llava-1.5-7b-hf&quot;</span>
processor = LlavaProcessor.from_pretrained(model_id)
model = LlavaForConditionalGeneration.from_pretrained(model_id, low_cpu_mem_usage=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># create random image input</span>
random_image = Image.fromarray(torch.randint(<span class="hljs-number">0</span>, <span class="hljs-number">256</span>, (<span class="hljs-number">224</span>, <span class="hljs-number">224</span>, <span class="hljs-number">3</span>), dtype=torch.uint8).numpy())

<span class="hljs-comment"># prompt</span>
prompt = <span class="hljs-string">&quot;&lt;image&gt;Describe this image.&quot;</span>

<span class="hljs-comment"># process inputs</span>
inputs = processor(text=prompt, images=random_image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># call forward method (not .generate!)</span>
<span class="hljs-keyword">with</span> model_addition_debugger_context(model, debug_path=<span class="hljs-string">&quot;Your_debug_path&quot;</span>, do_prune_layers=<span class="hljs-literal">False</span>):
    output = model.forward(**inputs)`,wrap:!1}}),{c(){j(e.$$.fragment)},l(c){o(e.$$.fragment,c)},m(c,H){C(e,c,H),I=!0},p:OM,i(c){I||(u(e.$$.fragment,c),I=!0)},o(c){J(e.$$.fragment,c),I=!1},d(c){i(e,c)}}}function ns(MM){let e,I,c,H,m,sM,d,fM="This page lists all the debugging and model adding tools used by the library, as well as the utility functions it provides for it.",lM,Q,DM="Most of those are only useful if you are adding new models in the library.",aM,g,tM,N,nM,S,xM=`This context manager is a power user tool intended for model adders.
It tracks all forward calls within a model forward and logs a slice of each input and output on a nested Json.
To note, this context manager enforces <code>torch.no_grad()</code>.`,yM,E,UM,k,BM="Because when porting models to transformers, even from python to python, model adders often have to do a lot of manual operations, involving saving and loading tensors, comparing dtypes, etc. This small tool can hopefully shave off some time.",eM,q,pM,Z,vM="Add this context manager as follows to debug a model:",jM,b,oM,L,CM,f,WM=`The debugger generates two files from the forward call, both with the same base name,
but ending either with <code>_SUMMARY.json</code> or with <code>_FULL_TENSORS.json</code>.`,uM,D,RM="The first one will contain a summary of each module’s <em>input</em> and <em>output</em> tensor values and shapes.",JM,x,iM,B,$M=`The <code>_FULL_TENSORS.json</code> file will display a full view of all tensors, which is useful
for comparing two files.`,cM,v,TM,W,wM,R,GM="Once the forward passes of two models have been traced by the debugger, one can compare the <code>json</code> output files. See below: we can see slight differences between these two implementations’ key projection layer. Inputs are mostly identical, but not quite. Looking through the file differences makes it easier to pinpoint which layer is wrong.",rM,$,_M='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/files_difference_debugging.png" alt="download-icon"/>',IM,G,AM,_,zM="This feature will only work for torch-based models, and would require more work and case-by-case approach for say <code>jax</code>-based models that are usually compiled. Models relying heavily on external kernel calls may work, but trace will probably miss some things. Regardless, any python implementation that aims at mimicking another implementation can be traced once instead of reran N times with breakpoints.",hM,z,YM="If you pass <code>do_prune_layers=False</code> to your model debugger, ALL the layers will be outputted to <code>json</code>. Else, only the first and last layer will be shown. This is useful when some layers (typically cross-attention) appear only after N layers.",mM,p,Y,SM,V,EM,O,VM=`This context manager is a power user tool intended for model adders.
It tracks all forward calls within a model forward and logs a slice of each input and output on a nested Json.
To note, this context manager enforces <code>torch.no_grad()</code>.`,kM,X,qM,K,XM="add the context manager to a model to debug",ZM,A,dM,F,QM,P,gM;return m=new r({props:{title:"Model debugging toolboxes",local:"model-debugging-toolboxes",headingTag:"h1"}}),g=new r({props:{title:"Model addition debuggers",local:"model-addition-debuggers",headingTag:"h2"}}),N=new r({props:{title:"Model addition debugger - context manager for model adders",local:"model-addition-debugger---context-manager-for-model-adders",headingTag:"h3"}}),E=new r({props:{title:"Rationale",local:"rationale",headingTag:"h3"}}),q=new r({props:{title:"Usage",local:"usage",headingTag:"h3"}}),b=new NM({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBMbGF2YVByb2Nlc3NvciUyQyUyMExsYXZhRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbF9kZWJ1Z2dpbmdfdXRpbHMlMjBpbXBvcnQlMjBtb2RlbF9hZGRpdGlvbl9kZWJ1Z2dlcl9jb250ZXh0JTBBdG9yY2gucmFuZG9tLm1hbnVhbF9zZWVkKDY3MyklMEElMEElMjMlMjBsb2FkJTIwcHJldHJhaW5lZCUyMG1vZGVsJTIwYW5kJTIwcHJvY2Vzc29yJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJsbGF2YS1oZiUyRmxsYXZhLTEuNS03Yi1oZiUyMiUwQXByb2Nlc3NvciUyMCUzRCUyMExsYXZhUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFtb2RlbCUyMCUzRCUyMExsYXZhRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMGxvd19jcHVfbWVtX3VzYWdlJTNEVHJ1ZSklMEElMEElMjMlMjBjcmVhdGUlMjByYW5kb20lMjBpbWFnZSUyMGlucHV0JTBBcmFuZG9tX2ltYWdlJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KHRvcmNoLnJhbmRpbnQoMCUyQyUyMDI1NiUyQyUyMCgyMjQlMkMlMjAyMjQlMkMlMjAzKSUyQyUyMGR0eXBlJTNEdG9yY2gudWludDgpLm51bXB5KCkpJTBBJTBBJTIzJTIwcHJvbXB0JTBBcHJvbXB0JTIwJTNEJTIwJTIyJTNDaW1hZ2UlM0VEZXNjcmliZSUyMHRoaXMlMjBpbWFnZS4lMjIlMEElMEElMjMlMjBwcm9jZXNzJTIwaW5wdXRzJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0Rwcm9tcHQlMkMlMjBpbWFnZXMlM0RyYW5kb21faW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQSUyMyUyMGNhbGwlMjBmb3J3YXJkJTIwbWV0aG9kJTIwKG5vdCUyMC5nZW5lcmF0ZSEpJTBBd2l0aCUyMG1vZGVsX2FkZGl0aW9uX2RlYnVnZ2VyX2NvbnRleHQoJTBBJTIwJTIwbW9kZWwlMkMlMEElMjAlMjBkZWJ1Z19wYXRoJTNEJTIyb3B0aW9uYWxfcGF0aF90b195b3VyX2RpcmVjdG9yeSUyMiUyQyUwQSUyMCUyMGRvX3BydW5lX2xheWVycyUzREZhbHNlJTIwJTIzJTIwVGhpcyUyMHdpbGwlMjBvdXRwdXQlMjBBTEwlMjB0aGUlMjBsYXllcnMlMjBvZiUyMGElMjBtb2RlbC4lMEElMjAlMjApJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0JTIwJTNEJTIwbW9kZWwuZm9yd2FyZCgqKmlucHV0cyklMEE=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> LlavaProcessor, LlavaForConditionalGeneration
<span class="hljs-keyword">from</span> transformers.model_debugging_utils <span class="hljs-keyword">import</span> model_addition_debugger_context
torch.random.manual_seed(<span class="hljs-number">673</span>)

<span class="hljs-comment"># load pretrained model and processor</span>
model_id = <span class="hljs-string">&quot;llava-hf/llava-1.5-7b-hf&quot;</span>
processor = LlavaProcessor.from_pretrained(model_id)
model = LlavaForConditionalGeneration.from_pretrained(model_id, low_cpu_mem_usage=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># create random image input</span>
random_image = Image.fromarray(torch.randint(<span class="hljs-number">0</span>, <span class="hljs-number">256</span>, (<span class="hljs-number">224</span>, <span class="hljs-number">224</span>, <span class="hljs-number">3</span>), dtype=torch.uint8).numpy())

<span class="hljs-comment"># prompt</span>
prompt = <span class="hljs-string">&quot;&lt;image&gt;Describe this image.&quot;</span>

<span class="hljs-comment"># process inputs</span>
inputs = processor(text=prompt, images=random_image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># call forward method (not .generate!)</span>
<span class="hljs-keyword">with</span> model_addition_debugger_context(
  model,
  debug_path=<span class="hljs-string">&quot;optional_path_to_your_directory&quot;</span>,
  do_prune_layers=<span class="hljs-literal">False</span> <span class="hljs-comment"># This will output ALL the layers of a model.</span>
  ):
    output = model.forward(**inputs)
`,wrap:!1}}),L=new r({props:{title:"Reading results",local:"reading-results",headingTag:"h3"}}),x=new NM({props:{code:" ",highlighted:`<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;module_path&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;MolmoForConditionalGeneration&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;inputs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;kwargs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;input_ids&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 589])&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.int64&quot;</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;attention_mask&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 589])&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.int64&quot;</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;pixel_values&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 5, 576, 588])&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.float32&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;mean&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-8.9514e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;std&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(9.2586e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;min&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-1.7923e+00, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;max&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(1.8899e+00, device=&#x27;cuda:0&#x27;)&quot;</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;children&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;module_path&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;MolmoForConditionalGeneration.language_model.model.embed_tokens&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;inputs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
          <span class="hljs-punctuation">{</span>
            <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 589])&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.int64&quot;</span>
          <span class="hljs-punctuation">}</span>
        <span class="hljs-punctuation">]</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;outputs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 589, 3584])&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.float32&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;mean&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(6.5460e-06, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;std&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(2.3807e-02, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;min&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-3.3398e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;max&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(3.9453e-01, device=&#x27;cuda:0&#x27;)&quot;</span>
      <span class="hljs-punctuation">}</span>
    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;module_path&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;MolmoForConditionalGeneration.vision_tower&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;inputs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
          <span class="hljs-punctuation">{</span>
            <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([5, 1, 576, 588])&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.float32&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;mean&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-8.9514e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;std&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(9.2586e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;min&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-1.7923e+00, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
            <span class="hljs-attr">&quot;max&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(1.8899e+00, device=&#x27;cuda:0&#x27;)&quot;</span>
          <span class="hljs-punctuation">}</span>
        <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;kwargs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
          <span class="hljs-attr">&quot;output_hidden_states&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;True&quot;</span>
        <span class="hljs-punctuation">}</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;children&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
        <span class="hljs-punctuation">{</span> ... and so on`,wrap:!1}}),v=new NM({props:{code:" ",highlighted:`      <span class="hljs-attr">&quot;pixel_values&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">&quot;shape&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.Size([1, 5, 576, 588])&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;dtype&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;torch.float32&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;value&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
          <span class="hljs-string">&quot;tensor([[[[-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          ...,&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00]],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;         [[-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          ...,&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.4857e+00, -1.4820e+00, -1.2100e+00,  ..., -6.0979e-01, -5.9650e-01, -3.8527e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.6755e+00, -1.7221e+00, -1.4518e+00,  ..., -7.5577e-01, -7.4658e-01, -5.5592e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-7.9957e-01, -8.2162e-01, -5.7014e-01,  ..., -1.3689e+00, -1.3169e+00, -1.0678e+00]],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;         [[-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          ...,&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-3.0322e-01, -5.0645e-01, -5.8436e-01,  ..., -6.2439e-01, -7.9160e-01, -8.1188e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-4.4921e-01, -6.5653e-01, -7.2656e-01,  ..., -3.4702e-01, -5.2146e-01, -5.1326e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-3.4702e-01, -5.3647e-01, -5.4170e-01,  ..., -1.0915e+00, -1.1968e+00, -1.0252e+00]],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;         [[-1.1207e+00, -1.2718e+00, -1.0678e+00,  ..., 1.2013e-01, -1.3126e-01, -1.7197e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-6.9738e-01, -9.1166e-01, -8.5454e-01,  ..., -5.5050e-02, -2.8134e-01, -4.2793e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-3.4702e-01, -5.5148e-01, -5.8436e-01,  ..., 1.9312e-01, -8.6235e-02, -2.1463e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          ...,&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00]],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;         [[-1.0039e+00, -9.5669e-01, -6.5546e-01,  ..., -1.4711e+00, -1.4219e+00, -1.1389e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.0039e+00, -9.5669e-01, -6.5546e-01,  ..., -1.7193e+00, -1.6771e+00, -1.4091e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.6317e+00, -1.6020e+00, -1.2669e+00,  ..., -1.2667e+00, -1.2268e+00, -8.9720e-01],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          ...,&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00],&quot;</span><span class="hljs-punctuation">,</span>
          <span class="hljs-string">&quot;          [-1.7923e+00, -1.7521e+00, -1.4802e+00,  ..., -1.7923e+00, -1.7521e+00, -1.4802e+00]]]], device=&#x27;cuda:0&#x27;)&quot;</span>
        <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;mean&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-8.9514e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;std&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(9.2586e-01, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;min&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(-1.7923e+00, device=&#x27;cuda:0&#x27;)&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-attr">&quot;max&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;tensor(1.8899e+00, device=&#x27;cuda:0&#x27;)&quot;</span>
      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>`,wrap:!1}}),W=new r({props:{title:"Comparing between implementations",local:"comparing-between-implementations",headingTag:"h3"}}),G=new r({props:{title:"Limitations and scope",local:"transformers.model_addition_debugger_context",headingTag:"h3"}}),Y=new ss({props:{name:"transformers.model_addition_debugger_context",anchor:"transformers.model_addition_debugger_context",parameters:[{name:"model",val:""},{name:"debug_path",val:": typing.Optional[str] = None"},{name:"do_prune_layers",val:": typing.Optional[bool] = True"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/model_debugging_utils.py#L336"}}),V=new r({props:{title:"Model addition debugger - context manager for model adders",local:"model-addition-debugger---context-manager-for-model-adders",headingTag:"h1"}}),X=new r({props:{title:"Usage",local:"usage",headingTag:"h2"}}),A=new ls({props:{anchor:"transformers.model_addition_debugger_context.example",$$slots:{default:[ts]},$$scope:{ctx:MM}}}),F=new as({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/internal/model_debugging_utils.md"}}),{c(){e=y("meta"),I=t(),c=y("p"),H=t(),j(m.$$.fragment),sM=t(),d=y("p"),d.textContent=fM,lM=t(),Q=y("p"),Q.textContent=DM,aM=t(),j(g.$$.fragment),tM=t(),j(N.$$.fragment),nM=t(),S=y("p"),S.innerHTML=xM,yM=t(),j(E.$$.fragment),UM=t(),k=y("p"),k.textContent=BM,eM=t(),j(q.$$.fragment),pM=t(),Z=y("p"),Z.textContent=vM,jM=t(),j(b.$$.fragment),oM=t(),j(L.$$.fragment),CM=t(),f=y("p"),f.innerHTML=WM,uM=t(),D=y("p"),D.innerHTML=RM,JM=t(),j(x.$$.fragment),iM=t(),B=y("p"),B.innerHTML=$M,cM=t(),j(v.$$.fragment),TM=t(),j(W.$$.fragment),wM=t(),R=y("p"),R.innerHTML=GM,rM=t(),$=y("p"),$.innerHTML=_M,IM=t(),j(G.$$.fragment),AM=t(),_=y("p"),_.innerHTML=zM,hM=t(),z=y("p"),z.innerHTML=YM,mM=t(),p=y("div"),j(Y.$$.fragment),SM=t(),j(V.$$.fragment),EM=t(),O=y("p"),O.innerHTML=VM,kM=t(),j(X.$$.fragment),qM=t(),K=y("p"),K.textContent=XM,ZM=t(),j(A.$$.fragment),dM=t(),j(F.$$.fragment),QM=t(),P=y("p"),this.h()},l(M){const s=Ms("svelte-u9bgzb",document.head);e=U(s,"META",{name:!0,content:!0}),s.forEach(l),I=n(M),c=U(M,"P",{}),bM(c).forEach(l),H=n(M),o(m.$$.fragment,M),sM=n(M),d=U(M,"P",{"data-svelte-h":!0}),w(d)!=="svelte-4sd845"&&(d.textContent=fM),lM=n(M),Q=U(M,"P",{"data-svelte-h":!0}),w(Q)!=="svelte-x293w1"&&(Q.textContent=DM),aM=n(M),o(g.$$.fragment,M),tM=n(M),o(N.$$.fragment,M),nM=n(M),S=U(M,"P",{"data-svelte-h":!0}),w(S)!=="svelte-1d3pgsd"&&(S.innerHTML=xM),yM=n(M),o(E.$$.fragment,M),UM=n(M),k=U(M,"P",{"data-svelte-h":!0}),w(k)!=="svelte-fewkz6"&&(k.textContent=BM),eM=n(M),o(q.$$.fragment,M),pM=n(M),Z=U(M,"P",{"data-svelte-h":!0}),w(Z)!=="svelte-jrktnj"&&(Z.textContent=vM),jM=n(M),o(b.$$.fragment,M),oM=n(M),o(L.$$.fragment,M),CM=n(M),f=U(M,"P",{"data-svelte-h":!0}),w(f)!=="svelte-1p13r1j"&&(f.innerHTML=WM),uM=n(M),D=U(M,"P",{"data-svelte-h":!0}),w(D)!=="svelte-a5x8y4"&&(D.innerHTML=RM),JM=n(M),o(x.$$.fragment,M),iM=n(M),B=U(M,"P",{"data-svelte-h":!0}),w(B)!=="svelte-1bk1mhr"&&(B.innerHTML=$M),cM=n(M),o(v.$$.fragment,M),TM=n(M),o(W.$$.fragment,M),wM=n(M),R=U(M,"P",{"data-svelte-h":!0}),w(R)!=="svelte-xwf6bx"&&(R.innerHTML=GM),rM=n(M),$=U(M,"P",{"data-svelte-h":!0}),w($)!=="svelte-9wdzxi"&&($.innerHTML=_M),IM=n(M),o(G.$$.fragment,M),AM=n(M),_=U(M,"P",{"data-svelte-h":!0}),w(_)!=="svelte-1ug7o4n"&&(_.innerHTML=zM),hM=n(M),z=U(M,"P",{"data-svelte-h":!0}),w(z)!=="svelte-1f729uy"&&(z.innerHTML=YM),mM=n(M),p=U(M,"DIV",{class:!0});var T=bM(p);o(Y.$$.fragment,T),SM=n(T),o(V.$$.fragment,T),EM=n(T),O=U(T,"P",{"data-svelte-h":!0}),w(O)!=="svelte-1d3pgsd"&&(O.innerHTML=VM),kM=n(T),o(X.$$.fragment,T),qM=n(T),K=U(T,"P",{"data-svelte-h":!0}),w(K)!=="svelte-chd0p3"&&(K.textContent=XM),ZM=n(T),o(A.$$.fragment,T),T.forEach(l),dM=n(M),o(F.$$.fragment,M),QM=n(M),P=U(M,"P",{}),bM(P).forEach(l),this.h()},h(){LM(e,"name","hf:doc:metadata"),LM(e,"content",ys),LM(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(M,s){h(document.head,e),a(M,I,s),a(M,c,s),a(M,H,s),C(m,M,s),a(M,sM,s),a(M,d,s),a(M,lM,s),a(M,Q,s),a(M,aM,s),C(g,M,s),a(M,tM,s),C(N,M,s),a(M,nM,s),a(M,S,s),a(M,yM,s),C(E,M,s),a(M,UM,s),a(M,k,s),a(M,eM,s),C(q,M,s),a(M,pM,s),a(M,Z,s),a(M,jM,s),C(b,M,s),a(M,oM,s),C(L,M,s),a(M,CM,s),a(M,f,s),a(M,uM,s),a(M,D,s),a(M,JM,s),C(x,M,s),a(M,iM,s),a(M,B,s),a(M,cM,s),C(v,M,s),a(M,TM,s),C(W,M,s),a(M,wM,s),a(M,R,s),a(M,rM,s),a(M,$,s),a(M,IM,s),C(G,M,s),a(M,AM,s),a(M,_,s),a(M,hM,s),a(M,z,s),a(M,mM,s),a(M,p,s),C(Y,p,null),h(p,SM),C(V,p,null),h(p,EM),h(p,O),h(p,kM),C(X,p,null),h(p,qM),h(p,K),h(p,ZM),C(A,p,null),a(M,dM,s),C(F,M,s),a(M,QM,s),a(M,P,s),gM=!0},p(M,[s]){const T={};s&2&&(T.$$scope={dirty:s,ctx:M}),A.$set(T)},i(M){gM||(u(m.$$.fragment,M),u(g.$$.fragment,M),u(N.$$.fragment,M),u(E.$$.fragment,M),u(q.$$.fragment,M),u(b.$$.fragment,M),u(L.$$.fragment,M),u(x.$$.fragment,M),u(v.$$.fragment,M),u(W.$$.fragment,M),u(G.$$.fragment,M),u(Y.$$.fragment,M),u(V.$$.fragment,M),u(X.$$.fragment,M),u(A.$$.fragment,M),u(F.$$.fragment,M),gM=!0)},o(M){J(m.$$.fragment,M),J(g.$$.fragment,M),J(N.$$.fragment,M),J(E.$$.fragment,M),J(q.$$.fragment,M),J(b.$$.fragment,M),J(L.$$.fragment,M),J(x.$$.fragment,M),J(v.$$.fragment,M),J(W.$$.fragment,M),J(G.$$.fragment,M),J(Y.$$.fragment,M),J(V.$$.fragment,M),J(X.$$.fragment,M),J(A.$$.fragment,M),J(F.$$.fragment,M),gM=!1},d(M){M&&(l(I),l(c),l(H),l(sM),l(d),l(lM),l(Q),l(aM),l(tM),l(nM),l(S),l(yM),l(UM),l(k),l(eM),l(pM),l(Z),l(jM),l(oM),l(CM),l(f),l(uM),l(D),l(JM),l(iM),l(B),l(cM),l(TM),l(wM),l(R),l(rM),l($),l(IM),l(AM),l(_),l(hM),l(z),l(mM),l(p),l(dM),l(QM),l(P)),l(e),i(m,M),i(g,M),i(N,M),i(E,M),i(q,M),i(b,M),i(L,M),i(x,M),i(v,M),i(W,M),i(G,M),i(Y),i(V),i(X),i(A),i(F,M)}}}const ys='{"title":"Model debugging toolboxes","local":"model-debugging-toolboxes","sections":[{"title":"Model addition debuggers","local":"model-addition-debuggers","sections":[{"title":"Model addition debugger - context manager for model adders","local":"model-addition-debugger---context-manager-for-model-adders","sections":[],"depth":3},{"title":"Rationale","local":"rationale","sections":[],"depth":3},{"title":"Usage","local":"usage","sections":[],"depth":3},{"title":"Reading results","local":"reading-results","sections":[],"depth":3},{"title":"Comparing between implementations","local":"comparing-between-implementations","sections":[],"depth":3},{"title":"Limitations and scope","local":"transformers.model_addition_debugger_context","sections":[],"depth":3}],"depth":2}],"depth":1}';function Us(MM){return HM(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class is extends KM{constructor(e){super(),PM(this,e,Us,ns,FM,{})}}export{is as component};
