-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathproblems.json
More file actions
2247 lines (2247 loc) · 77.9 KB
/
Copy pathproblems.json
File metadata and controls
2247 lines (2247 loc) · 77.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"count": 65,
"problems": [
{
"id": "lin-regression",
"legacy_ids": [
"v1-1"
],
"title": "Implement Linear Regression",
"description": "Build a linear regression model from scratch using PyTorch tensors and autograd, fitting a line to synthetic data with gradient descent.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/lin-regression/lin-regression.ipynb",
"solution": "torch/basic/lin-regression/lin-regression_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/lin-regression/lin-regression.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"LinearRegressionModel"
],
"hints": [
"A single nn.Linear(1, 1) is the whole model.",
"forward() just applies that layer to the input.",
"Train with MSELoss and an SGD/Adam optimizer."
]
},
{
"id": "custom-dataset",
"legacy_ids": [
"v1-2"
],
"title": "Write a Custom Dataset and DataLoader",
"description": "Create a custom Dataset class and use DataLoader to batch, shuffle, and iterate over your data for training.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/custom-dataset/custom-dataset.ipynb",
"solution": "torch/basic/custom-dataset/custom-dataset_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/custom-dataset/custom-dataset.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"LinearRegressionDataset"
],
"hints": [
"Subclass torch.utils.data.Dataset and implement __len__ and __getitem__.",
"Read the file once in __init__ and keep X and y as float32 tensors; __getitem__ should just index them.",
"__getitem__(i) returns the pair (X[i], y[i]) \u2014 DataLoader stacks those into batches for you, so do not batch inside the Dataset."
]
},
{
"id": "custom-activation",
"legacy_ids": [
"v1-3"
],
"title": "Write a Custom Activation Function",
"description": "Implement a custom activation function as a PyTorch module and use it inside a neural network.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/custom-activation/custom-activation.ipynb",
"solution": "torch/basic/custom-activation/custom-activation_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/custom-activation/custom-activation.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"CustomActivationModel"
],
"hints": [
"An activation is just a function of the tensor; you can write it inline or as an nn.Module.",
"Make sure it is differentiable \u2014 use torch ops, not Python branching on tensor values.",
"Apply it between the linear layers in forward()."
]
},
{
"id": "custom-loss",
"legacy_ids": [
"v1-4"
],
"title": "Implement Custom Loss Function (Huber Loss)",
"description": "Build Huber loss from scratch \u2014 a robust loss function that's quadratic for small errors and linear for large ones.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/custom-loss/custom-loss.ipynb",
"solution": "torch/basic/custom-loss/custom-loss_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/custom-loss/custom-loss.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"HuberLoss"
],
"hints": [
"Huber is quadratic for small errors and linear for large ones.",
"The switch happens at |error| == delta.",
"0.5*e^2 below the threshold; delta*(|e| - 0.5*delta) above it."
]
},
{
"id": "custom-dnn",
"legacy_ids": [
"v1-5"
],
"title": "Implement a Deep Neural Network",
"description": "Construct a multi-layer feedforward neural network with nonlinear activations, training it on a classification task.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/custom-DNN/custon-DNN.ipynb",
"solution": "torch/basic/custom-DNN/custon-DNN_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/custom-DNN/custon-DNN.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"DNNModel"
],
"hints": [
"Stack Linear layers with a nonlinearity between them.",
"Without an activation between layers the whole stack collapses to one linear map.",
"The last layer's out_features is your output dimension."
]
},
{
"id": "tensorboard",
"legacy_ids": [
"v1-6"
],
"title": "Visualize Training with TensorBoard",
"description": "Log training metrics, model graphs, and embeddings to TensorBoard for interactive visualization.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/tensorboard/tensorboard.ipynb",
"solution": "torch/basic/tensorboard/tensorboard_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/tensorboard/tensorboard.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"LinearRegressionModel"
],
"hints": [
"The model itself is a plain nn.Linear(1, 1).",
"Log with writer.add_scalar('Loss/train', loss.item(), step).",
"Run `tensorboard --logdir=runs` to view it."
]
},
{
"id": "save-model",
"legacy_ids": [
"v1-7"
],
"title": "Save and Load PyTorch Model",
"description": "Serialize model weights with state_dict and reload them, handling device mapping and architecture changes.",
"difficulty": "basic",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/basic/save-model/save_model.ipynb",
"solution": "torch/basic/save-model/save_model_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/basic/save-model/save_model.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "cnn",
"legacy_ids": [
"v1-8"
],
"title": "Implement a CNN on CIFAR-10",
"description": "Build and train a convolutional neural network to classify CIFAR-10 images using conv layers, pooling, and batch norm.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/cnn/CNN.ipynb",
"solution": "torch/easy/cnn/CNN_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/cnn/CNN.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"CNNModel"
],
"hints": [
"CIFAR-10 images are 3x32x32 and there are 10 classes.",
"Track the spatial size through each pool: 32 -> 16 after one 2x2 pool.",
"The first Linear needs in_features = channels * height * width after flattening."
]
},
{
"id": "rnn",
"legacy_ids": [
"v1-9"
],
"title": "Implement an RNN from Scratch",
"description": "Write a recurrent neural network cell from scratch using raw tensor operations, implementing the hidden state update manually.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/rnn/RNN.ipynb",
"solution": "torch/easy/rnn/RNN_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/rnn/RNN.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"RNNModel"
],
"hints": [
"The input is (batch, seq_len, input_size) \u2014 nn.RNN needs batch_first=True to read it that way.",
"Feed only the final hidden state into the fully connected layer; that is the summary of the whole sequence.",
"The output should be (batch, 1): one predicted next value per sequence, not one per timestep."
]
},
{
"id": "augmentation",
"legacy_ids": [
"v1-10"
],
"title": "Data Augmentation with torchvision.transforms",
"description": "Apply random flips, crops, color jitter, and other augmentations to training images using torchvision's transform pipeline.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/augmentation/augmentation.ipynb",
"solution": "torch/easy/augmentation/augmentation_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/augmentation/augmentation.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "benchmark",
"legacy_ids": [
"v1-11"
],
"title": "Add Benchmarking to PyTorch Code",
"description": "Profile PyTorch operations using torch.utils.benchmark, measuring GPU/CPU time and comparing implementations.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/benchmark/bench.ipynb",
"solution": "torch/easy/benchmark/bench_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/benchmark/bench.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"SimpleNN"
],
"hints": [
"Flatten the 28x28 image before the first Linear layer.",
"Use time.perf_counter() around the epoch, not time.time().",
"On CUDA you must torch.cuda.synchronize() before stopping the clock."
]
},
{
"id": "autoencoder",
"legacy_ids": [
"v1-12"
],
"title": "Train an Autoencoder for Anomaly Detection",
"description": "Build an autoencoder that learns normal data patterns, then detect anomalies by measuring reconstruction error.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/autoencoder/autoencoder.ipynb",
"solution": "torch/easy/autoencoder/autoencoder_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/autoencoder/autoencoder.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"Autoencoder"
],
"hints": [
"The decoder must undo the encoder's downsampling, so the output matches the input shape.",
"ConvTranspose2d with stride=2 doubles the spatial size; output_padding fixes off-by-ones.",
"Train it to reconstruct its own input with MSELoss."
]
},
{
"id": "quantize-lm",
"legacy_ids": [
"v1-13"
],
"title": "Quantize Your Language Model",
"description": "Apply post-training quantization to reduce model size and inference latency while maintaining accuracy.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/quantize-lm/quantize-language-model.ipynb",
"solution": "torch/easy/quantize-lm/quantize-language-model_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/quantize-lm/quantize-language-model.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"LanguageModel"
],
"hints": [
"LanguageModel(vocab_size, embed_size, hidden_size, num_layers): Embedding -> LSTM(batch_first=True) -> Linear -> Softmax.",
"Predict the *next* token, so take the last timestep of the LSTM output (lstm_out[:, -1, :]) before the Linear \u2014 the result is (batch, vocab_size).",
"torch.ao.quantization.quantize_dynamic(model, {nn.Linear, nn.LSTM}, dtype=torch.qint8) only rewrites modules it recognises, so build the model out of nn.Linear / nn.LSTM rather than raw matmuls."
]
},
{
"id": "cuda-amp",
"legacy_ids": [
"v1-14"
],
"title": "Mixed Precision Training with torch.cuda.amp",
"description": "Use automatic mixed precision to train models faster with float16, managing loss scaling and gradient overflow.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/easy/cuda-amp/cuda-amp.ipynb",
"solution": "torch/easy/cuda-amp/cuda-amp_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/easy/cuda-amp/cuda-amp.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "cnn-param-init",
"legacy_ids": [
"v1-15"
],
"title": "CNN Parameter Initialization",
"description": "Explore how different weight initialization strategies (Xavier, Kaiming, etc.) affect CNN training convergence.",
"difficulty": "medium",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/medium/cnn-param-init/CNN_ParamInit.ipynb",
"solution": "torch/medium/cnn-param-init/CNN_ParamInit_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/medium/cnn-param-init/CNN_ParamInit.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"config_init"
],
"hints": [
"config_init returns the initializer *function*, it does not run it \u2014 you use it as `model.apply(config_init('xavier'))`.",
"Each initializer takes one module and should only touch it when it is an nn.Conv2d or nn.Linear; apply() walks containers and activations too.",
"torch.nn.init has all four: zeros_, normal_, xavier_normal_ (variance 1/n) and kaiming_normal_ (variance 2/n). Do not forget the bias."
]
},
{
"id": "cnn-scratch",
"legacy_ids": [
"v1-16"
],
"title": "Implement a CNN from Scratch",
"description": "Build convolutional layers from raw tensor operations \u2014 implementing forward passes with cross-correlation and learnable filters.",
"difficulty": "medium",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/medium/cnn-scratch/CNN_scratch.ipynb",
"solution": "torch/medium/cnn-scratch/CNN_scratch_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/medium/cnn-scratch/CNN_scratch.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"Conv2dCustom",
"MaxPool2dCustom"
],
"hints": [
"Output size is (H + 2*padding - kernel) // stride + 1 per spatial dim.",
"F.unfold turns sliding windows into columns if you want to avoid Python loops.",
"Do not forget to add the bias, once per output channel."
]
},
{
"id": "lstm",
"legacy_ids": [
"v1-17"
],
"title": "Implement an LSTM from Scratch",
"description": "Code the LSTM cell equations from scratch: forget gate, input gate, cell state update, and output gate using raw tensors.",
"difficulty": "medium",
"category": "",
"tracks": [
"basics"
],
"companies": [],
"question": "torch/medium/lstm/LSTM.ipynb",
"solution": "torch/medium/lstm/LSTM_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/medium/lstm/LSTM.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"CustomLSTMModel",
"LSTMModel"
],
"hints": [
"CustomLSTMModel(input_dim, hidden_units).forward(inputs, H_C=None) returns (predictions, (H, C)) with predictions shaped (batch, seq_len, 1).",
"Per timestep: i, f, o = sigmoid(...), C~ = tanh(...), C = f*C + i*C~, H = o*tanh(C). Stack every H and push the stack through the Linear.",
"When H_C is given, start from it instead of a fresh state \u2014 that is what makes the model resumable, and zeros (not randn) are the right default."
]
},
{
"id": "alexnet",
"legacy_ids": [
"v1-18"
],
"title": "Implement AlexNet from Scratch",
"description": "Recreate the AlexNet architecture that started the deep learning revolution, with its 5 conv + 3 FC layer design.",
"difficulty": "medium",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/medium/alexnet/alexnet.ipynb",
"solution": "torch/medium/alexnet/alexnet_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/medium/alexnet/alexnet.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"AlexNet"
],
"hints": [
"AlexNet expects 3x224x224 input and ends in a classifier over num_classes.",
"Five conv layers with max-pooling, then three fully connected layers.",
"Track the spatial size through each stride and pool to size the first Linear."
]
},
{
"id": "3dcnn",
"legacy_ids": [
"v1-21"
],
"title": "Train a 3D CNN for CT Image Segmentation",
"description": "Extend 2D convolutions to 3D for volumetric medical image segmentation on CT scans.",
"difficulty": "medium",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/medium/3dcnn/3DCNN.ipynb",
"solution": "torch/medium/3dcnn/3DCNN_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/medium/3dcnn/3DCNN.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"MedCNN",
"compute_dice_loss"
],
"hints": [
"The input is [B, D, C, W, H]. Fold depth into the batch (view(B*D, C, W, H)) for the 2D backbone, then unfold and permute to [B, C, D, W, H] for Conv3d.",
"ResNet-18 with its last two children stripped divides W and H by 32, so the ConvTranspose3d stack has to multiply them back by 32 \u2014 use kernel/stride (1, k, k) so the depth axis is left alone.",
"Dice over binary masks is 2*|pred \u2229 label| / (|pred| + |label|); finish the network with sigmoid so pred is a probability the overlap can be computed on."
]
},
{
"id": "custom-autograd",
"legacy_ids": [
"v1-22"
],
"title": "Write a Custom Autograd Function (SILU)",
"description": "Implement SiLU activation with a custom autograd Function, defining both forward and backward passes manually.",
"difficulty": "hard",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/hard/custom-autograd/custom-autgrad-function.ipynb",
"solution": "torch/hard/custom-autograd/custom-autgrad-function_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/hard/custom-autograd/custom-autgrad-function.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"LearnedSiLUFunction",
"LinearRegressionModel"
],
"hints": [
"forward(ctx, x, slope) returns slope * x * sigmoid(x); ctx.save_for_backward whatever the backward pass needs.",
"d/dx [x*sigmoid(x)] = sigmoid(x) + x*sigmoid(x)*(1 - sigmoid(x)); multiply by slope and by grad_output.",
"backward must return one gradient per forward input: d/dslope is grad_output * x * sigmoid(x). Keep the slope an nn.Parameter in the model so the optimizer updates it."
]
},
{
"id": "transformer",
"legacy_ids": [
"v1-26"
],
"title": "Write a Transformer from Scratch",
"description": "Build the full transformer architecture \u2014 multi-head attention, positional encoding, encoder-decoder stacks \u2014 from raw tensors.",
"difficulty": "hard",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/hard/transformer/transformer.ipynb",
"solution": "torch/hard/transformer/transformer_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/hard/transformer/transformer.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"PositionalEncoding",
"MultiHeadSelfAttention",
"FeedForward",
"TransformerEncoderLayer",
"TransformerModel"
],
"hints": [
"Shapes: everything below the model works on (batch, seq_len, embed_dim) and returns the same shape.",
"In attention, split the last dim into (num_heads, head_dim) and move heads next to the batch: (B, H, T, head_dim). Scale the scores by 1/sqrt(head_dim) before the softmax over the *last* axis.",
"PositionalEncoding builds a (max_len, d_model) table once with sin(pos/10000^(2i/d)) and cos(...), registers it as a buffer, and forward just adds the first seq_len rows to x."
]
},
{
"id": "gan",
"legacy_ids": [
"v1-27"
],
"title": "Write a GAN",
"description": "Implement a generative adversarial network with competing generator and discriminator networks trained via minimax loss.",
"difficulty": "hard",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/hard/GAN/GAN.ipynb",
"solution": "torch/hard/GAN/GAN_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/hard/GAN/GAN.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"Generator",
"Discriminator"
],
"hints": [
"Generator(input_dim, output_dim) maps a latent vector to one fake sample; Discriminator(input_dim) maps a sample to a single number.",
"End the generator with Tanh so samples live in [-1, 1], and the discriminator with Sigmoid so its output is a probability BCELoss can take.",
"When you train the generator do NOT detach the fake batch \u2014 the gradient has to flow back through the discriminator into the generator."
]
},
{
"id": "seq-seq",
"legacy_ids": [
"v1-28"
],
"title": "Sequence-to-Sequence with Attention",
"description": "Build an encoder-decoder model with Bahdanau attention for sequence transduction tasks like translation.",
"difficulty": "hard",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/hard/seq-seq/seq-to-seq-with-Attention.ipynb",
"solution": "torch/hard/seq-seq/seq-to-seq-with-Attention_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/hard/seq-seq/seq-to-seq-with-Attention.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"Encoder"
],
"hints": [
"Encoder(input_dim, embed_dim, hidden_dim, num_layers): nn.Embedding over the source vocabulary, then nn.LSTM(embed_dim, hidden_dim, num_layers, batch_first=True).",
"forward returns (outputs, (hidden, cell)) \u2014 the attention needs every timestep, the decoder needs the final states to start from.",
"With batch_first=True outputs is (batch, src_len, hidden_dim) while hidden and cell stay (num_layers, batch, hidden_dim)."
]
},
{
"id": "xai",
"legacy_ids": [
"v1-31"
],
"title": "Explainable AI (GradCAM/SHAP)",
"description": "Visualize which image regions drive CNN predictions using Grad-CAM heatmaps and SHAP feature attributions.",
"difficulty": "hard",
"category": "",
"tracks": [
"advanced"
],
"companies": [],
"question": "torch/hard/xai/xai.ipynb",
"solution": "torch/hard/xai/xai_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/torch/hard/xai/xai.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "create-embeddings-out-of-an-llm",
"legacy_ids": [],
"title": "Create Embeddings Out Of An Llm",
"description": "",
"difficulty": "medium",
"category": "",
"tracks": [],
"companies": [],
"question": "llm/Create-Embeddings-out-of-an-LLM/embeddings-q2.ipynb",
"solution": null,
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Create-Embeddings-out-of-an-LLM/embeddings-q2.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "flash-attention",
"legacy_ids": [],
"title": "Flash Attention",
"description": "",
"difficulty": "medium",
"category": "",
"tracks": [],
"companies": [],
"question": "llm/Flash-Attention/flash-attention.ipynb",
"solution": null,
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Flash-Attention/flash-attention.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": true,
"entries": [
"flash_attention_pytorch"
],
"hints": [
"Keep a running max, a running denominator l, and a running output accumulator; on each K/V tile rescale all three by alpha = exp(prev_max - new_max).",
"Divide the accumulator by l only once, after the loop \u2014 not inside it.",
"L is the logsumexp of the scaled scores: running_max + log(l) at the end."
]
},
{
"id": "rms-norm",
"legacy_ids": [
"v2-2"
],
"title": "Implement RMS Norm",
"description": "Build Root Mean Square Layer Normalization used in LLaMA and modern transformers \u2014 simpler and faster than LayerNorm.",
"difficulty": "easy",
"category": "modern-architectures",
"tracks": [
"basics",
"llm-path"
],
"companies": [],
"question": "llm/RMS-Norm/rms-norm.ipynb",
"solution": null,
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/RMS-Norm/rms-norm.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": null,
"graded": false,
"entries": [],
"hints": null
},
{
"id": "byte-pair-encoder",
"legacy_ids": [
"v2-3"
],
"title": "Implement Byte Pair Encoding from Scratch",
"description": "Build the BPE tokenizer algorithm that iteratively merges frequent character pairs to build a subword vocabulary.",
"difficulty": "easy",
"category": "",
"tracks": [
"basics",
"llm-path"
],
"companies": [],
"question": "llm/Byte-Pair-Encoder/BPE-q3.ipynb",
"solution": "llm/Byte-Pair-Encoder/BPE-q3-SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Byte-Pair-Encoder/BPE-q3.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 1,
"graded": true,
"entries": [
"get_vocab",
"get_stats",
"merge_vocab",
"byte_pair_encoding"
],
"hints": [
"get_vocab splits each word into characters plus an end-of-word marker, and counts it.",
"get_stats counts adjacent symbol pairs weighted by each word's frequency.",
"A merge replaces every adjacent (a, b) with the single symbol 'ab' \u2014 the spelling of each word must not change, only how it is chopped up."
]
},
{
"id": "implement-attention-from-scratch",
"legacy_ids": [
"v2-6"
],
"title": "Implement Attention from Scratch",
"description": "Build scaled dot-product attention from raw matrix operations \u2014 queries, keys, values, scaling, and softmax.",
"difficulty": "medium",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/Implement-Attention-from-Scratch/attention-q4-Question.ipynb",
"solution": "llm/Implement-Attention-from-Scratch/attention-q4.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Implement-Attention-from-Scratch/attention-q4-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 5,
"graded": true,
"entries": [
"scaled_dot_product_attention"
],
"hints": [
"scores = q @ k.transpose(-2,-1) / sqrt(d_k), then softmax, then @ v.",
"Divide by sqrt(d_k) or the softmax saturates as dimension grows.",
"Masked positions become -inf BEFORE the softmax, not zero after it."
]
},
{
"id": "multi-head-attention",
"legacy_ids": [
"v2-7"
],
"title": "Implement Multi-Head Attention from Scratch",
"description": "Split attention into multiple heads with independent projections, compute attention per head, and concatenate results.",
"difficulty": "medium",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/Multi-Head-Attention/multi-head-attention-q5-Question.ipynb",
"solution": "llm/Multi-Head-Attention/multi-head-attention-q5.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Multi-Head-Attention/multi-head-attention-q5-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 6,
"graded": true,
"entries": [
"multi_head_attention"
],
"hints": [
"Project Q/K/V, split d_model into num_heads chunks of d_head, attend, then concatenate.",
"Reshape to (batch, heads, seq, d_head) with view + transpose(1, 2).",
"After attention, transpose back and merge the heads before the output projection."
]
},
{
"id": "grouped-query-attention",
"legacy_ids": [
"v2-8"
],
"title": "Implement Grouped Query Attention from Scratch",
"description": "Build GQA where multiple query heads share key-value heads, reducing KV cache memory while preserving quality.",
"difficulty": "medium",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/Grouped-Query-Attention/grouped-query-attention-Question.ipynb",
"solution": "llm/Grouped-Query-Attention/grouped-query-attention.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Grouped-Query-Attention/grouped-query-attention-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 7,
"graded": true,
"entries": [
"grouped_query_attention"
],
"hints": [
"Queries keep all their heads; keys and values only have num_query_groups heads.",
"Project K/V to num_query_groups * d_head, not to d_model \u2014 that is where the saving comes from.",
"repeat_interleave each K/V head across the query heads that share it, then attend as usual."
]
},
{
"id": "sinusoidal-positional-embedding",
"legacy_ids": [
"v2-10"
],
"title": "Implement Sinusoidal Embeddings",
"description": "Build the fixed sinusoidal positional encoding from 'Attention Is All You Need' using sin/cos at different frequencies.",
"difficulty": "medium",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/Sinusoidal-Positional-Embedding/sinusoidal-q7-Question.ipynb",
"solution": "llm/Sinusoidal-Positional-Embedding/sinusoidal-q7.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Sinusoidal-Positional-Embedding/sinusoidal-q7-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 2,
"graded": true,
"entries": [
"SinusoidalPositionalEmbedding"
],
"hints": [
"Even dimensions get sin, odd dimensions get cos.",
"The frequency for dimension i is 1 / 10000**(2i/d_model).",
"It is a fixed function of position \u2014 register it as a buffer, not a parameter."
]
},
{
"id": "rotary-positional-embedding",
"legacy_ids": [
"v2-11"
],
"title": "Implement ROPE Embeddings",
"description": "Build Rotary Position Embeddings that encode relative positions by rotating query and key vectors in complex space.",
"difficulty": "medium",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/Rotary-Positional-Embedding/rope-q8-Question.ipynb",
"solution": "llm/Rotary-Positional-Embedding/rope-q8.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/Rotary-Positional-Embedding/rope-q8-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 3,
"graded": true,
"entries": [
"rotate_half",
"apply_rotary_pos_emb"
],
"hints": [
"rotate_half splits the last dim in two and returns (-x2, x1) concatenated.",
"Rotated q = q*cos + rotate_half(q)*sin \u2014 the 2D rotation written elementwise.",
"cos and sin must broadcast against (batch, heads, seq, dim)."
]
},
{
"id": "smollm",
"legacy_ids": [
"v2-12"
],
"title": "Implement SmolLM from Scratch",
"description": "Build a complete small language model end-to-end: tokenizer integration, transformer blocks, and autoregressive text generation.",
"difficulty": "hard",
"category": "modern-architectures",
"tracks": [
"advanced",
"llm-path"
],
"companies": [],
"question": "llm/SmolLM/smollm-q12-Question.ipynb",
"solution": "llm/SmolLM/smollm-q12.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/llm/SmolLM/smollm-q12-Question.ipynb",
"frequency": "emerging",
"company_confidence": {},
"llm_path_order": 10,
"graded": true,
"entries": [
"rotate_half",
"apply_rotary_pos_emb",
"repeat_kv",
"RotaryEmbedder",
"RopeAttention"
],
"hints": [
"rotate_half splits the last dim in half and returns (-x2, x1) concatenated.",
"repeat_kv expands each KV head n_rep times *in place* so head i of Q pairs with KV head i // n_rep \u2014 expand + reshape, not a plain repeat/tile.",
"RopeAttention: project, split into num_heads (Q) and kv_heads (K/V), rotate Q and K, repeat_kv the K/V, then scaled dot-product attention plus the additive mask."
]
},
{
"id": "softmax",
"legacy_ids": [
"v3-1"
],
"title": "Implement Softmax from Scratch",
"description": "Build numerically stable softmax using the log-sum-exp trick, handling overflow and underflow in raw tensor math.",
"difficulty": "easy",
"category": "classical-ml",
"tracks": [
"basics"
],
"companies": [
"Apple",
"Meta",
"Google",
"Amazon"
],
"question": "v3/classical-ml/softmax/softmax.ipynb",
"solution": "v3/classical-ml/softmax/softmax_SOLN.ipynb",
"colab": "https://colab.research.google.com/github/Exorust/TorchLeet/blob/main/v3/classical-ml/softmax/softmax.ipynb",
"frequency": "very-likely",
"company_confidence": {
"Apple": "inferred",
"Meta": "inferred",
"Google": "inferred",
"Amazon": "inferred"
},
"llm_path_order": null,
"graded": true,