Skip to content
Snippets Groups Projects
  1. Oct 07, 2019
  2. Oct 06, 2019
    • Neta Zmora's avatar
      Low-level pruning API refactor (#401) · 05d5592e
      Neta Zmora authored
      Some refactoring of the low-level pruning API
      
      Added distiller/norms.py - for calculating norms of various sub-tensors.
      
      ranked_structures_pruner.py:
      -Removed l1_magnitude, l2_magnitude. Use instead distiller.norms.l1_norm
      -Lots of refactoring
      -replaced LpRankedStructureParameterPruner.ch_binary_map_to_mask with
      distiller.thresholding.expand_binary_map
      -FMReconstructionChannelPruner.rank_and_prune_channels used L2-norm
      by default and now uses L1-norm (i.e.magnitude_fn=l2_magnitude was
      replaced with magnitude_fn=distiller.norms.l1_norm)
      
      thresholding.py:
      -Delegated lots of the work to the new norms.py.
      -Removed support for 4D (entire convolution layers) since that has not been
      maintained for a longtime. This may break some old scripts that remove entire
      layers.
      -added expand_binary_map() explicitly so others can use it. Might need to
      move to a different file
      -removed threshold_policy()
      
      utils.py:
      -use distiller.norms.xxx for sparsity stats
      Unverified
      05d5592e
  3. Sep 27, 2019
  4. Sep 24, 2019
  5. Sep 18, 2019
    • Guy Jacob's avatar
      9097d6d7
    • Neta Zmora's avatar
      compress_classifier.py: remove remarked code · f6c48f87
      Neta Zmora authored
      f6c48f87
    • Neta Zmora's avatar
      Odds and ends commit · 8d55ab15
      Neta Zmora authored
      A bundle of very small, and mostly non-functional, changes to the code.
      Mostly they are unrelated to each other
      ../../../distiller/apputils/checkpoint.py – add info to exception
      
      ../../../distiller/apputils/image_classifier.py – remove unused
      `--extras` command-line argument
      
      ../../../distiller/thinning.py – code refactoring (non-functional)
      except for adding a new public API: contract_model()
      
      ../../classifier_compression/compress_classifier.py – use
      contract_model() when using `--thinnify`
      
      ../../lottery_ticket/README.md – remove illegal characters in
      the text
      8d55ab15
  6. Sep 10, 2019
  7. Sep 06, 2019
  8. Sep 02, 2019
  9. Sep 01, 2019
    • Neta Zmora's avatar
      AMC: add pruning of FC layers · 3f7a9408
      Neta Zmora authored
      FMReconstructionChannelPruner: add support for nn.Linear layers
      utils.py: add non_zero_channels()
      thinning: support removing channels from FC layers preceding Conv layers
      test_pruning.py: add test_row_pruning()
      scheduler: init from a dictionary of Maskers
      coach_if.py – fix imports of Clipped-PPO and TD3
      3f7a9408
  10. Aug 28, 2019
  11. Aug 26, 2019
    • Neta Zmora's avatar
      Lottery Ticket Hypothesis · 78e2e4c7
      Neta Zmora authored
      Added support for saving the randomly initialized network before
      starting training; and added an implmentation showing how to extract
      a (winning) lottery ticket from the prestine network, and the
      pruned network.
      78e2e4c7
  12. Aug 13, 2019
  13. Aug 11, 2019
  14. Aug 08, 2019
  15. Aug 07, 2019
  16. Aug 06, 2019
    • Neta Zmora's avatar
      AMC and other refactoring - large merge (#339) · 02054da1
      Neta Zmora authored
      *An implementation of AMC (the previous implementation
       code has moved to a new location under 
      /distiller/examples/auto_compression/amc.  AMC is aligned
      with the ‘master’ branch of Coach.
      *compress_classifier.py is refactored.  The base code moved
      to /distiller/apputils/image_classifier.py.  Further refactoring
      will follow.
      We want to provide a simple and small API to the basic features of
      a classifier-compression application.
      This will help applications that want to use the make features of a
      classifier-compression application, without the standard training
      regiment.
      AMC is one example of a stand-alone application that needs to leverage
      the capabilities of a classifier-compression application, but is currently
      coupled to `compress_classifier.py`.
      `multi-finetune.py` is another example.
      * ranked_structures_pruner.py:
      ** Added support for grouping channels/filters
      Sometimes we want to prune a group of structures: e.g. groups of
      8-channels.  This feature does not force the groups to be adjacent,
      so it is more like a set of structures.  E.g. in the case of pruning
      channels from a 64-channels convolution, grouped by 8 channels, we 
      will prune exactly one of 0/8/16/24/32/40/48/56 channels.  I.e. 
      always a multiple of 8-channels, excluding the set of all 64 channels.
      ** Added FMReconstructionChannelPruner – this is channel
      pruning using L1-magnitude to rank and select channels to
      remove, and feature-map reconstruction to improve the
      resilience to the pruning.
      * Added a script to run multiple instances of an 
      experiment, in different processes:
       examples/classifier_compression/multi-run.py
      * Set the seed value even when not specified by the command-line
      arguments, so that we can try and recreate the session.
      * Added pruning ranking noise -
      Ranking noise introduces Gaussian noise when ranking channels/filters
      using Lp-norm.  The noise is introduced using the epsilon-greedy
      methodology, where ranking using exact Lp-norm is considered greedy.
      * Added configurable rounding of pruning level: choose whether to 
      Round up/down when rounding the number of structures to prune 
      (rounding is always to an integer).  
      Unverified
      02054da1
  17. Jul 23, 2019
    • Guy Jacob's avatar
      NCF changes to make it compatible with latest changes in master · 81787436
      Guy Jacob authored
      * Pass the 'sigmoid' flag in NeuMF.forward as a bool tensor instead of
        a simple boolean. Required to make the model traceable (it?d be better
        to not have it an argument of forward at all, but keeping changes to
        a minimum)
      * Call prepare_model with dummy_input
      81787436
  18. Jul 22, 2019
    • Guy Jacob's avatar
      Fix non 1:1 mapping between model w. ModuleList and SummaryGraph (#328) · b614330c
      Guy Jacob authored
      The PyTorch trace mechanism doesn't "see" torch.nn.ModuleList modules
      (since they don't have a forward function). As a result, the mapping
      from module names at the Python model definition level to the
      scope-names at the trace level is not 1:1. This makes it impossible for
      us to map back from SummaryGraph ops to their respective nn.Modules,
      which is required for flows like BatchNorm folding and stats fusion in
      post-training quantization.
      
      In #313 we handled this issue specifically in DistillerLSTM, but it
      makes much more sense to have a generic and automatic solution for this
      issue, which doesn't require the user to modify the model. This is such
      a solution.
          
      * Implemented DistillerModuleList, a replacement for nn.ModuleList
        which results in full and unique scope-names
      * See documentation for this class in summary_graph.py for extensive
        details on the issue and solution
      * When generating a SummaryGraph, the model is scanned and all instances
        of torch.nn.ModuleList are replaced with DistillerModulelist
      * Add tests for new functionality
      * Partially revert changes made to DistillerLSTM in commit 43548deb:
        Keep the refactored _create_cells_list function, but have it create
        a standard torch.nn.ModuleList (since we're the ModuleList issue
        automatically now, and no need to confuse users with ad-hoc list 
        implementations
      Unverified
      b614330c
  19. Jul 10, 2019
    • Guy Jacob's avatar
      Update post-train quant command line example · 112163eb
      Guy Jacob authored
      Unverified
      112163eb
    • Guy Jacob's avatar
      Post-Train Quantization: BN folding and "net-aware quantization" (#313) · 43548deb
      Guy Jacob authored
      * "Net-aware quantization" - using the term coined in
        https://arxiv.org/abs/1811.09886. (section 3.2.2).
        Refers to considering sequences of modules when quantizing. This 
        isn't exactly layer fusion - we modify activation stats prior to
        setting quantization parameters, to make sure that when a module
        is followed by certain activation functions, only the relevant
        ranges are quantized. We do this for:
          * ReLU - Clip all negative values
          * Tanh / Sigmoid - Clip according to the (approximated) saturation
            values for these functions. We use [-4, 4] for tanh and [-6, 6]
            for sigmoid.
      
      * Perform batch-norm folding before post-training quantization.
        Batch-norm parameters are folded into the parameters of the previous
        layer and the BN layer is replaced with an identity module.
      
      * Both BN folding and "net-aware" are now automatically executed
        in PostTrainLinearQuantizer (details of this change below)
      
      * BN folding enabled by new generic mechanism to "fuse" module
        sequences (at the Python API level)
          * First module in sequence is replaced/modified by a user-provided
            function, rest of moudles replaced with nn.Identity
      
      * Quantizer changes:
        * Optionally create adjacency map during prepare_model
        * Subclasses may enforce adjacency map creation
        * Refatcoring: Replace _prepare_model_impl with pre and post
          override-able "callbacks", so core functionality is always executed
      
      * PostTrainLinearQuantizer Changes:
        * Enforce creation of adjacency map. This means users must now pass a
          dummy input to PostTrainLinearQuantizer.prepare_model
        * Before module replacement - Apply BN folding and stats updates according
          to net-aware quantization
      
      * Updated the language model quantization tutorial to reflect the new
        functionality
      
      * Updated the image classification post-train quantization samples
        (command line and YAML)
      
      * Other changes:
        * Distller LSTM implementation:
          Replace the ModuleList for cells with a plain list. The PyTorch trace
          mechanism doesn't "see" ModuleList objects, it only sees the 
          contained modules. This means that the "scopeName" of these modules
          isn't complete, which makes it impossible to match op names in 
          SummaryGraph to modules in the Python model.
        * ActivationStatsCollector: Ignore nn.Identity modules
      Unverified
      43548deb
  20. Jul 04, 2019
    • Guy Jacob's avatar
      Switch to PyTorch 1.1.0 (#306) · 032b1f74
      Guy Jacob authored
      * PyTorch 1.1.0 now required
        - Moved other dependencies to up-to-date versions as well
      * Adapt LR scheduler to PyTorch 1.1 API changes:
        - Change lr_scheduler.step() calls to succeed validate calls,
          during training
        - Pass to lr_scheduler.step() caller both loss and top1
          (Resolves issue #240)
      * Adapt thinning for PyTorch 1.1 semantic changes
        - **KNOWN ISSUE**: When a thinning recipe is applied, in certain
          cases PyTorch displays this warning:
          "UserWarning: non-inplace resize is deprecated".
          To be fixed later
      * SummaryGraph: Workaround for new scope name issue from PyTorch 1.1.0
      * Adapt to updated PyTest version:
        - Stop using deprecated 'message' parameter of pytest.raises(),
          use pytest.fail() instead
        - Make sure only a single test case per pytest.raises context
      * Move PyTorch version check to root __init__.py 
        - This means the version each checked when Distiller is first
          imported. A RuntimeError is raised if the version is wrong.
      * Updates to parameter_histograms notebook:
        - Replace deprecated normed argument with density
        - Add sparsity rate to plot title
        - Load model in CPU
      Unverified
      032b1f74
  21. Jul 03, 2019
  22. Jul 01, 2019
  23. Jun 03, 2019
    • Lev Zlotnik's avatar
      [Breaking] PTQ: Removed special handling of clipping overrides · 3cde6c5e
      Lev Zlotnik authored
      * In PostTrainLinearQuantizer - moved 'clip_acts' and 'clip_n_stds'
        to overrides, removed 'no_clip_layers' parameter from __init__
      * The 'no_clip_layers' command line argument REMAINS, handled in 
        PostTrainLinearQuantizer.from_args()
      * Removed old code from comments, fixed warnings in 
        test_post_train_quant.py
      * Updated tests
      * Update post-train quant sample YAML
      3cde6c5e
  24. May 29, 2019
  25. May 26, 2019
    • Neta Zmora's avatar
      Added support for setting the PRNG seed (#269) · fe27ab90
      Neta Zmora authored
      Added set_seed() to Distiller and added support for seeding the PRNG when setting --deterministic mode (prior to this change, the seed is always set to zero when running in deterministic mode.
      The PRNGs of Pytorch (CPU & Cuda devices), numpy and Python are set.
      Added support for ```--seed``` to classifier_compression.py.
      Unverified
      fe27ab90
Loading