Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a check for notebook (and image?) file size #1678

Open
Eric-Arellano opened this issue Jul 10, 2024 · 1 comment
Open

Consider adding a check for notebook (and image?) file size #1678

Eric-Arellano opened this issue Jul 10, 2024 · 1 comment

Comments

@Eric-Arellano
Copy link
Collaborator

#1673 is an example of an enormous file size we didn't realize. That has two major downsides:

  1. Makes the site slower for users to access, especially when they have slow Internet
  2. Slows down next.js's build process

I think #1672 may help address this. But either way, we may want to add a check that file sizes don't cross a threshold, e.g. >400MB. This would be at least for Jupyter notebooks, but maybe also for dedicated image files.

The allowlist mechanism should set new thresholds, e.g. (my-file.ipynb, 600) to set a threshold of 600MB.

FYI: how to reduce Jupyter notebook image size

Often PNGs are smaller than SVGs:

# Don't use SVGs for this file because the images are too large,
# and the SVGs are much larger than their PNGs equivalents.
%config InlineBackend.figure_format='png'

You can reduce the resolution of Matplotlib figures. However, this often makes the image less useful and I think it tends to be better to instead set figsize:

import matplotlib
matplotlib.rcParams["figure.dpi"] = 100

You can sometimes set figsize directly in Qiskit SDK:

# We set `figsize` to a smaller size to make the documentation website faster
# to load. Normally, you do not need to set the argument.
plot_gate_map(backend, figsize=(4, 4))

If figsize is not exposed, then you can change the returning figure:

fig = plot_circuit_layout(isa_circuit, backend=backend)
fig.set_size_inches(0.5 * fig.get_size_inches())
fig

One of the other techniques is to see if any of the images can be removed entirely. Are they pulling their weight?

@frankharkins
Copy link
Member

frankharkins commented Jul 11, 2024

Note that unless the SVG is is significantly bigger than its PNG equivalent, it may still load faster for users. SVGs can be compressed a lot when sent over the network, whereas PNGs are already compressed so the file size we see is much closer to what's actually sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants